OpenDDS
Snapshot(2023/04/07-19:43)
|
#include <SporadicEvent.h>
Public Member Functions | |
SporadicEvent (EventDispatcher_rch dispatcher, EventBase_rch event) | |
void | schedule (const TimeDuration &duration) |
void | cancel () |
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_ |
MonotonicTimePoint | expiration_ |
long | timer_id_ |
Additional Inherited Members | |
![]() | |
RcObject () | |
SporadicEvent is an event which can be scheduled multiple times but will only dispatch once
SporadicEvent allows repeated calls to schedule (when the application is unsure if the event has already been scheduled), but cumulative calls to schedule will only result in a single dispatch. After the base event dispatches, additional calls to schedule will result in another dispatch. Additional calls to schedule may, however, shorten the scheduled time until the base event dispatches. The SporadicEvent 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 30 of file SporadicEvent.h.
OpenDDS::DCPS::SporadicEvent::SporadicEvent | ( | EventDispatcher_rch | dispatcher, |
EventBase_rch | event | ||
) |
Creates a SporadicEvent 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 17 of file SporadicEvent.cpp.
void OpenDDS::DCPS::SporadicEvent::cancel | ( | void | ) |
Cancel the SporadicEvent, canceling the scheduled base event if scheduled.
Definition at line 54 of file SporadicEvent.cpp.
References OpenDDS::DCPS::EventDispatcher::cancel(), dispatcher_, mutex_, and timer_id_.
|
virtual |
For use by EventDispatcher
Reimplemented from OpenDDS::DCPS::EventBase.
Definition at line 84 of file SporadicEvent.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 73 of file SporadicEvent.cpp.
References event_, event_mutex_, handle_event_scheduling(), and ACE_Guard< ACE_LOCK >::release().
|
private |
Definition at line 67 of file SporadicEvent.cpp.
References mutex_, and timer_id_.
Referenced by handle_event().
void OpenDDS::DCPS::SporadicEvent::schedule | ( | const TimeDuration & | duration | ) |
Schedule the SporadicEvent to dispatch the base event after the specified duration. If the SporadicEvent is already scheduled, the duration is compared with the existing scheduled time and the shorter (sooner) of the two durations is used.
duration | the time period used to schedule / reschedule the base event |
Definition at line 24 of file SporadicEvent.cpp.
References OpenDDS::DCPS::EventDispatcher::cancel(), dispatcher_, expiration_, mutex_, OpenDDS::DCPS::TimePoint_T< MonotonicClock >::now(), OpenDDS::DCPS::rchandle_from(), OpenDDS::DCPS::EventDispatcher::schedule(), and timer_id_.
|
private |
Definition at line 70 of file SporadicEvent.h.
Referenced by cancel(), and schedule().
Definition at line 71 of file SporadicEvent.h.
Referenced by handle_cancel(), and handle_event().
|
mutableprivate |
Definition at line 69 of file SporadicEvent.h.
Referenced by handle_cancel(), and handle_event().
|
private |
Definition at line 72 of file SporadicEvent.h.
Referenced by schedule().
|
mutableprivate |
Definition at line 68 of file SporadicEvent.h.
Referenced by cancel(), handle_event_scheduling(), and schedule().
|
private |
Definition at line 73 of file SporadicEvent.h.
Referenced by cancel(), handle_event_scheduling(), and schedule().