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.

Synopsis

Declared in <bdlmt_eventscheduler.h>

class EventScheduler;

Types

Name

Description

Event

Opaque structure identifying a non‐recurring event; pointers are populated by the "Raw" API of EventScheduler.

RecurringEvent

Opaque structure identifying a recurring event; pointers are populated by the "Raw" API of EventScheduler.

Type Aliases

Name

Description

Dispatcher

Defines a type alias for the dispatcher functor type.

EventHandle

Defines a type alias for a handle managing a non‐recurring event.

RecurringEventHandle

Defines a type alias for a handle managing a recurring event.

Member Functions

Name

Description

EventScheduler [constructor]

Constructors

~EventScheduler [destructor]

Discard all unprocessed events and destroy this object. The behavior is undefined unless the scheduler is stopped.

addEventRefRaw

Increment the reference count for the event referred to by the specified handle and return handle. There must be a corresponding call to releaseEventRaw when the reference is no longer needed.

addRecurringEventRefRaw

Increment the reference count for the recurring event referred to by the specified handle and return handle. There must be a corresponding call to releaseEventRaw when the reference is no longer needed.

allocator

Return the allocator used by this object to supply memory.

cancelAllEvents

Cancel all recurring and one‐time events scheduled in this EventScheduler.

cancelAllEventsAndWait

Cancel all recurring and one‐time events scheduled in this EventScheduler. Block until all events have either been cancelled or dispatched before this call returns. The behavior is undefined if this method is invoked from the dispatcher thread.

cancelEvent

cancelEvent overloads

cancelEventAndWait

cancelEventAndWait overloads

clockType

Return the value of the clock type that this object was created with.

isInDispatcherThread

Return true if the calling thread is the dispatcher thread of this scheduler, and false otherwise.

isStarted

Return true if a call to start has finished successfully more recently than any call to stop, and false otherwise.

nextPendingEventTime

Return the earliest scheduled starting time of the pending events and recurring events registered with this scheduler. If there are no pending events or recurring events, return INT64_MAX microseconds.

now

Return the current epoch time, an absolute time represented as an interval from some epoch, which is determined by the clock indicated at construction (see {Supported Clock Types} in the component documentation).

numEvents

Return the number of pending one‐time events in this scheduler.

numRecurringEvents

Return the number of recurring events registered with this scheduler.

releaseEventRaw

releaseEventRaw overloads

rescheduleEvent

rescheduleEvent overloads

rescheduleEventAndWait

rescheduleEventAndWait overloads

scheduleEvent

scheduleEvent overloads

scheduleEventRaw

scheduleEventRaw overloads

scheduleRecurringEvent

scheduleRecurringEvent overloads

scheduleRecurringEventRaw

scheduleRecurringEventRaw overloads

scheduledEventTime

Return the scheduled starting time of the event having the specified handle. If the handle is invalid, or the event has already been canceled, return an optional without a value.

start

start overloads

stop

End the dispatching of events on this scheduler (but do not remove any pending events), and wait for any (one) currently executing event to complete. If the scheduler is already stopped then this method has no effect. This scheduler can be restarted by invoking start. The behavior is undefined if this method is invoked from the dispatcher thread.

operator BloombergLP::bslmf::NestedTraitDeclaration<EventScheduler, UsesBslmaAllocator>

Declare that this type uses a bslma allocator.

Friends

Name

Description

BloombergLP::bdlmt::EventSchedulerTestTimeSource

This class provides a means to change the clock that is used by a given event‐scheduler to determine when events should be triggered. Constructing a EventSchedulerTestTimeSource alters the behavior of the supplied event‐scheduler. After a test time‐source is created, the underlying scheduler will run events according to a discrete timeline, whose successive values are determined by calls to advanceTime on the test time‐source, and can be retrieved by calling now on that test time‐source. Note that the "system‐time" held by a test time‐source does not correspond to the current system time. Test writers must use caution when scheduling absolute‐time events so that they are scheduled relative to the test time‐source's value for now.

BloombergLP::bdlmt::EventSchedulerRecurringEventHandle

Objects of this type refer to recurring events in the EventScheduler API. They are convertible to const RecurringEvent* references and may be used in any method which expects these.

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.

Created with MrDocs