Provides an abstract interface for handling various types of I/O, timer, and signal events. More...
#include <Event_Handler.h>
Classes | |
class | Policy |
Base class for all handler policies. More... | |
class | Reference_Counting_Policy |
This policy dictates the reference counting requirements for the handler. More... | |
Public Types | |
enum | { LO_PRIORITY = 0, HI_PRIORITY = 10, NULL_MASK = 0, READ_MASK = (1 << 0), WRITE_MASK = (1 << 1), EXCEPT_MASK = (1 << 2), ACCEPT_MASK = (1 << 3), CONNECT_MASK = (1 << 4), TIMER_MASK = (1 << 5), QOS_MASK = (1 << 6), GROUP_QOS_MASK = (1 << 7), SIGNAL_MASK = (1 << 8), ALL_EVENTS_MASK, RWE_MASK, DONT_CALL = (1 << 9) } |
enum | { ACE_EVENT_HANDLER_NOT_RESUMED = -1, ACE_REACTOR_RESUMES_HANDLER = 0, ACE_APPLICATION_RESUMES_HANDLER } |
typedef long | Reference_Count |
Reference count type. | |
Public Member Functions | |
virtual | ~ACE_Event_Handler (void) |
Destructor is virtual to enable proper cleanup. | |
virtual ACE_HANDLE | get_handle (void) const |
Get the I/O handle. | |
virtual void | set_handle (ACE_HANDLE) |
Set the I/O handle. | |
virtual int | priority (void) const |
virtual void | priority (int priority) |
Set the priority of the Event_Handler. | |
virtual int | handle_input (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
Called when input events occur (e.g., connection or data). | |
virtual int | handle_output (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
virtual int | handle_exception (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
Called when an exceptional events occur (e.g., SIGURG). | |
virtual int | handle_timeout (const ACE_Time_Value ¤t_time, const void *act=0) |
virtual int | handle_exit (ACE_Process *) |
Called when a process exits. | |
virtual int | handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask) |
virtual int | handle_signal (int signum, siginfo_t *=0, ucontext_t *=0) |
virtual int | resume_handler (void) |
virtual int | handle_qos (ACE_HANDLE=ACE_INVALID_HANDLE) |
virtual int | handle_group_qos (ACE_HANDLE=ACE_INVALID_HANDLE) |
virtual void | reactor (ACE_Reactor *reactor) |
Set the event demultiplexors. | |
virtual ACE_Reactor * | reactor (void) const |
Get the event demultiplexors. | |
virtual ACE_Reactor_Timer_Interface * | reactor_timer_interface (void) const |
Get only the reactor's timer related interface. | |
virtual Reference_Count | add_reference (void) |
Increment reference count on the handler. | |
virtual Reference_Count | remove_reference (void) |
Decrement reference count on the handler. | |
Reference_Counting_Policy & | reference_counting_policy (void) |
Current Reference_Counting_Policy. | |
Static Public Member Functions | |
static ACE_THR_FUNC_RETURN | read_adapter (void *event_handler) |
static int | register_stdin_handler (ACE_Event_Handler *eh, ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr, int flags=THR_DETACHED) |
static int | remove_stdin_handler (ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr) |
Performs the inverse of the register_stdin_handler() method. | |
Protected Types | |
typedef ACE_Atomic_Op < ACE_SYNCH_MUTEX, Reference_Count > | Atomic_Reference_Count |
Typedef for implementation of reference counting. | |
Protected Member Functions | |
ACE_Event_Handler (ACE_Reactor *=0, int priority=ACE_Event_Handler::LO_PRIORITY) | |
Force ACE_Event_Handler to be an abstract base class. | |
Protected Attributes | |
Atomic_Reference_Count | reference_count_ |
Reference count. | |
Private Attributes | |
int | priority_ |
Priority of this Event_Handler. | |
ACE_Reactor * | reactor_ |
Pointer to the various event demultiplexors. | |
Reference_Counting_Policy | reference_counting_policy_ |
Reference counting requirements. |
Provides an abstract interface for handling various types of I/O, timer, and signal events.
Subclasses read/write input/output on an I/O descriptor, handle an exception raised on an I/O descriptor, handle a timer's expiration, or handle a signal.
Definition at line 49 of file Event_Handler.h.
typedef ACE_Atomic_Op<ACE_SYNCH_MUTEX, Reference_Count> ACE_Event_Handler::Atomic_Reference_Count [protected] |
Typedef for implementation of reference counting.
Definition at line 291 of file Event_Handler.h.
typedef long ACE_Event_Handler::Reference_Count |
Reference count type.
Definition at line 202 of file Event_Handler.h.
anonymous enum |
LO_PRIORITY | |
HI_PRIORITY | |
NULL_MASK | |
READ_MASK | |
WRITE_MASK | |
EXCEPT_MASK | |
ACCEPT_MASK | |
CONNECT_MASK | |
TIMER_MASK | |
QOS_MASK | |
GROUP_QOS_MASK | |
SIGNAL_MASK | |
ALL_EVENTS_MASK | |
RWE_MASK | |
DONT_CALL |
Definition at line 52 of file Event_Handler.h.
{ LO_PRIORITY = 0, HI_PRIORITY = 10, NULL_MASK = 0, #if defined (ACE_USE_POLL) READ_MASK = POLLIN, WRITE_MASK = POLLOUT, EXCEPT_MASK = POLLPRI, #else /* USE SELECT */ READ_MASK = (1 << 0), WRITE_MASK = (1 << 1), EXCEPT_MASK = (1 << 2), #endif /* ACE_USE_POLL */ ACCEPT_MASK = (1 << 3), CONNECT_MASK = (1 << 4), TIMER_MASK = (1 << 5), QOS_MASK = (1 << 6), GROUP_QOS_MASK = (1 << 7), SIGNAL_MASK = (1 << 8), ALL_EVENTS_MASK = READ_MASK | WRITE_MASK | EXCEPT_MASK | ACCEPT_MASK | CONNECT_MASK | TIMER_MASK | QOS_MASK | GROUP_QOS_MASK | SIGNAL_MASK, RWE_MASK = READ_MASK | WRITE_MASK | EXCEPT_MASK, DONT_CALL = (1 << 9) };
anonymous enum |
Definition at line 139 of file Event_Handler.h.
{ /// The handler is not resumed at all. Could lead to deadlock.. ACE_EVENT_HANDLER_NOT_RESUMED = -1, /// The reactor takes responsibility of resuming the handler and /// is the default ACE_REACTOR_RESUMES_HANDLER = 0, /// The application takes responsibility of resuming the handler ACE_APPLICATION_RESUMES_HANDLER };
ACE_Event_Handler::~ACE_Event_Handler | ( | void | ) | [virtual] |
Destructor is virtual to enable proper cleanup.
Definition at line 34 of file Event_Handler.cpp.
{
// ACE_TRACE ("ACE_Event_Handler::~ACE_Event_Handler");
}
ACE_Event_Handler::ACE_Event_Handler | ( | ACE_Reactor * | r = 0 , |
|
int | priority = ACE_Event_Handler::LO_PRIORITY | |||
) | [protected] |
Force ACE_Event_Handler to be an abstract base class.
Definition at line 24 of file Event_Handler.cpp.
: reference_count_ (1), priority_ (p), reactor_ (r), reference_counting_policy_ (Reference_Counting_Policy::DISABLED) { // ACE_TRACE ("ACE_Event_Handler::ACE_Event_Handler"); }
ACE_Event_Handler::Reference_Count ACE_Event_Handler::add_reference | ( | void | ) | [virtual] |
Increment reference count on the handler.
This method is called when the handler is registered with the Reactor and when the Reactor makes an upcall on the handler. Reference count is 1 when the handler is created.
Definition at line 185 of file Event_Handler.cpp.
{ bool const reference_counting_required = this->reference_counting_policy ().value () == ACE_Event_Handler::Reference_Counting_Policy::ENABLED; if (reference_counting_required) return ++this->reference_count_; else return 1; }
ACE_HANDLE ACE_Event_Handler::get_handle | ( | void | ) | const [virtual] |
Get the I/O handle.
Reimplemented in ACE_Name_Proxy, ACE_QoS_Decorator_Base, ACE_QoS_Event_Handler, and ACE_QoS_Decorator.
Definition at line 42 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::get_handle"); return ACE_INVALID_HANDLE; }
int ACE_Event_Handler::handle_close | ( | ACE_HANDLE | handle, | |
ACE_Reactor_Mask | close_mask | |||
) | [virtual] |
Called when a <handle_*()> method returns -1 or when the <remove_handler> method is called on an ACE_Reactor. The close_mask indicates which event has triggered the <handle_close> method callback on a particular handle.
Definition at line 78 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::handle_close"); return -1; }
int ACE_Event_Handler::handle_exception | ( | ACE_HANDLE | fd = ACE_INVALID_HANDLE |
) | [virtual] |
Called when an exceptional events occur (e.g., SIGURG).
Reimplemented in ACE_NonBlocking_Connect_Handler< SVC_HANDLER >.
Definition at line 105 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::handle_exception"); return -1; }
int ACE_Event_Handler::handle_exit | ( | ACE_Process * | ) | [virtual] |
Called when a process exits.
Definition at line 123 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::handle_exit"); return -1; }
int ACE_Event_Handler::handle_group_qos | ( | ACE_HANDLE | = ACE_INVALID_HANDLE |
) | [virtual] |
Definition at line 157 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::handle_group_qos"); return -1; }
int ACE_Event_Handler::handle_input | ( | ACE_HANDLE | fd = ACE_INVALID_HANDLE |
) | [virtual] |
Called when input events occur (e.g., connection or data).
Reimplemented in ACE_NonBlocking_Connect_Handler< SVC_HANDLER >, ACE_Process_Manager, ACE_QoS_Decorator_Base, ACE_QoS_Event_Handler, ACE_QoS_Decorator, and ACE_Select_Reactor_Notify.
Definition at line 87 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::handle_input"); return -1; }
int ACE_Event_Handler::handle_output | ( | ACE_HANDLE | fd = ACE_INVALID_HANDLE |
) | [virtual] |
Called when output events are possible (e.g., when flow control abates or non-blocking connection completes).
Reimplemented in ACE_NonBlocking_Connect_Handler< SVC_HANDLER >.
Definition at line 96 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::handle_output"); return -1; }
int ACE_Event_Handler::handle_qos | ( | ACE_HANDLE | = ACE_INVALID_HANDLE |
) | [virtual] |
Reimplemented in ACE_QoS_Decorator_Base, and ACE_QoS_Decorator.
Definition at line 150 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::handle_qos"); return -1; }
int ACE_Event_Handler::handle_signal | ( | int | signum, | |
siginfo_t * | = 0 , |
|||
ucontext_t * | = 0 | |||
) | [virtual] |
Called when object is signaled by OS (either via UNIX signals or when a Win32 object becomes signaled).
Reimplemented in ACE_MMAP_Memory_Pool, ACE_Process_Manager, ACE_Shared_Memory_Pool, ACE_Sig_Adapter, ACE_Test_and_Set< ACE_LOCK, TYPE >, and ACE_Async_Timer_Queue_Adapter< TQ, TYPE >.
Definition at line 132 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::handle_signal"); return -1; }
int ACE_Event_Handler::handle_timeout | ( | const ACE_Time_Value & | current_time, | |
const void * | act = 0 | |||
) | [virtual] |
Called when timer expires. current_time represents the current time that the Event_Handler was selected for timeout dispatching and act is the asynchronous completion token that was passed in when <schedule_timer> was invoked.
Reimplemented in ACE_NonBlocking_Connect_Handler< SVC_HANDLER >.
Definition at line 114 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::handle_timeout"); return -1; }
void ACE_Event_Handler::priority | ( | int | priority | ) | [virtual] |
Set the priority of the Event_Handler.
Definition at line 68 of file Event_Handler.cpp.
int ACE_Event_Handler::priority | ( | void | ) | const [virtual] |
Get the priority of the Event_Handler.
Definition at line 59 of file Event_Handler.cpp.
ACE_Reactor * ACE_Event_Handler::reactor | ( | void | ) | const [virtual] |
Get the event demultiplexors.
Definition at line 171 of file Event_Handler.cpp.
void ACE_Event_Handler::reactor | ( | ACE_Reactor * | reactor | ) | [virtual] |
Set the event demultiplexors.
Definition at line 164 of file Event_Handler.cpp.
ACE_Reactor_Timer_Interface * ACE_Event_Handler::reactor_timer_interface | ( | void | ) | const [virtual] |
Get only the reactor's timer related interface.
Definition at line 178 of file Event_Handler.cpp.
ACE_THR_FUNC_RETURN ACE_Event_Handler::read_adapter | ( | void * | event_handler | ) | [static] |
Used to read from non-socket ACE_HANDLEs in our own thread to work around Win32 limitations that don't allow us to <select> on non-sockets (such as ACE_STDIN). This is commonly used in situations where the Reactor is used to demultiplex read events on ACE_STDIN on UNIX. Note that event_handler must be a subclass of ACE_Event_Handler. If the get_handle() method of this event handler returns ACE_INVALID_HANDLE we default to reading from ACE_STDIN.
Definition at line 248 of file Event_Handler.cpp.
{ ACE_Event_Handler *this_ptr = static_cast<ACE_Event_Handler *> (args); ACE_Reactor *r = this_ptr->reactor (); while (this_ptr->handle_input (ACE_STDIN) != -1) continue; this_ptr->handle_close (ACE_STDIN, ACE_Event_Handler::READ_MASK); // It's possible for handle_close() to "delete this" so we need to // cache the reactor pointer and use it here. r->notify (); return 0; }
ACE_Event_Handler::Reference_Counting_Policy & ACE_Event_Handler::reference_counting_policy | ( | void | ) |
Current Reference_Counting_Policy.
Definition at line 242 of file Event_Handler.cpp.
{ return this->reference_counting_policy_; }
int ACE_Event_Handler::register_stdin_handler | ( | ACE_Event_Handler * | eh, | |
ACE_Reactor * | reactor, | |||
ACE_Thread_Manager * | thr_mgr, | |||
int | flags = THR_DETACHED | |||
) | [static] |
Abstracts away from the differences between Win32 and ACE with respect to reading from ACE_STDIN, which is non-<select>'able on Win32.
Definition at line 265 of file Event_Handler.cpp.
{ #if defined (ACE_WIN32) ACE_UNUSED_ARG (reactor); eh->reactor (reactor); return thr_mgr->spawn (&read_adapter, static_cast<void *> (eh), flags); #else // Keep compilers happy. ACE_UNUSED_ARG (flags); ACE_UNUSED_ARG (thr_mgr); return reactor->register_handler (ACE_STDIN, eh, ACE_Event_Handler::READ_MASK); #endif /* ACE_WIN32 */ }
ACE_Event_Handler::Reference_Count ACE_Event_Handler::remove_reference | ( | void | ) | [virtual] |
Decrement reference count on the handler.
This method is called when the handler is removed from the Reactor and when an upcall made on the handler by the Reactor completes. Handler is deleted when the reference count reaches 0.
Definition at line 198 of file Event_Handler.cpp.
{ bool const reference_counting_required = this->reference_counting_policy ().value () == ACE_Event_Handler::Reference_Counting_Policy::ENABLED; if (reference_counting_required) { Reference_Count result = --this->reference_count_; if (result == 0) delete this; return result; } else { return 1; } }
int ACE_Event_Handler::remove_stdin_handler | ( | ACE_Reactor * | reactor, | |
ACE_Thread_Manager * | thr_mgr | |||
) | [static] |
Performs the inverse of the register_stdin_handler() method.
Definition at line 286 of file Event_Handler.cpp.
{ #if defined (ACE_WIN32) ACE_UNUSED_ARG (reactor); // What should we do here? ACE_NOTSUP_RETURN (-1); #else return reactor->remove_handler (ACE_STDIN, ACE_Event_Handler::READ_MASK); #endif /* ACE_WIN32 */ }
int ACE_Event_Handler::resume_handler | ( | void | ) | [virtual] |
Called to figure out whether the handler needs to resumed by the reactor or the application can take care of it. The default value of 0 would be returned which would allow the reactor to take care of resumption of the handler. The application can return a value more than zero and decide to resume the handler themseleves.
Reimplemented in ACE_NonBlocking_Connect_Handler< SVC_HANDLER >.
Definition at line 139 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::resume_handler"); // Return a default value and allow the reactor to take care of // resuming the handler return ACE_Event_Handler::ACE_REACTOR_RESUMES_HANDLER; }
void ACE_Event_Handler::set_handle | ( | ACE_HANDLE | ) | [virtual] |
Set the I/O handle.
Definition at line 51 of file Event_Handler.cpp.
{ ACE_TRACE ("ACE_Event_Handler::set_handle"); }
int ACE_Event_Handler::priority_ [private] |
Priority of this Event_Handler.
Definition at line 299 of file Event_Handler.h.
ACE_Reactor* ACE_Event_Handler::reactor_ [private] |
Pointer to the various event demultiplexors.
Reimplemented in ACE_Name_Proxy, and ACE_QoS_Decorator.
Definition at line 302 of file Event_Handler.h.
Reference count.
Definition at line 294 of file Event_Handler.h.
Reference counting requirements.
Definition at line 305 of file Event_Handler.h.