OpenDDS
Snapshot(2023/04/07-19:43)
|
#include <DispatchService.h>
Public Types | |
typedef bool | DispatchStatus |
Typedef for Dispatch Return Values. More... | |
typedef long | TimerId |
Typedef for Schedule Return Values. More... | |
typedef void(* | FunPtr) (void *) |
typedef std::pair< FunPtr, void * > | FunArgPair |
Public Member Functions | |
typedef | OPENDDS_DEQUE (FunArgPair) EventQueue |
DispatchService (size_t count=1) | |
virtual | ~DispatchService () |
void | shutdown (bool immediate=false, EventQueue *pending=0) |
DispatchStatus | dispatch (FunPtr fun, void *arg=0) |
template<typename T > | |
DispatchStatus | dispatch (T &ref) |
Helper function to dispatch arbitrary function objects (see fun_ptr_proxy) More... | |
TimerId | schedule (FunPtr fun, void *arg=0, const MonotonicTimePoint &expiration=MonotonicTimePoint::now()) |
template<typename T > | |
TimerId | schedule (T &ref, const MonotonicTimePoint &expiration=MonotonicTimePoint::now()) |
Helper function to schedule arbitrary function objects (see fun_ptr_proxy) More... | |
size_t | cancel (TimerId id, void **arg=0) |
size_t | cancel (FunPtr fun, void *arg=0) |
template<typename T > | |
size_t | cancel (T &ref) |
Helper function to cancel arbitrary function objects (see fun_ptr_proxy) More... | |
![]() | |
virtual | ~RcObject () |
virtual void | _add_ref () |
virtual void | _remove_ref () |
long | ref_count () const |
WeakObject * | _get_weak_object () const |
Static Public Member Functions | |
template<typename T > | |
static void | fun_ptr_proxy (void *arg) |
Helper function for adapting arbitrary function objects (with operator()) More... | |
Static Public Attributes | |
static const bool | DS_SUCCESS = true |
DispatchStatus Success Constant. More... | |
static const bool | DS_ERROR = false |
DispatchStatus Error Constant. More... | |
static const long | TI_FAILURE = -1 |
TimerId Failure Constant. More... | |
Private Types | |
typedef std::pair< FunArgPair, TimerId > | TimerPair |
Private Member Functions | |
void | run_event_loop () |
typedef | OPENDDS_MULTIMAP (MonotonicTimePoint, TimerPair) TimerQueueMap |
typedef | OPENDDS_MAP (TimerId, TimerQueueMap::iterator) TimerIdMap |
Static Private Member Functions | |
static ACE_THR_FUNC_RETURN | run (void *arg) |
Private Attributes | |
ACE_Thread_Mutex | mutex_ |
ConditionVariable< ACE_Thread_Mutex > | cv_ |
bool | allow_dispatch_ |
bool | stop_when_empty_ |
bool | running_ |
size_t | running_threads_ |
EventQueue | event_queue_ |
TimerQueueMap | timer_queue_map_ |
TimerIdMap | timer_id_map_ |
TimerId | max_timer_id_ |
ThreadPool | pool_ |
Additional Inherited Members | |
![]() | |
RcObject () | |
Definition at line 24 of file DispatchService.h.
typedef bool OpenDDS::DCPS::DispatchService::DispatchStatus |
Typedef for Dispatch Return Values.
Definition at line 36 of file DispatchService.h.
typedef std::pair<FunPtr, void*> OpenDDS::DCPS::DispatchService::FunArgPair |
Definition at line 51 of file DispatchService.h.
typedef void(* OpenDDS::DCPS::DispatchService::FunPtr) (void *) |
Definition at line 50 of file DispatchService.h.
typedef long OpenDDS::DCPS::DispatchService::TimerId |
Typedef for Schedule Return Values.
Definition at line 45 of file DispatchService.h.
|
private |
Definition at line 129 of file DispatchService.h.
|
explicit |
Create a DispatchService
count | the requested size of the internal thread pool |
Definition at line 22 of file DispatchService.cpp.
|
virtual |
Definition at line 33 of file DispatchService.cpp.
References shutdown().
size_t OpenDDS::DCPS::DispatchService::cancel | ( | DispatchService::TimerId | id, |
void ** | arg = 0 |
||
) |
Cancel a scheduled event by id
id | the scheduled timer id to cancel |
arg | if specified, arg will be set to the arg value passed in at time of scheduling |
Definition at line 114 of file DispatchService.cpp.
References cv_, mutex_, OpenDDS::DCPS::ConditionVariable< Mutex >::notify_all(), timer_id_map_, and timer_queue_map_.
Referenced by OpenDDS::DCPS::ServiceEventDispatcher::cancel().
size_t OpenDDS::DCPS::DispatchService::cancel | ( | FunPtr | fun, |
void * | arg = 0 |
||
) |
Cancel a scheduled event by function pointer
fun | the function pointer of the event/s to cancel |
arg | the argument passed at time of scheduling |
Definition at line 132 of file DispatchService.cpp.
References cv_, mutex_, OpenDDS::DCPS::ConditionVariable< Mutex >::notify_all(), OPENDDS_ASSERT, timer_id_map_, and timer_queue_map_.
|
inline |
Helper function to cancel arbitrary function objects (see fun_ptr_proxy)
Definition at line 119 of file DispatchService.h.
DispatchService::DispatchStatus OpenDDS::DCPS::DispatchService::dispatch | ( | FunPtr | fun, |
void * | arg = 0 |
||
) |
Dispatch an event
fun | the function pointer to dispatch |
arg | the argument to pass during dispatch |
Definition at line 74 of file DispatchService.cpp.
References allow_dispatch_, cv_, DS_ERROR, DS_SUCCESS, event_queue_, mutex_, and OpenDDS::DCPS::ConditionVariable< Mutex >::notify_one().
Referenced by OpenDDS::DCPS::ServiceEventDispatcher::dispatch().
|
inline |
Helper function to dispatch arbitrary function objects (see fun_ptr_proxy)
Definition at line 80 of file DispatchService.h.
References OpenDDS::DCPS::TimePoint_T< MonotonicClock >::now().
|
inlinestatic |
Helper function for adapting arbitrary function objects (with operator())
Definition at line 29 of file DispatchService.h.
References OpenDDS::DCPS::ref().
typedef OpenDDS::DCPS::DispatchService::OPENDDS_DEQUE | ( | FunArgPair | ) |
|
private |
|
private |
|
staticprivate |
Definition at line 152 of file DispatchService.cpp.
References run_event_loop().
|
private |
Definition at line 159 of file DispatchService.cpp.
References allow_dispatch_, cv_, event_queue_, mutex_, OpenDDS::DCPS::ConditionVariable< Mutex >::notify_all(), OpenDDS::DCPS::TimePoint_T< MonotonicClock >::now(), OPENDDS_END_VERSIONED_NAMESPACE_DECL, running_, running_threads_, stop_when_empty_, TheServiceParticipant, timer_id_map_, timer_queue_map_, OpenDDS::DCPS::ConditionVariable< Mutex >::wait(), and OpenDDS::DCPS::ConditionVariable< Mutex >::wait_until().
Referenced by run().
DispatchService::TimerId OpenDDS::DCPS::DispatchService::schedule | ( | FunPtr | fun, |
void * | arg = 0 , |
||
const MonotonicTimePoint & | expiration = MonotonicTimePoint::now() |
||
) |
Schedule the future dispatch of an event
fun | the function pointer to schedule |
arg | the argument to pass during dispatch |
expiration | the requested dispatch time (no earlier than) |
Definition at line 89 of file DispatchService.cpp.
References allow_dispatch_, cv_, max_timer_id_, mutex_, OpenDDS::DCPS::ConditionVariable< Mutex >::notify_one(), TI_FAILURE, timer_id_map_, and timer_queue_map_.
Referenced by OpenDDS::DCPS::ServiceEventDispatcher::schedule().
|
inline |
Helper function to schedule arbitrary function objects (see fun_ptr_proxy)
Definition at line 96 of file DispatchService.h.
void OpenDDS::DCPS::DispatchService::shutdown | ( | bool | immediate = false , |
EventQueue * | pending = 0 |
||
) |
Request shutdown of this DispatchService, which prevents sucessful future calls to either dispatch or schedule and cancels all scheduled events.
immediate | prevent any further dispatches from event queue, otherwise allow current queue to empty |
pending | An EventQueue object in which to store canceled events in case extra processing is required |
Definition at line 38 of file DispatchService.cpp.
References ACE_ERROR, allow_dispatch_, OpenDDS::DCPS::ThreadPool::contains(), cv_, OpenDDS::DCPS::LogLevel::Error, event_queue_, LM_ERROR, OpenDDS::DCPS::log_level, mutex_, OpenDDS::DCPS::ConditionVariable< Mutex >::notify_all(), pool_, running_, running_threads_, ACE_Thread::self(), stop_when_empty_, TheServiceParticipant, timer_id_map_, timer_queue_map_, and OpenDDS::DCPS::ConditionVariable< Mutex >::wait().
Referenced by OpenDDS::DCPS::ServiceEventDispatcher::shutdown(), and ~DispatchService().
|
private |
Definition at line 135 of file DispatchService.h.
Referenced by dispatch(), run_event_loop(), schedule(), and shutdown().
|
mutableprivate |
Definition at line 134 of file DispatchService.h.
Referenced by cancel(), dispatch(), run_event_loop(), schedule(), and shutdown().
|
static |
DispatchStatus Error Constant.
Definition at line 42 of file DispatchService.h.
Referenced by dispatch().
|
static |
DispatchStatus Success Constant.
Definition at line 39 of file DispatchService.h.
Referenced by dispatch().
|
private |
Definition at line 139 of file DispatchService.h.
Referenced by dispatch(), run_event_loop(), and shutdown().
|
private |
Definition at line 142 of file DispatchService.h.
Referenced by schedule().
|
mutableprivate |
Definition at line 133 of file DispatchService.h.
Referenced by cancel(), dispatch(), run_event_loop(), schedule(), and shutdown().
|
private |
Definition at line 143 of file DispatchService.h.
Referenced by shutdown().
|
private |
Definition at line 137 of file DispatchService.h.
Referenced by run_event_loop(), and shutdown().
|
private |
Definition at line 138 of file DispatchService.h.
Referenced by run_event_loop(), and shutdown().
|
private |
Definition at line 136 of file DispatchService.h.
Referenced by run_event_loop(), and shutdown().
|
static |
TimerId Failure Constant.
Definition at line 48 of file DispatchService.h.
Referenced by schedule().
|
private |
Definition at line 141 of file DispatchService.h.
Referenced by cancel(), run_event_loop(), schedule(), and shutdown().
|
private |
Definition at line 140 of file DispatchService.h.
Referenced by cancel(), run_event_loop(), schedule(), and shutdown().