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

#include <bdlmt_eventscheduler.h>

Classes

struct  Event
 
struct  RecurringEvent
 

Public Types

typedef EventSchedulerEventHandle EventHandle
 
typedef EventSchedulerRecurringEventHandle RecurringEventHandle
 
typedef bsl::function< void(const bsl::function< void()> &)> Dispatcher
 Defines a type alias for the dispatcher functor type.
 

Public Member Functions

 BSLMF_NESTED_TRAIT_DECLARATION (EventScheduler, bslma::UsesBslmaAllocator)
 
 EventScheduler (bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (bsls::SystemClockType::Enum clockType, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const bsl::chrono::system_clock &, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const bsl::chrono::system_clock &, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const bsl::chrono::steady_clock &, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const bsl::chrono::steady_clock &, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const Dispatcher &dispatcherFunctor, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const Dispatcher &dispatcherFunctor, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const Dispatcher &dispatcherFunctor, bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const Dispatcher &dispatcherFunctor, bsls::SystemClockType::Enum clockType, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const Dispatcher &dispatcherFunctor, const bsl::chrono::system_clock &, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const Dispatcher &dispatcherFunctor, const bsl::chrono::system_clock &, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const Dispatcher &dispatcherFunctor, const bsl::chrono::steady_clock &, bslma::Allocator *basicAllocator=0)
 
 EventScheduler (const Dispatcher &dispatcherFunctor, const bsl::chrono::steady_clock &, const bsl::string_view &eventSchedulerName, bdlm::MetricsRegistry *metricsRegistry, bslma::Allocator *basicAllocator=0)
 
 ~EventScheduler ()
 
void cancelAllEvents ()
 
void cancelAllEventsAndWait ()
 
int cancelEvent (const Event *handle)
 
int cancelEvent (const RecurringEvent *handle)
 
int cancelEvent (EventHandle *handle)
 
int cancelEvent (RecurringEventHandle *handle)
 
int cancelEventAndWait (const Event *handle)
 
int cancelEventAndWait (const RecurringEvent *handle)
 
int cancelEventAndWait (EventHandle *handle)
 
int cancelEventAndWait (RecurringEventHandle *handle)
 
void releaseEventRaw (Event *handle)
 
void releaseEventRaw (RecurringEvent *handle)
 
int rescheduleEvent (const Event *handle, const bsls::TimeInterval &newEpochTime)
 
template<class t_CLOCK , class t_DURATION >
int rescheduleEvent (const Event *handle, const bsl::chrono::time_point< t_CLOCK, t_DURATION > &newEpochTime)
 
int rescheduleEventAndWait (const Event *handle, const bsls::TimeInterval &newEpochTime)
 
template<class t_CLOCK , class t_DURATION >
int rescheduleEventAndWait (const Event *handle, const bsl::chrono::time_point< t_CLOCK, t_DURATION > &newEpochTime)
 
void scheduleEvent (const bsls::TimeInterval &epochTime, const bsl::function< void()> &callback)
 
void scheduleEvent (EventHandle *event, const bsls::TimeInterval &epochTime, const bsl::function< void()> &callback)
 
template<class t_CLOCK , class t_DURATION >
void scheduleEvent (const bsl::chrono::time_point< t_CLOCK, t_DURATION > &epochTime, const bsl::function< void()> &callback)
 
template<class t_CLOCK , class t_DURATION >
void scheduleEvent (EventHandle *event, const bsl::chrono::time_point< t_CLOCK, t_DURATION > &epochTime, const bsl::function< void()> &callback)
 
void scheduleEventRaw (Event **event, const bsls::TimeInterval &epochTime, const bsl::function< void()> &callback)
 
template<class t_CLOCK , class t_DURATION >
void scheduleEventRaw (Event **event, const bsl::chrono::time_point< t_CLOCK, t_DURATION > &epochTime, const bsl::function< void()> &callback)
 
void scheduleRecurringEvent (const bsls::TimeInterval &interval, const bsl::function< void()> &callback, const bsls::TimeInterval &startEpochTime=bsls::TimeInterval(0))
 
void scheduleRecurringEvent (RecurringEventHandle *event, const bsls::TimeInterval &interval, const bsl::function< void()> &callback, const bsls::TimeInterval &startEpochTime=bsls::TimeInterval(0))
 
template<class t_CLOCK , class t_REP_TYPE , class t_PERIOD_TYPE , class t_DURATION >
void scheduleRecurringEvent (const bsl::chrono::duration< t_REP_TYPE, t_PERIOD_TYPE > &interval, const bsl::function< void()> &callback, const bsl::chrono::time_point< t_CLOCK, t_DURATION > &startEpochTime=t_CLOCK::now())
 
template<class t_CLOCK , class t_REP_TYPE , class t_PERIOD_TYPE , class t_DURATION >
void scheduleRecurringEvent (RecurringEventHandle *event, const bsl::chrono::duration< t_REP_TYPE, t_PERIOD_TYPE > &interval, const bsl::function< void()> &callback, const bsl::chrono::time_point< t_CLOCK, t_DURATION > &startEpochTime=t_CLOCK::now())
 
void scheduleRecurringEventRaw (RecurringEvent **event, const bsls::TimeInterval &interval, const bsl::function< void()> &callback, const bsls::TimeInterval &startEpochTime=bsls::TimeInterval(0))
 
template<class t_CLOCK , class t_REP_TYPE , class t_PERIOD_TYPE , class t_DURATION >
void scheduleRecurringEventRaw (RecurringEvent **event, const bsl::chrono::duration< t_REP_TYPE, t_PERIOD_TYPE > &interval, const bsl::function< void()> &callback, const bsl::chrono::time_point< t_CLOCK, t_DURATION > &startEpochTime=t_CLOCK::now())
 
int start ()
 
int start (const bslmt::ThreadAttributes &threadAttributes)
 
void stop ()
 
EventaddEventRefRaw (Event *handle) const
 
RecurringEventaddRecurringEventRefRaw (RecurringEvent *handle) const
 
bsls::SystemClockType::Enum clockType () const
 
bool isInDispatcherThread () const
 
bool isStarted () const
 
bsls::TimeInterval now () const
 
int numEvents () const
 Return the number of pending one-time events in this scheduler.
 
int numRecurringEvents () const
 
bsls::TimeInterval nextPendingEventTime () const
 
bslma::Allocatorallocator () const
 Return the allocator used by this object to supply memory.
 

Friends

class EventSchedulerEventHandle
 
class EventSchedulerRecurringEventHandle
 
class EventSchedulerTestTimeSource
 

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

See bdlmt_eventscheduler

Member Typedef Documentation

◆ Dispatcher

◆ EventHandle

◆ RecurringEventHandle

Constructor & Destructor Documentation

◆ EventScheduler() [1/16]

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

Create an event scheduler using the default dispatcher functor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation) and using the system realtime clock to indicate the epoch used for all time intervals. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ EventScheduler() [2/16]

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

