amp icon indicating copy to clipboard operation
amp copied to clipboard

Add Interval

Open trowski opened this issue 7 months ago • 4 comments

This adds a utility class Interval which controls a repeating timer, automatically cancelling the timer when the object is destroyed.

The main use-case of this object is to store an instance of Interval as an object property. When the holding object is destroyed, the repeating timer will be cancelled. This avoids a bit of boilerplate in the class, such as needing to declare a destructor to manually cancel the event loop callback.

The value here isn't necessarily huge, but this is a pattern we frequently use for classes with self-cleanup mechanisms such as LocalCache.

trowski avatar Jul 24 '24 00:07 trowski