ACE_ReactorEx from its event loop, passing it an
optional ACE_Event_Handler to dispatch.
#include <ace/ReactorEx.h>
class ACE_ReactorEx_Notify : public ACE_Event_Handler {
public:ACE_ReactorEx_Notify (void);int open (ACE_ReactorEx &reactorEx, ACE_Timer_Queue *timer_queue);int notify ( ACE_Event_Handler *eh = 0, ACE_Reactor_Mask mask = ACE_Event_Handler::EXCEPT_MASK, ACE_Time_Value *timeout = 0 );virtual ACE_HANDLE get_handle (void) const;void max_notify_iterations (int);int max_notify_iterations (void);private:ACE_Timer_Queue *timer_queue_;virtual int handle_signal ( int signum, siginfo_t * = 0, ucontext_t * = 0 );ACE_Auto_Event wakeup_one_thread_;ACE_Message_Queue<ACE_MT_SYNCH> message_queue_;int max_notify_iterations_;};
ACE_ReactorEx is run in a multi-threaded program. In this
case, we need to be able to unblock WaitForMultipleObjects()
when updates occur other than in the main ACE_ReactorEx
thread. To do this, we signal an auto-reset event the
ACE_ReactorEx is listening on. If an ACE_Event_Handler
and ACE_Reactor_Mask is passed to notify, the appropriate
handle_* method is dispatched.
ACE_ReactorEx_Notify (void);
int open (ACE_ReactorEx &reactorEx, ACE_Timer_Queue *timer_queue);
timer_queue is stored to call gettimeofday.
int notify (
ACE_Event_Handler *eh = 0,
ACE_Reactor_Mask mask = ACE_Event_Handler::EXCEPT_MASK,
ACE_Time_Value *timeout = 0
);
eh and mask onto the
ACE_Message_Queue and wakeup the ReactorEx by signaling its
ACE_Event handle. The ACE_Time_Value indicates how long to
blocking trying to notify the Reactor. If timeout == 0, the
caller will block until action is possible, else will wait until
the relative time specified in timeout elapses).
virtual ACE_HANDLE get_handle (void) const;
ACE_Auto_Event.
void max_notify_iterations (int);
ACE_ReactorEx_Notify::handle_input method will iterate and
dispatch the ACE_Event_Handlers that are passed in via the
notify queue before breaking out of its
ACE_Message_Queue::dequeue loop. By default, this is set to
-1, which means "iterate until the queue is empty." Setting this
to a value like "1 or 2" will increase "fairness" (and thus
prevent starvation) at the expense of slightly higher dispatching
overhead.
int max_notify_iterations (void);
ACE_ReactorEx_Notify::handle_input method will iterate and
dispatch the ACE_Event_Handlers that are passed in via the
notify queue before breaking out of its
ACE_Message_Queue::dequeue loop.
ACE_Timer_Queue *timer_queue_;
virtual int handle_signal (
int signum,
siginfo_t * = 0,
ucontext_t * = 0
);
ACE_ReactorEx
is signaled. This dequeues all pending ACE_Event_Handlers and
dispatches them.
ACE_Auto_Event wakeup_one_thread_;
signal it to wakeup one
thread up (e.g., when the notify method is called).
ACE_Message_Queue<ACE_MT_SYNCH> message_queue_;
int max_notify_iterations_;
ACE_ReactorEx_Notify::handle_input method will iterate and
dispatch the ACE_Event_Handlers that are passed in via the
notify queue before breaking out of its
ACE_Message_Queue::dequeue loop. By default, this is set to
-1, which means "iterate until the queue is empty."