Create an event scheduler using the default dispatcher functor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation), using the system realtime clock to indicate the epoch used for all time intervals, 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.

◆ EventScheduler() [3/16]

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

Create an event scheduler using the default dispatcher functor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation) and using the specified clockType to indicate the epoch used for all time intervals (see {Supported Clock Types} in the component documentation). Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ EventScheduler() [4/16]

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

Create an event scheduler using the default dispatcher functor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation), using the specified clockType to indicate the epoch used for all time intervals (see {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.

◆ EventScheduler() [5/16]

bdlmt::EventScheduler::EventScheduler ( const bsl::chrono::system_clock &  ,
bslma::Allocator basicAllocator = 0 
)
explicit

Create an event scheduler using the default dispatcher functor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation) and using the system realtime clock to indicate the epoch used for all time intervals. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ EventScheduler() [6/16]

bdlmt::EventScheduler::EventScheduler ( const bsl::chrono::system_clock &  ,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)
explicit

Create an event scheduler using the default dispatcher functor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation), using the system realtime clock to indicate the epoch used for all time intervals, 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.

◆ EventScheduler() [7/16]

bdlmt::EventScheduler::EventScheduler ( const bsl::chrono::steady_clock &  ,
bslma::Allocator basicAllocator = 0 
)
explicit

Create an event scheduler using the default dispatcher functor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation) and using the system monotonic clock to indicate the epoch used for all time intervals. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ EventScheduler() [8/16]

bdlmt::EventScheduler::EventScheduler ( const bsl::chrono::steady_clock &  ,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)
explicit

Create an event scheduler using the default dispatcher functor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation), using the system monotonic clock to indicate the epoch used for all time intervals, 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.

◆ EventScheduler() [9/16]

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

Create an event scheduler using the specified dispatcherFunctor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation) and using the system realtime clock to indicate the epoch used for all time intervals. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ EventScheduler() [10/16]

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

Create an event scheduler using the specified dispatcherFunctor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation), using the system realtime clock to indicate the epoch used for all time intervals, 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.

◆ EventScheduler() [11/16]

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

Create an event scheduler using the specified dispatcherFunctor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation) and using the specified clockType to indicate the epoch used for all time intervals (see {Supported Clock Types} in the component documentation). Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ EventScheduler() [12/16]

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

Create an event scheduler using the specified dispatcherFunctor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation), using the specified clockType to indicate the epoch used for all time intervals (see {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.

◆ EventScheduler() [13/16]

bdlmt::EventScheduler::EventScheduler ( const Dispatcher dispatcherFunctor,
const bsl::chrono::system_clock &  ,
bslma::Allocator basicAllocator = 0 
)

Create an event scheduler using the specified dispatcherFunctor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation) and using the system realtime clock to indicate the epoch used for all time intervals. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ EventScheduler() [14/16]

bdlmt::EventScheduler::EventScheduler ( const Dispatcher dispatcherFunctor,
const bsl::chrono::system_clock &  ,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)

Create an event scheduler using the specified dispatcherFunctor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation), using the system realtime clock to indicate the epoch used for all time intervals, 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.

◆ EventScheduler() [15/16]

bdlmt::EventScheduler::EventScheduler ( const Dispatcher dispatcherFunctor,
const bsl::chrono::steady_clock &  ,
bslma::Allocator basicAllocator = 0 
)

Create an event scheduler using the specified dispatcherFunctor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation) and using the system monotonic clock to indicate the epoch used for all time intervals. Optionally specify a basicAllocator used to supply memory. If basicAllocator is 0, the currently installed default allocator is used.

◆ EventScheduler() [16/16]

bdlmt::EventScheduler::EventScheduler ( const Dispatcher dispatcherFunctor,
const bsl::chrono::steady_clock &  ,
const bsl::string_view eventSchedulerName,
bdlm::MetricsRegistry metricsRegistry,
bslma::Allocator basicAllocator = 0 
)

Create an event scheduler using the specified dispatcherFunctor (see {The Dispatcher Thread and the Dispatcher Functor} in the component-level documentation), using the system monotonic clock to indicate the epoch used for all time intervals, 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.

◆ ~EventScheduler()

bdlmt::EventScheduler::~EventScheduler ( )

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

Member Function Documentation

◆ addEventRefRaw()

EventScheduler::Event * bdlmt::EventScheduler::addEventRefRaw ( Event handle) const
inline

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()

EventScheduler::RecurringEvent * bdlmt::EventScheduler::addRecurringEventRefRaw ( RecurringEvent handle) const
inline

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()

bslma::Allocator * bdlmt::EventScheduler::allocator ( ) const
inline

◆ BSLMF_NESTED_TRAIT_DECLARATION()

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

◆ cancelAllEvents()

void bdlmt::EventScheduler::cancelAllEvents ( )

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

◆ cancelAllEventsAndWait()

void bdlmt::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() [1/4]

int bdlmt::EventScheduler::cancelEvent ( const Event handle)
inline

◆ cancelEvent() [2/4]

int bdlmt::EventScheduler::cancelEvent ( const RecurringEvent handle)
inline

Cancel the event having the specified handle. Return 0 on successful cancellation, and a non-zero value if the handle is invalid or if the event has already been dispatched or canceled. Note that due to the implicit conversion from Handle types, these methods also match the following:

int cancelEvent(const EventHandle& handle);
int cancelEvent(const RecurringEventHandle& handle);
Definition bdlmt_eventscheduler.h:1528
Definition bdlmt_eventscheduler.h:1580
int cancelEvent(const Event *handle)
Definition bdlmt_eventscheduler.h:1833

Compared to the version taking a pointer to Handle, the managed reference to the event is not released until the Handle goes out of scope.

◆ cancelEvent() [3/4]

int bdlmt::EventScheduler::cancelEvent ( EventHandle handle)

◆ cancelEvent() [4/4]

int bdlmt::EventScheduler::cancelEvent ( RecurringEventHandle handle)

