BDE 4.14.0 Production release
Loading...
Searching...
No Matches
bdlmt::TimerEventScheduler Class Reference

#include <bdlmt_timereventscheduler.h>

Public Types

enum  { e_INVALID_HANDLE = -1 , BCEP_INVALID_HANDLE = e_INVALID_HANDLE , INVALID_HANDLE = e_INVALID_HANDLE }
 
typedef int Handle
 
typedef bsl::function< void(const bsl::function< void()> &)> Dispatcher
 Defines a type alias for the dispatcher functor type.
 
typedef bdlcc::TimeQueue< bsl::function< void()> >::Key EventKey
 Defines a type alias for a user-supplied key for identifying events.
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (TimerEventScheduler, bslma::UsesBslmaAllocator)
 
 TimerEventScheduler (bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (bsls::SystemClockType::Enum clockType, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (const Dispatcher &dispatcherFunctor, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (const Dispatcher &dispatcherFunctor, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (const Dispatcher &dispatcherFunctor, bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (const Dispatcher &dispatcherFunctor, bsls::SystemClockType::Enum clockType, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (int numEvents, int numClocks, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (int numEvents, int numClocks, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (int numEvents, int numClocks, bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (int numEvents, int numClocks, bsls::SystemClockType::Enum clockType, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (int numEvents, int numClocks, const Dispatcher &dispatcherFunctor, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (int numEvents, int numClocks, const Dispatcher &dispatcherFunctor, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (int numEvents, int numClocks, const Dispatcher &dispatcherFunctor, bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0)
 
 TimerEventScheduler (int numEvents, int numClocks, const Dispatcher &dispatcherFunctor, bsls::SystemClockType::Enum clockType, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 ~TimerEventScheduler ()
 
int start ()
 
int start (const bslmt::ThreadAttributes &threadAttributes)
 
void stop ()
 
Handle scheduleEvent (const bsls::TimeInterval &time, const bsl::function< void()> &callback, const EventKey &key=EventKey(0))
 
int rescheduleEvent (Handle handle, const bsls::TimeInterval &newTime, bool wait=false)
 
int rescheduleEvent (Handle handle, const EventKey &key, const bsls::TimeInterval &newTime, bool wait=false)
 
int cancelEvent (Handle handle, bool wait=false)
 
int cancelEvent (Handle handle, const EventKey &key, bool wait=false)
 
void cancelAllEvents (bool wait=false)
 
Handle startClock (const bsls::TimeInterval &interval, const bsl::function< void()> &callback, const bsls::TimeInterval &startTime=bsls::TimeInterval(0))
 
int cancelClock (Handle handle, bool wait=false)
 
void cancelAllClocks (bool wait=false)
 
bsls::SystemClockType::Enum clockType () const
 Return the value of the clock type that this object was created with.
 
bsls::TimeInterval now () const
 
int numClocks () const
 
int numEvents () const
 
bsls::TimeInterval nextPendingEventTime () const
 

Friends

struct TimerEventSchedulerDispatcher
 
class TimerEventSchedulerTestTimeSource
 

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

See bdlmt_timereventscheduler

Member Typedef Documentation

◆ Dispatcher

◆ EventKey

◆ Handle

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

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
e_INVALID_HANDLE 
BCEP_INVALID_HANDLE 
INVALID_HANDLE 

Constructor & Destructor Documentation

◆ TimerEventScheduler() [1/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( bslma::Allocator basicAllocator = 0)
explicit

Construct an event scheduler using the default dispatcher functor (see the "The dispatcher thread and the dispatcher functor" section in component-level doc) and use the realtime clock epoch for all time intervals (see Supported Clock-Types . Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that the maximal number of scheduled non-recurring events and recurring events defaults to an implementation defined constant.

◆ TimerEventScheduler() [2/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)
explicit

Construct an event scheduler using the default dispatcher functor (see the "The dispatcher thread and the dispatcher functor" section in component-level doc), use the realtime clock epoch for all time intervals (see Supported Clock-Types , the specified eventSchedulerName to be used to identify this event scheduler, and the specified metricsRegistry to be used for reporting metrics. If metricsRegistry is 0, bdlm::MetricsRegistry::singleton() is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that the maximal number of scheduled non-recurring events and recurring events defaults to an implementation defined constant.

◆ TimerEventScheduler() [3/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( bsls::SystemClockType::Enum  clockType,
bslma::Allocator basicAllocator = 0 
)
explicit

Construct an event scheduler using the default dispatcher functor (see the "The dispatcher thread and the dispatcher functor" section in component-level doc) and use the specified clockType to indicate the epoch used for all time intervals (see Supported Clock-Types . Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that the maximal number of scheduled non-recurring events and recurring events defaults to an implementation defined constant.

◆ TimerEventScheduler() [4/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( bsls::SystemClockType::Enum  clockType,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)
explicit

Construct an event scheduler using the default dispatcher functor (see the "The dispatcher thread and the dispatcher functor" section in component-level doc), use the specified clockType to indicate the epoch used for all time intervals (see []#(Supported Clock-Types)), the specified eventSchedulerName to be used to identify this event scheduler, and the specified metricsRegistry to be used for reporting metrics. If metricsRegistry is 0, bdlm::MetricsRegistry::singleton() is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that the maximal number of scheduled non-recurring events and recurring events defaults to an implementation defined constant.

◆ TimerEventScheduler() [5/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( const Dispatcher dispatcherFunctor,
bslma::Allocator basicAllocator = 0 
)
explicit

Construct an event scheduler using the specified dispatcherFunctor (see "The dispatcher thread and the dispatcher functor" section in component-level doc) and use the realtime clock epoch for all time intervals (see Supported Clock-Types . Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that the maximal number of scheduled non-recurring events and recurring events defaults to an implementation defined constant.

◆ TimerEventScheduler() [6/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( const Dispatcher dispatcherFunctor,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)
explicit

Construct an event scheduler using the specified dispatcherFunctor (see "The dispatcher thread and the dispatcher functor" section in component-level doc), use the realtime clock epoch for all time intervals (see Supported Clock-Types , the specified eventSchedulerName to be used to identify this event scheduler, and the specified metricsRegistry to be used for reporting metrics. If metricsRegistry is 0, bdlm::MetricsRegistry::singleton() is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that the maximal number of scheduled non-recurring events and recurring events defaults to an implementation defined constant.

◆ TimerEventScheduler() [7/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( const Dispatcher dispatcherFunctor,
bsls::SystemClockType::Enum  clockType,
bslma::Allocator basicAllocator = 0 
)
explicit

Construct an event scheduler using the specified dispatcherFunctor (see "The dispatcher thread and the dispatcher functor" section in component-level doc) and use the specified clockType to indicate the epoch used for all time intervals (see Supported Clock-Types . Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that the maximal number of scheduled non-recurring events and recurring events defaults to an implementation defined constant.

◆ TimerEventScheduler() [8/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( const Dispatcher dispatcherFunctor,
bsls::SystemClockType::Enum  clockType,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)
explicit

Construct an event scheduler using the specified dispatcherFunctor (see "The dispatcher thread and the dispatcher functor" section in component-level doc), use the specified clockType to indicate the epoch used for all time intervals (see Supported Clock-Types , the specified eventSchedulerName to be used to identify this event scheduler, and the specified metricsRegistry to be used for reporting metrics. If metricsRegistry is 0, bdlm::MetricsRegistry::singleton() is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. Note that the maximal number of scheduled non-recurring events and recurring events defaults to an implementation defined constant.

◆ TimerEventScheduler() [9/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( int  numEvents,
int  numClocks,
bslma::Allocator basicAllocator = 0 
)

Construct a timer event scheduler using the default dispatcher functor (see the "The dispatcher thread and the dispatcher functor" section in component level doc) that has the capability to concurrently schedule at least the specified numEvents and numClocks and use the realtime clock epoch for all time intervals (see Supported Clock-Types . Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 0 <= numEvents < 2**24 and 0 <= numClocks < 2**24.

◆ TimerEventScheduler() [10/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( int  numEvents,
int  numClocks,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)

Construct a timer event scheduler using the default dispatcher functor (see the "The dispatcher thread and the dispatcher functor" section in component level doc) that has the capability to concurrently schedule at least the specified numEvents and numClocks, use the realtime clock epoch for all time intervals (see Supported Clock-Types , the specified eventSchedulerName to be used to identify this event scheduler, and the specified metricsRegistry to be used for reporting metrics. If metricsRegistry is 0, bdlm::MetricsRegistry::singleton() is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 0 <= numEvents < 2**24 and 0 <= numClocks < 2**24.

◆ TimerEventScheduler() [11/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( int  numEvents,
int  numClocks,
bsls::SystemClockType::Enum  clockType,
bslma::Allocator basicAllocator = 0 
)

Construct a timer event scheduler using the default dispatcher functor (see the "The dispatcher thread and the dispatcher functor" section in component level doc) that has the capability to concurrently schedule at least the specified numEvents and numClocks and use the specified clockType to indicate the epoch used for all time intervals (see Supported Clock-Types . Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 0 <= numEvents < 2**24 and 0 <= numClocks < 2**24.

◆ TimerEventScheduler() [12/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( int  numEvents,
int  numClocks,
bsls::SystemClockType::Enum  clockType,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)

Construct a timer event scheduler using the default dispatcher functor (see the "The dispatcher thread and the dispatcher functor" section in component level doc) that has the capability to concurrently schedule at least the specified numEvents and numClocks, use the specified clockType to indicate the epoch used for all time intervals (see bdlmt_timereventscheduler-supported-clock-types-in-the-component-documentation , the specified eventSchedulerName to be used to identify this event scheduler, and the specified metricsRegistry to be used for reporting metrics. If metricsRegistry is 0, bdlm::MetricsRegistry::singleton() is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 0 <= numEvents < 2**24 and 0 <= numClocks < 2**24.

◆ TimerEventScheduler() [13/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( int  numEvents,
int  numClocks,
const Dispatcher dispatcherFunctor,
bslma::Allocator basicAllocator = 0 
)

Construct a timer event scheduler using the specified dispatcherFunctor (see "The dispatcher thread and the dispatcher functor" section in component level doc) that has the capability to concurrently schedule at least the specified numEvents and numClocks and use the realtime clock epoch for all time intervals (see Supported Clock-Types . Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 0 <= numEvents < 2**24 and 0 <= numClocks < 2**24.

◆ TimerEventScheduler() [14/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( int  numEvents,
int  numClocks,
const Dispatcher dispatcherFunctor,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)

Construct a timer event scheduler using the specified dispatcherFunctor (see "The dispatcher thread and the dispatcher functor" section in component level doc) that has the capability to concurrently schedule at least the specified numEvents and numClocks, use the realtime clock epoch for all time intervals (see Supported Clock-Types , the specified eventSchedulerName to be used to identify this event scheduler, and the specified metricsRegistry to be used for reporting metrics. If metricsRegistry is 0, bdlm::MetricsRegistry::singleton() is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 0 <= numEvents < 2**24 and 0 <= numClocks < 2**24.

◆ TimerEventScheduler() [15/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( int  numEvents,
int  numClocks,
const Dispatcher dispatcherFunctor,
bsls::SystemClockType::Enum  clockType,
bslma::Allocator basicAllocator = 0 
)

Construct a timer event scheduler using the specified dispatcherFunctor (see "The dispatcher thread and the dispatcher functor" section in component level doc) that has the capability to concurrently schedule at least the specified numEvents and numClocks and use the specified clockType to indicate the epoch used for all time intervals (see Supported Clock-Types . Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 0 <= numEvents < 2**24 and 0 <= numClocks < 2**24.

◆ TimerEventScheduler() [16/16]

bdlmt::TimerEventScheduler::TimerEventScheduler ( int  numEvents,
int  numClocks,
const Dispatcher dispatcherFunctor,
bsls::SystemClockType::Enum  clockType,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)

Construct a timer event scheduler using the specified dispatcherFunctor (see "The dispatcher thread and the dispatcher functor" section in component level doc) that has the capability to concurrently schedule at least the specified numEvents and numClocks, use the specified clockType to indicate the epoch used for all time intervals (see Supported Clock-Types , the specified eventSchedulerName to be used to identify this event scheduler, and the specified metricsRegistry to be used for reporting metrics. If metricsRegistry is 0, bdlm::MetricsRegistry::singleton() is used. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used. The behavior is undefined unless 0 <= numEvents < 2**24 and 0 <= numClocks < 2**24.

◆ ~TimerEventScheduler()

bdlmt::TimerEventScheduler::~TimerEventScheduler ( )

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

Member Function Documentation

◆ BSLMF_NESTED_TRAIT_DECLARATION()

bdlmt::TimerEventScheduler::BSLMF_NESTED_TRAIT_DECLARATION ( TimerEventScheduler  ,
bslma::UsesBslmaAllocator   
)

◆ cancelAllClocks()

void bdlmt::TimerEventScheduler::cancelAllClocks ( bool  wait = false)

Cancel all clocks. If the optionally specified wait is true, then ensure that any clock event still in this scheduler is either cancelled or has been dispatched before this call returns. If this method is being invoked from the dispatcher thread, then the wait is ignored to avoid deadlock.

◆ cancelAllEvents()

void bdlmt::TimerEventScheduler::cancelAllEvents ( bool  wait = false)

Cancel all the events. If the optionally specified wait is true, then ensure any event still in this scheduler is either cancelled or has been dispatched before this call returns. If this method is being invoked from the dispatcher thread then the wait is ignored to avoid deadlock.

◆ cancelClock()

int bdlmt::TimerEventScheduler::cancelClock ( Handle  handle,
bool  wait = false 
)

Cancel the clock having the specified handle. If the optionally specified wait is true, then ensure that any scheduled event for the clock having handle is either cancelled or has been dispatched before this call returns. Return 0 on success, and a non-zero value if the handle is invalid. If this method is being invoked from the dispatcher thread, then the wait is ignored to avoid deadlock.

◆ cancelEvent() [1/2]

int bdlmt::TimerEventScheduler::cancelEvent ( TimerEventScheduler::Handle  handle,
bool  wait = false 
)
inline

◆ cancelEvent() [2/2]

int bdlmt::TimerEventScheduler::cancelEvent ( Handle  handle,
const EventKey key,
bool  wait = false 
)

Cancel the event having the specified handle. Optionally use the specified key to uniquely identify the event. If the optionally specified wait is true, then ensure that the dispatcher thread has resumed execution before returning. Return 0 on successful cancellation, and a non-zero value if the handle is invalid or if it is too late to cancel the event. If this method is being invoked from the dispatcher thread then the wait is ignored to avoid deadlock.

◆ clockType()

bsls::SystemClockType::Enum bdlmt::TimerEventScheduler::clockType ( ) const
inline

◆ nextPendingEventTime()

bsls::TimeInterval bdlmt::TimerEventScheduler::nextPendingEventTime ( ) const

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

◆ now()

bsls::TimeInterval bdlmt::TimerEventScheduler::now ( ) const
inline

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 .

◆ numClocks()

int bdlmt::TimerEventScheduler::numClocks ( ) const
inline

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

◆ numEvents()

int bdlmt::TimerEventScheduler::numEvents ( ) const
inline

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

◆ rescheduleEvent() [1/2]

int bdlmt::TimerEventScheduler::rescheduleEvent ( TimerEventScheduler::Handle  handle,
const bsls::TimeInterval newTime,
bool  wait = false 
)
inline

◆ rescheduleEvent() [2/2]

int bdlmt::TimerEventScheduler::rescheduleEvent ( Handle  handle,
const EventKey key,
const bsls::TimeInterval newTime,
bool  wait = false 
)

Reschedule the event having the specified handle at the specified newTime. Optionally use the specified key to uniquely identify the event. If the optionally specified wait is true, then ensure that the event having the handle (if it is valid) is either successfully rescheduled or dispatched before the call returns. Return 0 on successful reschedule, and a non-zero value if the handle is invalid or if the event has already been dispatched or if the event has not yet been dispatched but will soon be dispatched. If this method is being invoked from the dispatcher thread then the wait is ignored to avoid deadlock. The newTime is an absolute time represented as an interval from some epoch, which is detemined by the clock indicated at construction (see Supported Clock-Types .

◆ scheduleEvent()

Handle bdlmt::TimerEventScheduler::scheduleEvent ( const bsls::TimeInterval time,
const bsl::function< void()> &  callback,
const EventKey key = EventKey(0) 
)

Schedule the specified callback to be dispatched at the specified time. On success, return a handle that can be used to cancel the callback (by invoking cancelEvent), or return e_INVALID_HANDLE if scheduling this event would exceed the maximum number of scheduled events for this object (see constructor). Optionally specify key to uniquely identify the event. The time is an absolute time represented as an interval from some epoch, which is detemined by the clock indicated at construction (see Supported Clock-Types .

◆ start() [1/2]

int bdlmt::TimerEventScheduler::start ( )

Begin dispatching events on this scheduler using default attributes for the dispatcher thread. Return 0 on success, and a nonzero value otherwise. If another thread is currently executing stop, wait until the dispatcher thread stops before starting a new one. If this scheduler has already started (and is not currently being stopped by another thread) then this invocation has no effect and 0 is returned. The created thread will use the eventSchedulerName supplied at construction if it is not empty, otherwise "bdl.TimerEvent". The behavior is undefined if this method is invoked in the dispatcher thread (i.e., in a job executed by this scheduler). Note that any event whose time has already passed is pending and will be dispatched immediately.

◆ start() [2/2]

int bdlmt::TimerEventScheduler::start ( const bslmt::ThreadAttributes threadAttributes)

Begin dispatching events on this scheduler using the specified threadAttributes for the dispatcher thread (except that the DETACHED attribute is ignored). Return 0 on success, and a nonzero value otherwise. If another thread is currently executing stop, wait until the dispatcher thread stops before starting a new one. If this scheduler has already started (and is not currently being stopped by another thread) then this invocation has no effect and 0 is returned. The created thread will use the name threadAttributes.getThreadName() if it is not empty, otherwise eventSchedulerName supplied at construction if it is not empty, otherwise "bdl.TimerEvent". The behavior is undefined if this method is invoked in the dispatcher thread (i.e., in a job executed by this scheduler). Note that any event whose time has already passed is pending and will be dispatched immediately.

◆ startClock()

Handle bdlmt::TimerEventScheduler::startClock ( const bsls::TimeInterval interval,
const bsl::function< void()> &  callback,
const bsls::TimeInterval startTime = bsls::TimeInterval(0) 
)

Schedule a recurring event that invokes the specified callback at every specified interval, starting at the optionally specified startTime. On success, return a handle that can be use to cancel the clock (by invoking cancelClock), or return e_INVALID_HANDLE if scheduling this event would exceed the maximum number of scheduled events for this object (see constructor). If no start time is specified, it is assumed to be the interval time from now. The startTime is an absolute time represented as an interval from some epoch, which is detemined by the clock indicated at construction (see Supported Clock-Types .

◆ stop()

void bdlmt::TimerEventScheduler::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.

Friends And Related Symbol Documentation

◆ TimerEventSchedulerDispatcher

friend struct TimerEventSchedulerDispatcher
friend

◆ TimerEventSchedulerTestTimeSource

friend class TimerEventSchedulerTestTimeSource
friend

The documentation for this class was generated from the following file: