Thread‐safe scheduler that dispatches callbacks on a worker thread.

Synopsis

Declared in <bdlmt_eventscheduler.h>

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

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 handle.

addRecurringEventRefRaw

Increment the reference count for the recurring event handle.

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 events and wait for completion.

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 time of any pending event.

now

Return the current epoch time for this scheduler's clock.

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

Reschedule the event referred to by handle to newEpochTime.

rescheduleEventAndWait

Reschedule handle at newEpochTime and wait for completion.

scheduleEvent

scheduleEvent overloads

scheduleEventRaw

Schedule callback and load a raw cancel handle into event.

scheduleRecurringEvent

scheduleRecurringEvent overloads

scheduleRecurringEventRaw

Schedule a recurring event and load a raw cancel handle into event.

scheduledEventTime

scheduledEventTime overloads

start

start overloads

stop

Stop dispatching events on this scheduler.

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

Declare that this type uses a bslma allocator.

Friends

Name

Description

BloombergLP::bdlmt::EventSchedulerTestTimeSource

Test utility that controls the clock used by an EventScheduler.

BloombergLP::bdlmt::EventSchedulerRecurringEventHandle

Handle referring to a recurring event in an EventScheduler.

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