Cancel the event having the specified handle and release the handle. Return 0 on successful cancellation, and a non-zero value if the handle is invalid or if the event has already been dispatched or canceled. Note that handle is released whether this call is successful or not.

◆ cancelEventAndWait() [1/4]

int bdlmt::EventScheduler::cancelEventAndWait ( const Event handle)

◆ cancelEventAndWait() [2/4]

int bdlmt::EventScheduler::cancelEventAndWait ( const RecurringEvent handle)

Cancel the event having the specified handle. Block until the event having handle (if it is valid) is either successfully canceled or dispatched before the call returns. Return 0 on successful cancellation, and a non-zero value if handle is invalid or if the event has already been dispatched or canceled. The behavior is undefined if this method is invoked from the dispatcher thread. Note that if the event is being executed when this method is invoked, this method will block until it is completed and then return a nonzero value.

◆ cancelEventAndWait() [3/4]

int bdlmt::EventScheduler::cancelEventAndWait ( EventHandle handle)

◆ cancelEventAndWait() [4/4]

int bdlmt::EventScheduler::cancelEventAndWait ( RecurringEventHandle handle)

Cancel the event having the specified handle and release *handle. Block until the event having handle (if it is valid) is either successfully canceled or dispatched before the call returns. Return 0 on successful cancellation, and a non-zero value if handle is invalid or if the event has already been dispatched or canceled. The behavior is undefined if this method is invoked from the dispatcher thread. Note that if the event is being executed when this method is invoked, this method will block until it is completed and then return a nonzero value. Also note that it is guaranteed that *handle will be released whether this call is successful or not.

◆ clockType()

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

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

◆ isInDispatcherThread()

bool bdlmt::EventScheduler::isInDispatcherThread ( ) const
inline

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

◆ isStarted()

bool bdlmt::EventScheduler::isStarted ( ) const

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

◆ nextPendingEventTime()

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

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()

bsls::TimeInterval bdlmt::EventScheduler::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} in the component documentation).

◆ numEvents()

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

◆ numRecurringEvents()

int bdlmt::EventScheduler::numRecurringEvents ( ) const
inline

Return the number of recurring events registered with this scheduler.

◆ releaseEventRaw() [1/2]

void bdlmt::EventScheduler::releaseEventRaw ( Event handle)
inline

◆ releaseEventRaw() [2/2]

void bdlmt::EventScheduler::releaseEventRaw ( RecurringEvent handle)
inline

Release the specified handle. Every handle reference added by scheduleEventRaw, addEventRefRaw, scheduleRecurringEventRaw, or addRecurringEventRefRaw must be released using this method to avoid leaking resources. The behavior is undefined if the value of handle is used for any purpose after being released.

◆ rescheduleEvent() [1/2]

template<class t_CLOCK , class t_DURATION >
int bdlmt::EventScheduler::rescheduleEvent ( const Event handle,
const bsl::chrono::time_point< t_CLOCK, t_DURATION > &  newEpochTime 
)

Reschedule the event referred to by the specified handle at the specified newEpochTime truncated to microseconds. Return 0 on successful reschedule, and a non-zero value if the handle is invalid or if the event has already been dispatched. The newEpochTime is an absolute time represented as an interval from some epoch, determined by the clock associated with the time point.

◆ rescheduleEvent() [2/2]

int bdlmt::EventScheduler::rescheduleEvent ( const Event handle,
const bsls::TimeInterval newEpochTime 
)

Reschedule the event referred to by the specified handle at the specified newEpochTime truncated to microseconds. Return 0 on successful reschedule, and a non-zero value if the handle is invalid or if the event has already been dispatched. The newEpochTime is 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).

◆ rescheduleEventAndWait() [1/2]

template<class t_CLOCK , class t_DURATION >
int bdlmt::EventScheduler::rescheduleEventAndWait ( const Event handle,
const bsl::chrono::time_point< t_CLOCK, t_DURATION > &  newEpochTime 
)

Reschedule the event referred to by the specified handle at the specified newEpochTime truncated to microseconds. Block until the event having 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 handle is invalid or if the event has already been dispatched. The newEpochTime is an absolute time represented as an interval from some epoch, which is determined by the clock associated with the time point. The behavior is undefined if this method is invoked from the dispatcher thread.

