#include <Event_Handler.h>
Inheritance diagram for ACE_Event_Handler:


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 } |
Public Methods | |
| virtual | ~ACE_Event_Handler (void) |
| Destructor is virtual to enable proper cleanup. More... | |
| virtual ACE_HANDLE | get_handle (void) const |
| Get the I/O handle. More... | |
| virtual void | set_handle (ACE_HANDLE) |
| Set the I/O handle. More... | |
| virtual int | priority (void) const |
| Get the priority of the Event_Handler. More... | |
| virtual void | priority (int priority) |
| Set the priority of the Event_Handler. More... | |
| virtual int | handle_input (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
| Called when input events occur (e.g., connection or data). More... | |
| virtual int | handle_output (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
| Called when output events are possible (e.g., when flow control abates or non-blocking connection completes). More... | |
| virtual int | handle_exception (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
| Called when an exceptional events occur (e.g., SIGURG). More... | |
| 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. More... | |
| virtual int | handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask) |
| 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>. More... | |
| virtual int | handle_signal (int signum, siginfo_t *=0, ucontext_t *=0) |
| Called when object is signaled by OS (either via UNIX signals or when a Win32 object becomes signaled). More... | |
| 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. More... | |
| virtual ACE_Reactor * | reactor (void) const |
| Get the event demultiplexors. More... | |
Static Public Methods | |
| ACE_THR_FUNC_RETURN | read_adapter (void *event_handler) |
| int | register_stdin_handler (ACE_Event_Handler *eh, ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr, int flags=THR_DETACHED) |
| int | remove_stdin_handler (ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr) |
| Performs the inverse of the <register_stdin_handler> method. More... | |
Protected Methods | |
| ACE_Event_Handler (ACE_Reactor *=0, int priority=ACE_Event_Handler::LO_PRIORITY) | |
| Force ACE_Event_Handler to be an abstract base class. More... | |
Private Attributes | |
| int | priority_ |
| Priority of this Event_Handler. More... | |
| ACE_Reactor * | reactor_ |
| Pointer to the various event demultiplexors. More... | |
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 43 of file Event_Handler.h.
|
|
Definition at line 133 of file Event_Handler.h.
00134 {
00135 /// The handler is not resumed at all. Could lead to deadlock..
00136 ACE_EVENT_HANDLER_NOT_RESUMED = -1,
00137 /// The reactor takes responsibility of resuming the handler and
00138 /// is the default
00139 ACE_REACTOR_RESUMES_HANDLER = 0,
00140 /// The application takes responsibility of resuming the handler
00141 ACE_APPLICATION_RESUMES_HANDLER
00142 };
|
|
|
Definition at line 46 of file Event_Handler.h.
00047 {
00048 LO_PRIORITY = 0,
00049 HI_PRIORITY = 10,
00050 NULL_MASK = 0,
00051 #if defined (ACE_USE_POLL)
00052 READ_MASK = POLLIN,
00053 WRITE_MASK = POLLOUT,
00054 EXCEPT_MASK = POLLPRI,
00055 #else /* USE SELECT */
00056 READ_MASK = (1 << 0),
00057 WRITE_MASK = (1 << 1),
00058 EXCEPT_MASK = (1 << 2),
00059 #endif /* ACE_USE_POLL */
00060 ACCEPT_MASK = (1 << 3),
00061 CONNECT_MASK = (1 << 4),
00062 TIMER_MASK = (1 << 5),
00063 QOS_MASK = (1 << 6),
00064 GROUP_QOS_MASK = (1 << 7),
00065 SIGNAL_MASK = (1 << 8),
00066 ALL_EVENTS_MASK = READ_MASK |
00067 WRITE_MASK |
00068 EXCEPT_MASK |
00069 ACCEPT_MASK |
00070 CONNECT_MASK |
00071 TIMER_MASK |
00072 QOS_MASK |
00073 GROUP_QOS_MASK |
00074 SIGNAL_MASK,
00075 RWE_MASK = READ_MASK |
00076 WRITE_MASK |
00077 EXCEPT_MASK,
00078 DONT_CALL = (1 << 9)
00079 };
|
|
|
Destructor is virtual to enable proper cleanup.
Definition at line 28 of file Event_Handler.cpp. References ACE_Reactor::purge_pending_notifications, and reactor_.
00029 {
00030 // ACE_TRACE ("ACE_Event_Handler::~ACE_Event_Handler");
00031 if (this->reactor_ != 0)
00032 {
00033 ACE_Errno_Guard guard (errno); // purge may get ENOTSUP
00034 this->reactor_->purge_pending_notifications (this);
00035 }
00036 }
|
|
||||||||||||
|
Force ACE_Event_Handler to be an abstract base class.
Definition at line 20 of file Event_Handler.cpp.
|
|
|
||||||||||||
|
|
Called when an exceptional events occur (e.g., SIGURG).
Reimplemented in ACE_Connector. Definition at line 104 of file Event_Handler.cpp. References ACE_TRACE. Referenced by ACE_Dev_Poll_Reactor::dispatch_io_events, ACE_Select_Reactor_T::dispatch_io_handlers, ACE_Select_Reactor_Notify::dispatch_notify, ACE_Dev_Poll_Reactor_Notify::dispatch_notify, ACE_TP_Reactor::get_socket_event_info, ACE_WFMO_Reactor_Notify::handle_signal, and ACE_WFMO_Reactor::upcall.
00105 {
00106 ACE_TRACE ("ACE_Event_Handler::handle_exception");
00107 return -1;
00108 }
|
|
|
Called when a process exits.
Definition at line 122 of file Event_Handler.cpp. References ACE_TRACE. Referenced by ACE_Process_Manager::notify_proc_handler.
00123 {
00124 ACE_TRACE ("ACE_Event_Handler::handle_exit");
00125 return -1;
00126 }
|
|
|
Definition at line 156 of file Event_Handler.cpp. References ACE_TRACE. Referenced by ACE_Select_Reactor_Notify::dispatch_notify, ACE_Dev_Poll_Reactor_Notify::dispatch_notify, ACE_WFMO_Reactor_Notify::handle_signal, and ACE_WFMO_Reactor::upcall.
00157 {
00158 ACE_TRACE ("ACE_Event_Handler::handle_group_qos");
00159 return -1;
00160 }
|
|
|
Called when input events occur (e.g., connection or data).
Reimplemented in ACE_Acceptor. Definition at line 86 of file Event_Handler.cpp. References ACE_TRACE. Referenced by ACE_Dev_Poll_Reactor::dispatch_io_events, ACE_Select_Reactor_T::dispatch_io_handlers, ACE_Select_Reactor_Notify::dispatch_notify, ACE_Dev_Poll_Reactor_Notify::dispatch_notify, ACE_TP_Reactor::get_socket_event_info, ACE_WFMO_Reactor_Notify::handle_signal, read_adapter, and ACE_WFMO_Reactor::upcall.
00087 {
00088 ACE_TRACE ("ACE_Event_Handler::handle_input");
00089 return -1;
00090 }
|
|
|
Called when output events are possible (e.g., when flow control abates or non-blocking connection completes).
Reimplemented in ACE_Connector. Definition at line 95 of file Event_Handler.cpp. References ACE_TRACE. Referenced by ACE_Dev_Poll_Reactor::dispatch_io_events, ACE_Select_Reactor_T::dispatch_io_handlers, ACE_Select_Reactor_Notify::dispatch_notify, ACE_Dev_Poll_Reactor_Notify::dispatch_notify, ACE_TP_Reactor::get_socket_event_info, ACE_WFMO_Reactor_Notify::handle_signal, and ACE_WFMO_Reactor::upcall.
00096 {
00097 ACE_TRACE ("ACE_Event_Handler::handle_output");
00098 return -1;
00099 }
|
|
|
Definition at line 149 of file Event_Handler.cpp. References ACE_TRACE. Referenced by ACE_Select_Reactor_Notify::dispatch_notify, ACE_Dev_Poll_Reactor_Notify::dispatch_notify, ACE_WFMO_Reactor_Notify::handle_signal, and ACE_WFMO_Reactor::upcall.
00150 {
00151 ACE_TRACE ("ACE_Event_Handler::handle_qos");
00152 return -1;
00153 }
|
|
||||||||||||||||
|
Called when object is signaled by OS (either via UNIX signals or when a Win32 object becomes signaled).
Reimplemented in ACE_Strategy_Acceptor. Definition at line 131 of file Event_Handler.cpp. References ACE_TRACE, and ucontext_t. Referenced by ACE_Sig_Handler::dispatch, ACE_Sig_Adapter::handle_signal, and ACE_WFMO_Reactor::simple_dispatch_handler.
00132 {
00133 ACE_TRACE ("ACE_Event_Handler::handle_signal");
00134 return -1;
00135 }
|
|
||||||||||||
|
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_Oneshot_Acceptor. Definition at line 113 of file Event_Handler.cpp. References ACE_TRACE. Referenced by ACE_Event_Handler_Handle_Timeout_Upcall::timeout.
00114 {
00115 ACE_TRACE ("ACE_Event_Handler::handle_timeout");
00116 return -1;
00117 }
|
|
|
Set the priority of the Event_Handler.
Definition at line 67 of file Event_Handler.cpp. References ACE_TRACE, priority, and priority_.
|
|
|
|
|
Set the event demultiplexors.
Definition at line 163 of file Event_Handler.cpp. References ACE_TRACE, and reactor_. Referenced by ACE_Svc_Handler::ACE_Svc_Handler, ACE_Reactor::notify, read_adapter, ACE_Reactor::register_handler, register_stdin_handler, ACE_Reactor::schedule_timer, ACE_Reactor::schedule_wakeup, and ACE_Event_Handler_Handle_Timeout_Upcall::timeout.
|
|
|
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 179 of file Event_Handler.cpp. References ACE_STDIN, get_handle, handle_close, handle_input, reactor, and READ_MASK. Referenced by register_stdin_handler.
00180 {
00181 ACE_Event_Handler *this_ptr = (ACE_Event_Handler *) args;
00182
00183 ACE_HANDLE handle = this_ptr->get_handle ();
00184 if (handle == ACE_INVALID_HANDLE)
00185 handle = ACE_STDIN;
00186
00187 while (this_ptr->handle_input (handle) != -1)
00188 continue;
00189
00190 this_ptr->handle_close (handle,
00191 ACE_Event_Handler::READ_MASK);
00192 this_ptr->reactor ()->notify ();
00193
00194 return 0;
00195 }
|
|
||||||||||||||||||||
|
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 198 of file Event_Handler.cpp. References ACE_STDIN, reactor, read_adapter, READ_MASK, ACE_Reactor::register_handler, and ACE_Thread_Manager::spawn.
00202 {
00203 #if defined (ACE_WIN32) || defined (ACE_PSOS)
00204 ACE_UNUSED_ARG (reactor);
00205
00206 eh->reactor (reactor);
00207 return thr_mgr->spawn (&read_adapter, (void *) eh, flags);
00208 #else
00209 // Keep compilers happy.
00210 ACE_UNUSED_ARG (flags);
00211 ACE_UNUSED_ARG (thr_mgr);
00212 return reactor->register_handler (ACE_STDIN,
00213 eh,
00214 ACE_Event_Handler::READ_MASK);
00215 #endif /* ACE_WIN32 || ACE_PSOS */
00216 }
|
|
||||||||||||
|
Performs the inverse of the <register_stdin_handler> method.
Definition at line 219 of file Event_Handler.cpp. References ACE_STDIN, READ_MASK, and ACE_Reactor::remove_handler.
00221 {
00222 #if defined (ACE_WIN32)
00223 ACE_UNUSED_ARG (reactor);
00224 ACE_UNUSED_ARG (thr_mgr);
00225
00226 // What should we do here?
00227 ACE_NOTSUP_RETURN (-1);
00228 #else
00229 // Keep compilers happy.
00230 ACE_UNUSED_ARG (thr_mgr);
00231 return reactor->remove_handler (ACE_STDIN,
00232 ACE_Event_Handler::READ_MASK);
00233 #endif /* ACE_WIN32 */
00234 }
|
|
|
Reimplemented in ACE_Connector. Definition at line 138 of file Event_Handler.cpp. References ACE_REACTOR_RESUMES_HANDLER, and ACE_TRACE. Referenced by ACE_TP_Reactor::handle_socket_events.
00139 {
00140 ACE_TRACE ("ACE_Event_Handler::resume_handler");
00141
00142 // Return a default value and allow the reactor to take care of
00143 // resuming the handler
00144 return ACE_Event_Handler::ACE_REACTOR_RESUMES_HANDLER;
00145 }
|
|
|
Set the I/O handle.
Reimplemented in ACE_Event_Handler_T. Definition at line 50 of file Event_Handler.cpp. References ACE_TRACE.
00051 {
00052 ACE_TRACE ("ACE_Event_Handler::set_handle");
00053 }
|
|
|
Priority of this Event_Handler.
Definition at line 201 of file Event_Handler.h. Referenced by priority. |
|
|
Pointer to the various event demultiplexors.
Reimplemented in ACE_Asynch_Pseudo_Task. Definition at line 204 of file Event_Handler.h. Referenced by reactor, and ~ACE_Event_Handler. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002