Quick Links: |
#include <bdlmt_eventscheduler.h>
Classes | |
struct | Event |
struct | EventData |
struct | RecurringEvent |
struct | RecurringEventData |
Public Types | |
typedef EventSchedulerEventHandle | EventHandle |
typedef EventSchedulerRecurringEventHandle | RecurringEventHandle |
typedef bsl::function< void(const bsl::function< void()> &)> | Dispatcher |
Public Member Functions | |
BSLMF_NESTED_TRAIT_DECLARATION (EventScheduler, bslma::UsesBslmaAllocator) | |
EventScheduler (bslma::Allocator *basicAllocator=0) | |
EventScheduler (bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0) | |
EventScheduler (const bsl::chrono::system_clock &, bslma::Allocator *basicAllocator=0) | |
EventScheduler (const bsl::chrono::steady_clock &, bslma::Allocator *basicAllocator=0) | |
EventScheduler (const Dispatcher &dispatcherFunctor, bslma::Allocator *basicAllocator=0) | |
EventScheduler (const Dispatcher &dispatcherFunctor, bsls::SystemClockType::Enum clockType, bslma::Allocator *basicAllocator=0) | |
EventScheduler (const Dispatcher &dispatcherFunctor, const bsl::chrono::system_clock &, bslma::Allocator *basicAllocator=0) | |
EventScheduler (const Dispatcher &dispatcherFunctor, const bsl::chrono::steady_clock &, 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 () |
Event * | addEventRefRaw (Event *handle) const |
RecurringEvent * | addRecurringEventRefRaw (RecurringEvent *handle) const |
bsls::SystemClockType::Enum | clockType () const |
bool | isStarted () const |
bsls::TimeInterval | now () const |
int | numEvents () const |
int | numRecurringEvents () const |
bool | isInDispatcherThread () const |
bslma::Allocator * | allocator () const |
Friends | |
class | EventSchedulerEventHandle |
class | EventSchedulerRecurringEventHandle |
class | EventSchedulerTestTimeSource |
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 Component bdlmt_eventscheduler
typedef bsl::function<void(const bsl::function<void()>&)> bdlmt::EventScheduler::Dispatcher |
Defines a type alias for the dispatcher functor type.
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.
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.
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.
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.
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.
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.
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.
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.
bdlmt::EventScheduler::~EventScheduler | ( | ) |
Discard all unprocessed events and destroy this object. The behavior is undefined unless the scheduler is stopped.
bdlmt::EventScheduler::BSLMF_NESTED_TRAIT_DECLARATION | ( | EventScheduler | , | |
bslma::UsesBslmaAllocator | ||||
) |
void bdlmt::EventScheduler::cancelAllEvents | ( | ) |
Cancel all recurring and one-time events scheduled in this EventScheduler.
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.
int bdlmt::EventScheduler::cancelEvent | ( | const Event * | handle | ) |
int bdlmt::EventScheduler::cancelEvent | ( | const RecurringEvent * | handle | ) |
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);
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.
int bdlmt::EventScheduler::cancelEvent | ( | EventHandle * | handle | ) |
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.
int bdlmt::EventScheduler::cancelEventAndWait | ( | const Event * | handle | ) |
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.
int bdlmt::EventScheduler::cancelEventAndWait | ( | EventHandle * | handle | ) |
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.
void bdlmt::EventScheduler::releaseEventRaw | ( | Event * | handle | ) |
void bdlmt::EventScheduler::releaseEventRaw | ( | RecurringEvent * | handle | ) |
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.
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).
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.
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.
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.
void bdlmt::EventScheduler::scheduleEvent | ( | const bsls::TimeInterval & | epochTime, | |
const bsl::function< void()> & | callback | |||
) |
void bdlmt::EventScheduler::scheduleEvent | ( | EventHandle * | 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 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.
void bdlmt::EventScheduler::scheduleEvent | ( | const bsl::chrono::time_point< t_CLOCK, t_DURATION > & | epochTime, | |
const bsl::function< void()> & | callback | |||
) |
void bdlmt::EventScheduler::scheduleEvent | ( | EventHandle * | 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 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.
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.
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.
void bdlmt::EventScheduler::scheduleRecurringEvent | ( | const bsls::TimeInterval & | interval, | |
const bsl::function< void()> & | callback, | |||
const bsls::TimeInterval & | startEpochTime = bsls::TimeInterval(0) | |||
) |
void bdlmt::EventScheduler::scheduleRecurringEvent | ( | RecurringEventHandle * | 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 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.
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() | |||
) |
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() | |||
) |
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.
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.
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.
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 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.
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 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.
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.
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.
RecurringEvent* bdlmt::EventScheduler::addRecurringEventRefRaw | ( | RecurringEvent * | handle | ) | const |
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.
bsls::SystemClockType::Enum bdlmt::EventScheduler::clockType | ( | ) | const |
Return the value of the clock type that this object was created with.
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.
bsls::TimeInterval bdlmt::EventScheduler::now | ( | ) | const |
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).
int bdlmt::EventScheduler::numEvents | ( | ) | const |
Return the number of pending one-time events in this scheduler.
int bdlmt::EventScheduler::numRecurringEvents | ( | ) | const |
Return the number of recurring events registered with this scheduler.
bool bdlmt::EventScheduler::isInDispatcherThread | ( | ) | const |
Return true
if the calling thread is the dispatcher thread of this scheduler, and false
otherwise.
bslma::Allocator* bdlmt::EventScheduler::allocator | ( | ) | const |
Return the allocator used by this object to supply memory.
friend class EventSchedulerEventHandle [friend] |
friend class EventSchedulerRecurringEventHandle [friend] |
friend class EventSchedulerTestTimeSource [friend] |