◆ rescheduleEventAndWait() [2/2]

int bdlmt::EventScheduler::rescheduleEventAndWait ( const Event handle,
const bsls::TimeInterval newEpochTime 
)

Reschedule the event referred to by the specified handle at the specified newEpochTime truncated to microseconds. Block until the event having 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 handle is invalid or if the event has already been dispatched. The newEpochTime is 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). The behavior is undefined if this method is invoked from the dispatcher thread.

◆ scheduleEvent() [1/4]

template<class t_CLOCK , class t_DURATION >
void bdlmt::EventScheduler::scheduleEvent ( const bsl::chrono::time_point< t_CLOCK, t_DURATION > &  epochTime,
const bsl::function< void()> &  callback 
)
inline

Schedule the specified callback to be dispatched at the specified epochTime truncated to microseconds. Load into the optionally specified event a handle that can be used to cancel the event (by invoking cancelEvent). The epochTime is an absolute time represented as an interval from some epoch, which is determined by the clock associated with the time point. This method guarantees that the event will occur at or after epochTime. epochTime may be in the past, in which case the event will be executed as soon as possible.

◆ scheduleEvent() [2/4]

void bdlmt::EventScheduler::scheduleEvent ( const bsls::TimeInterval epochTime,
const bsl::function< void()> &  callback 
)
inline

◆ scheduleEvent() [3/4]

template<class t_CLOCK , class t_DURATION >
void bdlmt::EventScheduler::scheduleEvent ( EventHandle event,
const bsl::chrono::time_point< t_CLOCK, t_DURATION > &  epochTime,
const bsl::function< void()> &  callback 
)

◆ scheduleEvent() [4/4]

void bdlmt::EventScheduler::scheduleEvent ( EventHandle event,
const bsls::TimeInterval epochTime,
const bsl::function< void()> &  callback 
)
inline

Schedule the specified callback to be dispatched at the specified epochTime truncated to microseconds. Load into the optionally specified event a handle that can be used to cancel the event (by invoking cancelEvent). The epochTime is 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). This method guarantees that the event will occur at or after epochTime. epochTime may be in the past, in which case the event will be executed as soon as possible.

◆ scheduleEventRaw() [1/2]

template<class t_CLOCK , class t_DURATION >
void bdlmt::EventScheduler::scheduleEventRaw ( Event **  event,
const bsl::chrono::time_point< t_CLOCK, t_DURATION > &  epochTime,
const bsl::function< void()> &  callback 
)

Schedule the specified callback to be dispatched at the specified epochTime truncated to microseconds. Load into the specified event pointer a handle that can be used to cancel the event (by invoking cancelEvent). The epochTime is an absolute time represented as an interval from some epoch, which is determined by the clock associated with the time point. The event pointer must be released invoking releaseEventRaw when it is no longer needed.

◆ scheduleEventRaw() [2/2]

void bdlmt::EventScheduler::scheduleEventRaw ( Event **  event,
const bsls::TimeInterval epochTime,
const bsl::function< void()> &  callback 
)

Schedule the specified callback to be dispatched at the specified epochTime truncated to microseconds. Load into the specified event pointer a handle that can be used to cancel the event (by invoking cancelEvent). The epochTime is 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). The event pointer must be released invoking releaseEventRaw when it is no longer needed.

◆ scheduleRecurringEvent() [1/4]

template<class t_CLOCK , class t_REP_TYPE , class t_PERIOD_TYPE , class t_DURATION >
void bdlmt::EventScheduler::scheduleRecurringEvent ( const bsl::chrono::duration< t_REP_TYPE, t_PERIOD_TYPE > &  interval,
const bsl::function< void()> &  callback,
const bsl::chrono::time_point< t_CLOCK, t_DURATION > &  startEpochTime = t_CLOCK::now() 
)

Schedule a recurring event that invokes the specified callback at every specified interval truncated to microseconds, with the first event dispatched at the optionally specified startEpochTime truncated to microseconds. If startEpochTime is not specified, the first event is dispatched at one interval from now. Load into the optionally specified event a handle that can be used to cancel the event (by invoking cancelEvent). The startEpochTime is an absolute time represented as an interval from some epoch, which is determined by the clock associated with the time point. The behavior is undefined unless interval is at least one microsecond. Note that if startEpochTime is in the past, the first event is dispatched immediately, and additional (now() - startEpochTime) / interval events will be submitted serially.

