atomic-interval
A very tiny library implementing a lock-free atomic timer.
Documentation
Example
In the following example, we have a concurrent scenario where multiple threads want to push a data sample towards a single and common entity (e.g., a static function, a multi-referenced object, and so on).
The entity wants to provide a "limiter" mechanism, where it actually processes a sample with a limited frequency.
Therefore, even if concurrently threads push with a higher frequency, only one sample (coming from one thread) for each period can be actually processed (i.e., printed).
AtomicInterval can be used without an additional sync mechanism, as it can already be safely shared across threads.
use AtomicIntervalLight;
use OnceCell;
use thread;
use Duration;
const MAX_PERIOD_SAMPLING: Duration = from_secs;