Thread‐safe scheduler that dispatches one‐shot and recurring callbacks.

Synopsis

Declared in <bdlmt_timereventscheduler.h>

class TimerEventScheduler;

Description

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

Type Aliases

Name

Description

Dispatcher

Defines a type alias for the dispatcher functor type.

EventKey

Defines a type alias for a user‐supplied key for identifying events.

Handle

Defines a type alias for a handle that identifies a scheduled clock or event.

Enums

Name

Description

Unnamed enum

Invalid handle constants.

Member Functions

Name

Description

TimerEventScheduler [constructor]

Constructors

~TimerEventScheduler [destructor]

Stop this scheduler, discard all the unprocessed events and destroy this object.

cancelAllClocks

Cancel all recurring clocks registered with this scheduler.

cancelAllEvents

Cancel all one‐shot events registered with this scheduler.

cancelClock

Cancel the recurring clock identified by the specified handle.

cancelEvent

cancelEvent overloads

clockType

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

nextPendingEventTime

Return the earliest scheduled time among pending events and clocks.

now

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

numClocks

Return a snapshot of the number of registered clocks with this scheduler.

numEvents

Return a snapshot of the number of pending events and events being dispatched in this scheduler.

rescheduleEvent

rescheduleEvent overloads

scheduleEvent

Schedule the specified callback to run at the specified time.

start

start overloads

startClock

Schedule a recurring callback at the specified interval.

stop

Stop dispatching events without removing pending work.

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

Declare that this type uses a bslma allocator.

Friends

Name

Description

BloombergLP::bdlmt::TimerEventSchedulerTestTimeSource

Test helper that substitutes a controllable clock into a timer scheduler.

BloombergLP::bdlmt::TimerEventSchedulerDispatcher

Dispatcher functor type for TimerEventScheduler.

Created with MrDocs