NAME
ACE_ReactorEx -
An object oriented event demultiplexor and event handler
ReactorEx for Win32 WaitForMultipleObjects
SYNOPSIS
#include <ace/ReactorEx.h>
class ACE_ReactorEx
{
public:
enum { MAX_SIZE = MAXIMUM_WAIT_OBJECTS, };
ACE_ReactorEx (void);
virtual ~ACE_ReactorEx (void);
virtual int handle_events (
ACE_Time_Value *how_long = 0,
int wait_all = 0
);
virtual int handle_events (
ACE_Time_Value &how_long,
int wait_all = 0
);
virtual int register_handler (
ACE_Event_Handler *eh,
ACE_HANDLE handle = ACE_INVALID_HANDLE
);
virtual int remove_handler (
ACE_Event_Handler *eh,
ACE_Reactor_Mask mask = 0
);
virtual int notify (void);
virtual int schedule_timer (
ACE_Event_Handler *eh,
const void *arg,
const ACE_Time_Value &delta,
const ACE_Time_Value &interval = ACE_Time_Value::zero
);
virtual int cancel_timer (ACE_Event_Handler *event_handler);
virtual int cancel_timer (int timer_id, const void **arg = 0);
void dump (void) const;
ACE_ALLOC_HOOK_DECLARE;
inline virtual int handle_events (void);
inline virtual int handle_events (ACE_Time_Value &);
inline virtual int notify (void);
protected:
int handle_notification (void);
ACE_Timer_Queue timer_queue_;
ACE_Time_Value timer_skew_;
ACE_HANDLE handles_[MAX_SIZE];
ACE_Event_Handler *handlers_[MAX_SIZE];
size_t active_handles_;
ACE_ReactorEx_Token token_;
private:
ACE_ReactorEx (const ACE_ReactorEx &);
ACE_ReactorEx &operator = (const ACE_ReactorEx &);
ACE_ReactorEx_Notify notify_handler_;
};
DESCRIPTION
Initialization and termination methods.
ACE_ReactorEx (void);
Initialize the new ACE_ReactorEx with the default size.
virtual ~ACE_ReactorEx (void);
Close down the ReactorEx and release all of its resources.
Event loop drivers.
Main event loop driver that blocks for -how_long- before
returning (will return earlier if I/O or signal events occur).
Note that -how_long- can be 0, in which case this method blocks
until I/O events or signals occur. Returns 0 if timed out, 1 if
an event occurred, and -1 if an error occured.
virtual int handle_events (
ACE_Time_Value *how_long = 0,
int wait_all = 0
);
virtual int handle_events (
ACE_Time_Value &how_long,
int wait_all = 0
);
Register and remove Handlers.
virtual int register_handler (
ACE_Event_Handler *eh,
ACE_HANDLE handle = ACE_INVALID_HANDLE
);
Register an Event_Handler -eh-. If handle == ACE_INVALID_HANDLE
the ReactorEx will call eh-get_handle() to extract the
underlying I/O handle).
virtual int remove_handler (
ACE_Event_Handler *eh,
ACE_Reactor_Mask mask = 0
);
Removes -eh- from the ReactorEx. Note that the ReactorEx will
call eh-get_handle() to extract the underlying I/O handle. If
-mask- == ACE_Event_Handler::DONT_CALL then the -handle_close-
method of the -eh- is not invoked.
virtual int notify (void);
Wakeup ACE_ReactorEx if currently blocked
WaitForMultipleObjects.
Timer management.
virtual int schedule_timer (
ACE_Event_Handler *eh,
const void *arg,
const ACE_Time_Value &delta,
const ACE_Time_Value &interval = ACE_Time_Value::zero
);
Schedule an Event Handler -eh- that will expire after -delta-
amount of time. If it expires then -arg- is passed in as the
value to eh-handle_timeout. If -interval- is != to
ACE_Time_Value::zero then it is used to reschedule -eh-
automatically. This method returns a timer handle that uniquely
identifies the -eh- in an internal list. This timer handle can
be used to cancel an Event_Handler before it expires. The
cancellation ensures that timer_ids are unique up to values of
greater than 2 billion timers. As long as timers don't stay
around longer than this there should be no problems with
accidentally deleting the wrong timer.
virtual int cancel_timer (ACE_Event_Handler *event_handler);
Cancel all Event_Handlers that match the address of
-event_handler-.
virtual int cancel_timer (int timer_id, const void **arg = 0);
Cancel the single Event_Handler that matches the -timer_id- value
(which was returned from the schedule method). If arg is
non-NULL then it will be set to point to the ``magic cookie''
argument passed in when the Event_Handler was registered. This
makes it possible to free up the memory and avoid memory leaks.
void dump (void) const;
Dump the state of an object.
ACE_ALLOC_HOOK_DECLARE;
Declare the dynamic allocation hooks.
AUTHOR
Tim Harrison and Doug Schmidt
LIBRARY
ace