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

Thread&hyphen;safe scheduler that dispatches callbacks on a worker thread&period;

== Synopsis

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

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

== Description

This class provides a thread&hyphen;safe event scheduler that executes callbacks in a separate &quot;dispatcher thread&period;&quot; `start` must be invoked to start dispatching the callbacks&period; `stop` pauses the dispatching of the callbacks without removing the pending events&period;

== Types

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/EventScheduler/Event.adoc[`Event`] 
| Opaque structure identifying a non&hyphen;recurring event&semi; pointers are populated by the &quot;Raw&quot; API of `EventScheduler`&period;
| xref:BloombergLP/bdlmt/EventScheduler/RecurringEvent.adoc[`RecurringEvent`] 
| Opaque structure identifying a recurring event&semi; pointers are populated by the &quot;Raw&quot; API of `EventScheduler`&period;
|===


== Type Aliases

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/EventScheduler/Dispatcher.adoc[`Dispatcher`] 
| Defines a type alias for the dispatcher functor type&period;
| xref:BloombergLP/bdlmt/EventScheduler/EventHandle.adoc[`EventHandle`] 
| Defines a type alias for a handle managing a non&hyphen;recurring event&period;
| xref:BloombergLP/bdlmt/EventScheduler/RecurringEventHandle.adoc[`RecurringEventHandle`] 
| Defines a type alias for a handle managing a recurring event&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:BloombergLP/bdlmt/EventScheduler/2constructor-05e.adoc[`EventScheduler`]         [.small]#[constructor]#
| Constructors
| xref:BloombergLP/bdlmt/EventScheduler/2destructor.adoc[`&#126;EventScheduler`] [.small]#[destructor]#
| Discard all unprocessed events and destroy this object&period; The behavior is undefined unless the scheduler is stopped&period;
| xref:BloombergLP/bdlmt/EventScheduler/addEventRefRaw.adoc[`addEventRefRaw`] 
| Increment the reference count for the event `handle`&period;
| xref:BloombergLP/bdlmt/EventScheduler/addRecurringEventRefRaw.adoc[`addRecurringEventRefRaw`] 
| Increment the reference count for the recurring event `handle`&period;
| xref:BloombergLP/bdlmt/EventScheduler/allocator.adoc[`allocator`] 
| Return the allocator used by this object to supply memory&period;
| xref:BloombergLP/bdlmt/EventScheduler/cancelAllEvents.adoc[`cancelAllEvents`] 
| Cancel all recurring and one&hyphen;time events scheduled in this EventScheduler&period;
| xref:BloombergLP/bdlmt/EventScheduler/cancelAllEventsAndWait.adoc[`cancelAllEventsAndWait`] 
| Cancel all events and wait for completion&period;
| xref:BloombergLP/bdlmt/EventScheduler/cancelEvent-01.adoc[`cancelEvent`] 
| `cancelEvent` overloads
| xref:BloombergLP/bdlmt/EventScheduler/cancelEventAndWait-05.adoc[`cancelEventAndWait`] 
| `cancelEventAndWait` overloads
| xref:BloombergLP/bdlmt/EventScheduler/clockType.adoc[`clockType`] 
| Return the value of the clock type that this object was created with&period;
| xref:BloombergLP/bdlmt/EventScheduler/isInDispatcherThread.adoc[`isInDispatcherThread`] 
| Return `true` if the calling thread is the dispatcher thread of this scheduler, and `false` otherwise&period;
| xref:BloombergLP/bdlmt/EventScheduler/isStarted.adoc[`isStarted`] 
| Return `true` if a call to `start` has finished successfully more recently than any call to `stop`, and `false` otherwise&period;
| xref:BloombergLP/bdlmt/EventScheduler/nextPendingEventTime.adoc[`nextPendingEventTime`] 
| Return the earliest scheduled time of any pending event&period;
| xref:BloombergLP/bdlmt/EventScheduler/now.adoc[`now`] 
| Return the current epoch time for this scheduler&apos;s clock&period;
| xref:BloombergLP/bdlmt/EventScheduler/numEvents.adoc[`numEvents`] 
| Return the number of pending one&hyphen;time events in this scheduler&period;
| xref:BloombergLP/bdlmt/EventScheduler/numRecurringEvents.adoc[`numRecurringEvents`] 
| Return the number of recurring events registered with this scheduler&period;
| xref:BloombergLP/bdlmt/EventScheduler/releaseEventRaw-0e.adoc[`releaseEventRaw`] 
| `releaseEventRaw` overloads
| xref:BloombergLP/bdlmt/EventScheduler/rescheduleEvent-00.adoc[`rescheduleEvent`] 
| Reschedule the event referred to by `handle` to `newEpochTime`&period;
| xref:BloombergLP/bdlmt/EventScheduler/rescheduleEventAndWait-0f.adoc[`rescheduleEventAndWait`] 
| Reschedule `handle` at `newEpochTime` and wait for completion&period;
| xref:BloombergLP/bdlmt/EventScheduler/scheduleEvent-052.adoc[`scheduleEvent`] 
| `scheduleEvent` overloads
| xref:BloombergLP/bdlmt/EventScheduler/scheduleEventRaw-04.adoc[`scheduleEventRaw`] 
| Schedule `callback` and load a raw cancel handle into `event`&period;
| xref:BloombergLP/bdlmt/EventScheduler/scheduleRecurringEvent-09.adoc[`scheduleRecurringEvent`] 
| `scheduleRecurringEvent` overloads
| xref:BloombergLP/bdlmt/EventScheduler/scheduleRecurringEventRaw-06.adoc[`scheduleRecurringEventRaw`] 
| Schedule a recurring event and load a raw cancel handle into `event`&period;
| xref:BloombergLP/bdlmt/EventScheduler/scheduledEventTime-00.adoc[`scheduledEventTime`] 
| `scheduledEventTime` overloads
| xref:BloombergLP/bdlmt/EventScheduler/start-07.adoc[`start`] 
| `start` overloads
| xref:BloombergLP/bdlmt/EventScheduler/stop.adoc[`stop`] 
| Stop dispatching events on this scheduler&period;
| xref:BloombergLP/bdlmt/EventScheduler/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration&lt;EventScheduler, UsesBslmaAllocator&gt;`] 
| Declare that this type uses a `bslma` allocator&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:BloombergLP/bdlmt/EventSchedulerTestTimeSource.adoc[BloombergLP::bdlmt::EventSchedulerTestTimeSource]`
| Test utility that controls the clock used by an `EventScheduler`&period;
| `xref:BloombergLP/bdlmt/EventSchedulerRecurringEventHandle.adoc[BloombergLP::bdlmt::EventSchedulerRecurringEventHandle]`
| Handle referring to a recurring event in an `EventScheduler`&period;
| `xref:BloombergLP/bdlmt/EventSchedulerEventHandle.adoc[BloombergLP::bdlmt::EventSchedulerEventHandle]`
| Objects of this type refer to events in the `EventScheduler` API&period; They are convertible to `const Event&ast;` references and may be used in any method that expects them&period;
|===


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