Thread‐safe scheduler that dispatches one‐shot and recurring callbacks.
Synopsis
Declared in <bdlmt_timereventscheduler.h>
class TimerEventScheduler;
Description
This class provides a thread‐safe event scheduler. scheduleEvent schedules a non‐recurring event, returning a handle of type TimerEventScheduler::Handle, which can be used to cancel the scheduled event by invoking cancelEvent. Similarly, startClock schedules a recurring event, returning a handle of type TimerEventScheduler::Handle, which can be used to cancel the clock by invoking cancelClock. cancelAllEvents cancels all the registered events and cancelAllClocks cancels all the registered clocks. The callbacks are processed by a separate thread (called dispatcher thread). By default the callbacks are executed in the dispatcher thread, but this behavior can be altered by providing a dispatcher functor at the creation time (see the section "The dispatcher thread and the dispatcher functor"). start must be invoked to start dispatching the callbacks. stop stops the dispatching of the callbacks without removing the pending events.
Type Aliases
Name |
Description |
Defines a type alias for the dispatcher functor type. |
|
Defines a type alias for a user‐supplied key for identifying events. |
|
Defines a type alias for a handle that identifies a scheduled clock or event. |
Enums
Name |
Description |
Invalid handle constants. |
Member Functions
Name |
Description |
|
Constructors |
|
Stop this scheduler, discard all the unprocessed events and destroy this object. |
Cancel all recurring clocks registered with this scheduler. |
|
Cancel all one‐shot events registered with this scheduler. |
|
Cancel the recurring clock identified by the specified handle. |
|
|
|
Return the value of the clock type that this object was created with. |
|
Return the earliest scheduled time among pending events and clocks. |
|
Return the current epoch time for this scheduler's clock. |
|
Return a snapshot of the number of registered clocks with this scheduler. |
|
Return a snapshot of the number of pending events and events being dispatched in this scheduler. |
|
|
|
Schedule the specified callback to run at the specified time. |
|
|
|
Schedule a recurring callback at the specified interval. |
|
Stop dispatching events without removing pending work. |
|
|
Declare that this type uses a |
Friends
Name |
Description |
Test helper that substitutes a controllable clock into a timer scheduler. |
|
Dispatcher functor type for |
Created with MrDocs