clang-tools 20.0.0git
|
Used to guard an operation that should run at most every N seconds. More...
#include <Threading.h>
Public Member Functions | |
PeriodicThrottler (Stopwatch::duration Period, Stopwatch::duration Delay={}) | |
If Period is zero, the throttler will return true every time. | |
bool | operator() () |
Returns whether the operation should run at this time. | |
Used to guard an operation that should run at most every N seconds.
Usage: mutable PeriodicThrottler ShouldLog(std::chrono::seconds(1)); void calledFrequently() { if (ShouldLog()) log("this is not spammy"); }
This class is threadsafe. If multiple threads are involved, then the guarded operation still needs to be threadsafe!
Definition at line 186 of file Threading.h.
|
inline |
If Period is zero, the throttler will return true every time.
Definition at line 195 of file Threading.h.
bool clang::clangd::PeriodicThrottler::operator() | ( | ) |
Returns whether the operation should run at this time.
operator() is safe to call concurrently.
Definition at line 130 of file Threading.cpp.