[#BloombergLP-bdlmt-TimerEventScheduler]
= xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlmt.adoc[bdlmt]::TimerEventScheduler
:relfileprefix: ../../
:mrdocs:

Thread&hyphen;safe scheduler that dispatches one&hyphen;shot and recurring callbacks&period;

== Synopsis

Declared in `&lt;bdlmt&lowbar;timereventscheduler&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class TimerEventScheduler;
----

== Description

This class provides a thread&hyphen;safe event scheduler&period; `scheduleEvent` schedules a non&hyphen;recurring event, returning a handle of type `TimerEventScheduler&colon;&colon;Handle`, which can be used to cancel the scheduled event by invoking `cancelEvent`&period; Similarly, `startClock` schedules a recurring event, returning a handle of type `TimerEventScheduler&colon;&colon;Handle`, which can be used to cancel the clock by invoking `cancelClock`&period; `cancelAllEvents` cancels all the registered events and `cancelAllClocks` cancels all the registered clocks&period; The callbacks are processed by a separate thread (called dispatcher thread)&period; 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 &quot;The dispatcher thread and the dispatcher functor&quot;)&period; `start` must be invoked to start dispatching the callbacks&period; `stop` stops the dispatching of the callbacks without removing the pending events&period;

== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/TimerEventScheduler/Dispatcher.adoc[`Dispatcher`] 
| Defines a type alias for the dispatcher functor type&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/EventKey.adoc[`EventKey`] 
| Defines a type alias for a user&hyphen;supplied key for identifying events&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/Handle.adoc[`Handle`] 
| Defines a type alias for a handle that identifies a scheduled clock or event&period;
|===


== Enums

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/TimerEventScheduler/_04enum.adoc[`Unnamed enum`] 
| Invalid handle constants&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/TimerEventScheduler/2constructor-0e02.adoc[`TimerEventScheduler`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlmt/TimerEventScheduler/2destructor.adoc[`&#126;TimerEventScheduler`] [.small]#[destructor]#
| Stop this scheduler, discard all the unprocessed events and destroy this object&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/cancelAllClocks.adoc[`cancelAllClocks`] 
| Cancel all recurring clocks registered with this scheduler&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/cancelAllEvents.adoc[`cancelAllEvents`] 
| Cancel all one&hyphen;shot events registered with this scheduler&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/cancelClock.adoc[`cancelClock`] 
| Cancel the recurring clock identified by the specified handle&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/cancelEvent-0b.adoc[`cancelEvent`] 
| `cancelEvent` overloads
| xref:BloombergLP/bdlmt/TimerEventScheduler/clockType.adoc[`clockType`] 
| Return the value of the clock type that this object was created with&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/nextPendingEventTime.adoc[`nextPendingEventTime`] 
| Return the earliest scheduled time among pending events and clocks&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/now.adoc[`now`] 
| Return the current epoch time for this scheduler&apos;s clock&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/numClocks.adoc[`numClocks`] 
| Return a _snapshot_ of the number of registered clocks with this scheduler&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/numEvents.adoc[`numEvents`] 
| Return a _snapshot_ of the number of pending events and events being dispatched in this scheduler&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/rescheduleEvent-06.adoc[`rescheduleEvent`] 
| `rescheduleEvent` overloads
| xref:BloombergLP/bdlmt/TimerEventScheduler/scheduleEvent.adoc[`scheduleEvent`] 
| Schedule the specified callback to run at the specified time&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/start-0d.adoc[`start`] 
| `start` overloads
| xref:BloombergLP/bdlmt/TimerEventScheduler/startClock.adoc[`startClock`] 
| Schedule a recurring callback at the specified interval&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/stop.adoc[`stop`] 
| Stop dispatching events without removing pending work&period;
| xref:BloombergLP/bdlmt/TimerEventScheduler/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;TimerEventScheduler, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bdlmt/TimerEventSchedulerTestTimeSource.adoc[BloombergLP::bdlmt::TimerEventSchedulerTestTimeSource]`
| Test helper that substitutes a controllable clock into a timer scheduler&period;
| `xref:BloombergLP/bdlmt/TimerEventSchedulerDispatcher.adoc[BloombergLP::bdlmt::TimerEventSchedulerDispatcher]`
| Dispatcher functor type for `TimerEventScheduler`&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
