[#BloombergLP-bdlmt-EventScheduler] = xref:BloombergLP.adoc[BloombergLP]::xref:BloombergLP/bdlmt.adoc[bdlmt]::EventScheduler :relfileprefix: ../../ :mrdocs: Thread‐safe scheduler that dispatches callbacks on a worker thread. == Synopsis Declared in `<bdlmt_eventscheduler.h>` [source,cpp,subs="verbatim,replacements,macros,-callouts"] ---- class EventScheduler; ---- == Description This class provides a thread‐safe event scheduler that executes callbacks in a separate "dispatcher thread." `start` must be invoked to start dispatching the callbacks. `stop` pauses the dispatching of the callbacks without removing the pending events. == Types [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlmt/EventScheduler/Event.adoc[`Event`] | Opaque structure identifying a non‐recurring event; pointers are populated by the "Raw" API of `EventScheduler`. | xref:BloombergLP/bdlmt/EventScheduler/RecurringEvent.adoc[`RecurringEvent`] | Opaque structure identifying a recurring event; pointers are populated by the "Raw" API of `EventScheduler`. |=== == Type Aliases [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlmt/EventScheduler/Dispatcher.adoc[`Dispatcher`] | Defines a type alias for the dispatcher functor type. | xref:BloombergLP/bdlmt/EventScheduler/EventHandle.adoc[`EventHandle`] | Defines a type alias for a handle managing a non‐recurring event. | xref:BloombergLP/bdlmt/EventScheduler/RecurringEventHandle.adoc[`RecurringEventHandle`] | Defines a type alias for a handle managing a recurring event. |=== == Member Functions [cols="1,4"] |=== | Name| Description | xref:BloombergLP/bdlmt/EventScheduler/2constructor-05e.adoc[`EventScheduler`] [.small]#[constructor]# | Constructors | xref:BloombergLP/bdlmt/EventScheduler/2destructor.adoc[`~EventScheduler`] [.small]#[destructor]# | Discard all unprocessed events and destroy this object. The behavior is undefined unless the scheduler is stopped. | xref:BloombergLP/bdlmt/EventScheduler/addEventRefRaw.adoc[`addEventRefRaw`] | Increment the reference count for the event `handle`. | xref:BloombergLP/bdlmt/EventScheduler/addRecurringEventRefRaw.adoc[`addRecurringEventRefRaw`] | Increment the reference count for the recurring event `handle`. | xref:BloombergLP/bdlmt/EventScheduler/allocator.adoc[`allocator`] | Return the allocator used by this object to supply memory. | xref:BloombergLP/bdlmt/EventScheduler/cancelAllEvents.adoc[`cancelAllEvents`] | Cancel all recurring and one‐time events scheduled in this EventScheduler. | xref:BloombergLP/bdlmt/EventScheduler/cancelAllEventsAndWait.adoc[`cancelAllEventsAndWait`] | Cancel all events and wait for completion. | 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. | xref:BloombergLP/bdlmt/EventScheduler/isInDispatcherThread.adoc[`isInDispatcherThread`] | Return `true` if the calling thread is the dispatcher thread of this scheduler, and `false` otherwise. | 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. | xref:BloombergLP/bdlmt/EventScheduler/nextPendingEventTime.adoc[`nextPendingEventTime`] | Return the earliest scheduled time of any pending event. | xref:BloombergLP/bdlmt/EventScheduler/now.adoc[`now`] | Return the current epoch time for this scheduler's clock. | xref:BloombergLP/bdlmt/EventScheduler/numEvents.adoc[`numEvents`] | Return the number of pending one‐time events in this scheduler. | xref:BloombergLP/bdlmt/EventScheduler/numRecurringEvents.adoc[`numRecurringEvents`] | Return the number of recurring events registered with this scheduler. | 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`. | xref:BloombergLP/bdlmt/EventScheduler/rescheduleEventAndWait-0f.adoc[`rescheduleEventAndWait`] | Reschedule `handle` at `newEpochTime` and wait for completion. | 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`. | 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`. | 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. | xref:BloombergLP/bdlmt/EventScheduler/2conversion.adoc[`operator BloombergLP::bslmf::NestedTraitDeclaration<EventScheduler, UsesBslmaAllocator>`] | Declare that this type uses a `bslma` allocator. |=== == Friends [cols="1,4"] |=== | Name| Description | `xref:BloombergLP/bdlmt/EventSchedulerTestTimeSource.adoc[BloombergLP::bdlmt::EventSchedulerTestTimeSource]` | Test utility that controls the clock used by an `EventScheduler`. | `xref:BloombergLP/bdlmt/EventSchedulerRecurringEventHandle.adoc[BloombergLP::bdlmt::EventSchedulerRecurringEventHandle]` | Handle referring to a recurring event in an `EventScheduler`. | `xref:BloombergLP/bdlmt/EventSchedulerEventHandle.adoc[BloombergLP::bdlmt::EventSchedulerEventHandle]` | Objects of this type refer to events in the `EventScheduler` API. They are convertible to `const Event*` references and may be used in any method that expects them. |=== [.small]#Created with https://www.mrdocs.com[MrDocs]#