◆ scheduleRecurringEvent() [2/4]

void bdlmt::EventScheduler::scheduleRecurringEvent ( const bsls::TimeInterval interval,
const bsl::function< void()> &  callback,
const bsls::TimeInterval startEpochTime = bsls::TimeInterval(0) 
)
inline

◆ scheduleRecurringEvent() [3/4]

template<class t_CLOCK , class t_REP_TYPE , class t_PERIOD_TYPE , class t_DURATION >
void bdlmt::EventScheduler::scheduleRecurringEvent ( RecurringEventHandle event,
const bsl::chrono::duration< t_REP_TYPE, t_PERIOD_TYPE > &  interval,
const bsl::function< void()> &  callback,
const bsl::chrono::time_point< t_CLOCK, t_DURATION > &  startEpochTime = t_CLOCK::now() 
)

◆ scheduleRecurringEvent() [4/4]

void bdlmt::EventScheduler::scheduleRecurringEvent ( RecurringEventHandle event,
const bsls::TimeInterval interval,
const bsl::function< void()> &  callback,
const bsls::TimeInterval startEpochTime = bsls::TimeInterval(0) 
)
inline

Schedule a recurring event that invokes the specified callback at every specified interval truncated to microseconds, with the first event dispatched at the optionally specified startEpochTime truncated to microseconds. If startEpochTime is not specified, the first event is dispatched at one interval from now. Load into the optionally specified event a handle that can be used to cancel the event (by invoking cancelEvent). The startEpochTime is 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). The behavior is undefined unless interval is at least one microsecond. Note that if startEpochTime is in the past, the first event is dispatched immediately, and additional (now() - startEpochTime) / interval events will be submitted serially.

◆ scheduleRecurringEventRaw() [1/2]

template<class t_CLOCK , class t_REP_TYPE , class t_PERIOD_TYPE , class t_DURATION >
void bdlmt::EventScheduler::scheduleRecurringEventRaw ( RecurringEvent **  event,
const bsl::chrono::duration< t_REP_TYPE, t_PERIOD_TYPE > &  interval,
const bsl::function< void()> &  callback,
const bsl::chrono::time_point< t_CLOCK, t_DURATION > &  startEpochTime = t_CLOCK::now() 
)

Schedule a recurring event that invokes the specified callback at every specified interval truncated to microseconds, with the first event dispatched at the optionally specified startEpochTime truncated to microseconds. If startEpochTime is not specified, the first event is dispatched at one interval from now. Load into the specified event pointer a handle that can be used to cancel the event (by invoking cancelEvent). The startEpochTime is an absolute time represented as an interval from some epoch, which is determined by the clock associated with the time point. The event pointer must be released by invoking releaseEventRaw when it is no longer needed. The behavior is undefined unless interval is at least one microsecond. Note that if startEpochTime is in the past, the first event is dispatched immediately, and additional (now() - startEpochTime) / interval events will be submitted serially.

◆ scheduleRecurringEventRaw() [2/2]

void bdlmt::EventScheduler::scheduleRecurringEventRaw ( RecurringEvent **  event,
const bsls::TimeInterval interval,
const bsl::function< void()> &  callback,
const bsls::TimeInterval startEpochTime = bsls::TimeInterval(0) 
)

Schedule a recurring event that invokes the specified callback at every specified interval truncated to microseconds, with the first event dispatched at the optionally specified startEpochTime truncated to microseconds. If startEpochTime is not specified, the first event is dispatched at one interval from now. Load into the specified event pointer a handle that can be used to cancel the event (by invoking cancelEvent). The startEpochTime is 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). The event pointer must be released by invoking releaseEventRaw when it is no longer needed. The behavior is undefined unless interval is at least one microsecond. Note that if startEpochTime is in the past, the first event is dispatched immediately, and additional (now() - startEpochTime) / interval events will be submitted serially.

◆ start() [1/2]

int bdlmt::EventScheduler::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.EventSched". 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::EventScheduler::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.EventSched". 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.

◆ stop()

void bdlmt::EventScheduler::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

◆ EventSchedulerEventHandle

friend class EventSchedulerEventHandle
friend

◆ EventSchedulerRecurringEventHandle

◆ EventSchedulerTestTimeSource

friend class EventSchedulerTestTimeSource
friend

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