Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Event_Handler.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // Event_Handler.cpp
00003 // $Id: Event_Handler.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:21 chad Exp $
00004 
00005 #include "ace/Event_Handler.h"
00006 #include "ace/Message_Block.h"
00007 #include "ace/OS_Errno.h"
00008 #include "ace/Reactor.h"
00009 #include "ace/Thread_Manager.h"
00010 
00011 #if !defined (__ACE_INLINE__)
00012 #include "ace/Event_Handler.i"
00013 #endif /* __ACE_INLINE__ */
00014 
00015 ACE_RCSID(ace, Event_Handler, "$Id: Event_Handler.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:21 chad Exp $")
00016 
00017 // Implement conceptually abstract virtual functions in the base class
00018 // so derived classes don't have to implement unused ones.
00019 
00020 ACE_Event_Handler::ACE_Event_Handler (ACE_Reactor *r,
00021                                       int p)
00022   : priority_ (p),
00023     reactor_ (r)
00024 {
00025   // ACE_TRACE ("ACE_Event_Handler::ACE_Event_Handler");
00026 }
00027 
00028 ACE_Event_Handler::~ACE_Event_Handler (void)
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 }
00037 
00038 // Gets the file descriptor associated with this I/O device.
00039 
00040 ACE_HANDLE
00041 ACE_Event_Handler::get_handle (void) const
00042 {
00043   ACE_TRACE ("ACE_Event_Handler::get_handle");
00044   return ACE_INVALID_HANDLE;
00045 }
00046 
00047 // Sets the file descriptor associated with this I/O device.
00048 
00049 void
00050 ACE_Event_Handler::set_handle (ACE_HANDLE)
00051 {
00052   ACE_TRACE ("ACE_Event_Handler::set_handle");
00053 }
00054 
00055 // Gets the priority of this handler.
00056 
00057 int
00058 ACE_Event_Handler::priority (void) const
00059 {
00060   ACE_TRACE ("ACE_Event_Handler::priority");
00061   return this->priority_;
00062 }
00063 
00064 // Sets the priority
00065 
00066 void
00067 ACE_Event_Handler::priority (int priority)
00068 {
00069   ACE_TRACE ("ACE_Event_Handler::priority");
00070   this->priority_ = priority;
00071 }
00072 
00073 // Called when the object is about to be removed from the Dispatcher
00074 // tables.
00075 
00076 int
00077 ACE_Event_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
00078 {
00079   ACE_TRACE ("ACE_Event_Handler::handle_close");
00080   return -1;
00081 }
00082 
00083 // Called when input becomes available on fd.
00084 
00085 int
00086 ACE_Event_Handler::handle_input (ACE_HANDLE)
00087 {
00088   ACE_TRACE ("ACE_Event_Handler::handle_input");
00089   return -1;
00090 }
00091 
00092 // Called when output is possible on fd.
00093 
00094 int
00095 ACE_Event_Handler::handle_output (ACE_HANDLE)
00096 {
00097   ACE_TRACE ("ACE_Event_Handler::handle_output");
00098   return -1;
00099 }
00100 
00101 // Called when urgent data is available on fd.
00102 
00103 int
00104 ACE_Event_Handler::handle_exception (ACE_HANDLE)
00105 {
00106   ACE_TRACE ("ACE_Event_Handler::handle_exception");
00107   return -1;
00108 }
00109 
00110 // Called when timer expires, TV stores the current time.
00111 
00112 int
00113 ACE_Event_Handler::handle_timeout (const ACE_Time_Value &, const void *)
00114 {
00115   ACE_TRACE ("ACE_Event_Handler::handle_timeout");
00116   return -1;
00117 }
00118 
00119 // Called when a monitored Process exits
00120 
00121 int
00122 ACE_Event_Handler::handle_exit (ACE_Process *)
00123 {
00124   ACE_TRACE ("ACE_Event_Handler::handle_exit");
00125   return -1;
00126 }
00127 
00128 // Called when a registered signal occurs.
00129 
00130 int
00131 ACE_Event_Handler::handle_signal (int, siginfo_t *, ucontext_t *)
00132 {
00133   ACE_TRACE ("ACE_Event_Handler::handle_signal");
00134   return -1;
00135 }
00136 
00137 int
00138 ACE_Event_Handler::resume_handler (void)
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 }
00146 
00147 
00148 int
00149 ACE_Event_Handler::handle_qos (ACE_HANDLE)
00150 {
00151   ACE_TRACE ("ACE_Event_Handler::handle_qos");
00152   return -1;
00153 }
00154 
00155 int
00156 ACE_Event_Handler::handle_group_qos (ACE_HANDLE)
00157 {
00158   ACE_TRACE ("ACE_Event_Handler::handle_group_qos");
00159   return -1;
00160 }
00161 
00162 void
00163 ACE_Event_Handler::reactor (ACE_Reactor *reactor)
00164 {
00165   ACE_TRACE ("ACE_Event_Handler::reactor");
00166   this->reactor_ = reactor;
00167 }
00168 
00169 ACE_Reactor *
00170 ACE_Event_Handler::reactor (void) const
00171 {
00172   ACE_TRACE ("ACE_Event_Handler::reactor");
00173   return this->reactor_;
00174 }
00175 
00176 #if !defined (ACE_HAS_WINCE)
00177 
00178 ACE_THR_FUNC_RETURN
00179 ACE_Event_Handler::read_adapter (void *args)
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 }
00196 
00197 int
00198 ACE_Event_Handler::register_stdin_handler (ACE_Event_Handler *eh,
00199                                            ACE_Reactor *reactor,
00200                                            ACE_Thread_Manager *thr_mgr,
00201                                            int flags)
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 }
00217 
00218 int
00219 ACE_Event_Handler::remove_stdin_handler (ACE_Reactor *reactor,
00220                                          ACE_Thread_Manager *thr_mgr)
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 }
00235 
00236 #endif /* ACE_HAS_WINCE */
00237 
00238 ACE_Notification_Buffer::ACE_Notification_Buffer (void)
00239 {
00240   ACE_TRACE ("ACE_Notification_Buffer::ACE_Notification_Buffer");
00241 }
00242 
00243 ACE_Notification_Buffer::ACE_Notification_Buffer (ACE_Event_Handler *eh,
00244                                                   ACE_Reactor_Mask mask)
00245   : eh_ (eh),
00246     mask_ (mask)
00247 {
00248   ACE_TRACE ("ACE_Notification_Buffer::ACE_Notification_Buffer");
00249 }

Generated on Mon Jun 16 11:19:38 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002