OpenDDS
Snapshot(2023/04/07-19:43)
|
#include <PeriodicEvent.h>
Public Member Functions | |
PeriodicEvent (EventDispatcher_rch dispatcher, EventBase_rch event) | |
void | enable (const TimeDuration &period, bool immediate_dispatch=true, bool strict_timing=true) |
void | disable () |
bool | enabled () const |
void | handle_event () |
void | handle_cancel () |
![]() | |
virtual | ~EventBase () |
virtual void | handle_error () |
Only called when an exception is caught during handle_event. More... | |
void | operator() () |
![]() | |
virtual | ~RcObject () |
virtual void | _add_ref () |
virtual void | _remove_ref () |
long | ref_count () const |
WeakObject * | _get_weak_object () const |
Private Member Functions | |
void | handle_event_scheduling () |
Private Attributes | |
ACE_Thread_Mutex | mutex_ |
ACE_Thread_Mutex | event_mutex_ |
WeakRcHandle< EventDispatcher > | dispatcher_ |
RcHandle< EventBase > | event_ |
TimeDuration | period_ |
bool | strict_timing_ |
MonotonicTimePoint | expiration_ |
long | timer_id_ |
Additional Inherited Members | |
![]() | |
RcObject () | |
PeriodicEvent is an event that is dispatched with a regular, repeating period
PeriodicEvent serves as a helpful utility class for repeatedly dispatching another base event at a regular, fixed interval. The PeriodicEvent takes both an EventDispatcher and a base event (c.f. EventBase) and handles the logic of scheduling, rescheduling, and canceling the base event with the EventDispatcher.
Definition at line 27 of file PeriodicEvent.h.
OpenDDS::DCPS::PeriodicEvent::PeriodicEvent | ( | EventDispatcher_rch | dispatcher, |
EventBase_rch | event | ||
) |
Creates a PeriodicEvent to handle scheduling a base event with an EventDispatcher
dispatcher | the EventDispatcher to use for scheduling |
event | the base event (c.f EventBase) to schedule for dispatch |
Definition at line 18 of file PeriodicEvent.cpp.
void OpenDDS::DCPS::PeriodicEvent::disable | ( | ) |
Disable the PeriodicEvent, canceling the scheduled base event if enabled.
Definition at line 50 of file PeriodicEvent.cpp.
References OpenDDS::DCPS::EventDispatcher::cancel(), dispatcher_, mutex_, and timer_id_.
void OpenDDS::DCPS::PeriodicEvent::enable | ( | const TimeDuration & | period, |
bool | immediate_dispatch = true , |
||
bool | strict_timing = true |
||
) |
Enable the PeriodicEvent to begin scheduling / rescheduling the base event using the internal EventDispatcher and the provided time period. If strict scheduling is requested, the elapsed time since the previous dispatch will not impact the time point provided for the next scheduled dispatch. Note: strict timing may potentially lead to CPU starvation if the dispatch takes longer than the requested period.
period | the time period used to schedule / reschedule the base event |
immediate_dispatch | set to true to immediately dispatch base event |
strict_timing | set to true to strictly calculate scheduled dispatch times |
Definition at line 26 of file PeriodicEvent.cpp.
References ACE_ERROR, OpenDDS::DCPS::EventDispatcher::dispatch(), dispatcher_, expiration_, LM_WARNING, OpenDDS::DCPS::log_level, mutex_, OpenDDS::DCPS::TimePoint_T< MonotonicClock >::now(), period_, OpenDDS::DCPS::rchandle_from(), OpenDDS::DCPS::EventDispatcher::schedule(), strict_timing_, timer_id_, and OpenDDS::DCPS::LogLevel::Warning.
bool OpenDDS::DCPS::PeriodicEvent::enabled | ( | ) | const |
Check to see if the PeriodicEvent is currently enabled
Definition at line 63 of file PeriodicEvent.cpp.
References mutex_, and timer_id_.
|
virtual |
For use by EventDispatcher
Reimplemented from OpenDDS::DCPS::EventBase.
Definition at line 95 of file PeriodicEvent.cpp.
References event_, event_mutex_, OPENDDS_END_VERSIONED_NAMESPACE_DECL, and ACE_Guard< ACE_LOCK >::release().
|
virtual |
For use by EventDispatcher
Implements OpenDDS::DCPS::EventBase.
Definition at line 84 of file PeriodicEvent.cpp.
References event_, event_mutex_, handle_event_scheduling(), and ACE_Guard< ACE_LOCK >::release().
|
private |
Definition at line 69 of file PeriodicEvent.cpp.
References dispatcher_, expiration_, mutex_, OpenDDS::DCPS::TimePoint_T< MonotonicClock >::now(), period_, OpenDDS::DCPS::rchandle_from(), OpenDDS::DCPS::EventDispatcher::schedule(), strict_timing_, and timer_id_.
Referenced by handle_event().
|
private |
Definition at line 77 of file PeriodicEvent.h.
Referenced by disable(), enable(), and handle_event_scheduling().
Definition at line 78 of file PeriodicEvent.h.
Referenced by handle_cancel(), and handle_event().
|
mutableprivate |
Definition at line 76 of file PeriodicEvent.h.
Referenced by handle_cancel(), and handle_event().
|
private |
Definition at line 81 of file PeriodicEvent.h.
Referenced by enable(), and handle_event_scheduling().
|
mutableprivate |
Definition at line 75 of file PeriodicEvent.h.
Referenced by disable(), enable(), enabled(), and handle_event_scheduling().
|
private |
Definition at line 79 of file PeriodicEvent.h.
Referenced by enable(), and handle_event_scheduling().
|
private |
Definition at line 80 of file PeriodicEvent.h.
Referenced by enable(), and handle_event_scheduling().
|
private |
Definition at line 82 of file PeriodicEvent.h.
Referenced by disable(), enable(), enabled(), and handle_event_scheduling().