Reactor.cpp

Go to the documentation of this file.
00001 // $Id: Reactor.cpp 79134 2007-07-31 18:23:50Z johnnyw $
00002 
00003 #include "ace/Reactor.h"
00004 
00005 //#if !defined (ACE_HAS_WINCE)
00006 #  if !defined (ACE_LACKS_ACE_SVCCONF)
00007 #    include "ace/Service_Config.h"
00008 #  endif /* !ACE_LACKS_ACE_SVCCONF */
00009 //#endif /* ! ACE_HAS_WINCE */
00010 
00011 /*
00012  * Hook to specialize the includes directly with the concrete
00013  * Reactor type, e.g., select, thread pool reactor
00014  * known at compile time. This hook results in all the
00015  * #defines being commented
00016  * out and the concrete header file directly included.
00017  */
00018 //@@ REACTOR_SPL_COMMENT_INCLUDE_START_HOOK
00019 // Only include the headers needed to compile.
00020 #if !defined (ACE_WIN32) \
00021       || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) \
00022       || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) \
00023       || defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL) \
00024       || defined (ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL)
00025 #  if defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL)
00026 #    include "ace/TP_Reactor.h"
00027 #  else
00028 #    if defined (ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL)
00029 #      include "ace/Dev_Poll_Reactor.h"
00030 #    else
00031 #      include "ace/Select_Reactor.h"
00032 #    endif /* ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL */
00033 #  endif /* ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL */
00034 #else /* We are on Win32 and we have winsock and ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL is not defined */
00035 #  if defined (ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL)
00036 #    include "ace/Msg_WFMO_Reactor.h"
00037 #  else
00038 #    include "ace/WFMO_Reactor.h"
00039 #  endif /* ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL */
00040 #endif /* !defined (ACE_WIN32) || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) */
00041 
00042 /*
00043  * End comment hook.
00044  */
00045 //@@ REACTOR_SPL_COMMENT_INCLUDE_END_HOOK
00046 
00047 #include "ace/Static_Object_Lock.h"
00048 #include "ace/Framework_Component.h"
00049 #include "ace/Guard_T.h"
00050 #include "ace/Recursive_Thread_Mutex.h"
00051 
00052 #if !defined (__ACE_INLINE__)
00053 #include "ace/Reactor.inl"
00054 #endif /* __ACE_INLINE__ */
00055 
00056 
00057 ACE_RCSID (ace,
00058            Reactor,
00059            "$Id: Reactor.cpp 79134 2007-07-31 18:23:50Z johnnyw $")
00060 
00061 
00062 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00063 
00064 ACE_ALLOC_HOOK_DEFINE(ACE_Reactor)
00065 
00066 ACE_Reactor::ACE_Reactor (ACE_Reactor_Impl *impl,
00067                           int delete_implementation)
00068   : implementation_ (0),
00069     delete_implementation_ (delete_implementation)
00070 {
00071   this->implementation (impl);
00072 
00073   if (this->implementation () == 0)
00074     {
00075 /*
00076  * Hook to specialize the reactor implementation with the concrete
00077  * Reactor implementation known at compile time. This hook will
00078  * cause the conditionally defined code to be commented out and
00079  * the concrete Reactor directly created.
00080  */
00081 //@@ REACTOR_SPL_CONSTRUCTOR_COMMENT_HOOK_START
00082 #if !defined (ACE_WIN32) \
00083       || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) \
00084       || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) \
00085       || defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL) \
00086       || defined (ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL)
00087 #  if defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL)
00088       ACE_NEW (impl,
00089                ACE_TP_Reactor);
00090 #  else
00091 #    if defined (ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL)
00092       ACE_NEW (impl,
00093                ACE_Dev_Poll_Reactor);
00094 #    else
00095       ACE_NEW (impl,
00096                ACE_Select_Reactor);
00097 #    endif /* ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL */
00098 #  endif /* ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL */
00099 #else /* We are on Win32 and we have winsock and ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL is not defined */
00100   #if defined (ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL)
00101       ACE_NEW (impl,
00102                ACE_Msg_WFMO_Reactor);
00103   #else
00104       ACE_NEW (impl,
00105                ACE_WFMO_Reactor);
00106   #endif /* ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL */
00107 #endif /* !defined (ACE_WIN32) || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) */
00108 
00109 /*
00110  * End hook.
00111  */
00112 //@@ REACTOR_SPL_CONSTRUCTOR_COMMENT_HOOK_END
00113 
00114       this->implementation (impl);
00115       this->delete_implementation_ = 1;
00116     }
00117 }
00118 
00119 ACE_Reactor::~ACE_Reactor (void)
00120 {
00121   this->implementation ()->close ();
00122   if (this->delete_implementation_)
00123     delete this->implementation ();
00124 }
00125 
00126 // Process-wide ACE_Reactor.
00127 ACE_Reactor *ACE_Reactor::reactor_ = 0;
00128 
00129 // Controls whether the Reactor is deleted when we shut down (we can
00130 // only delete it safely if we created it!)
00131 int ACE_Reactor::delete_reactor_ = 0;
00132 
00133 ACE_Reactor *
00134 ACE_Reactor::instance (void)
00135 {
00136   ACE_TRACE ("ACE_Reactor::instance");
00137 
00138   if (ACE_Reactor::reactor_ == 0)
00139     {
00140       // Perform Double-Checked Locking Optimization.
00141       ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00142                                 *ACE_Static_Object_Lock::instance (), 0));
00143 
00144       if (ACE_Reactor::reactor_ == 0)
00145         {
00146           ACE_NEW_RETURN (ACE_Reactor::reactor_,
00147                           ACE_Reactor,
00148                           0);
00149           ACE_Reactor::delete_reactor_ = 1;
00150           ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Reactor, ACE_Reactor::reactor_)
00151         }
00152     }
00153   return ACE_Reactor::reactor_;
00154 }
00155 
00156 ACE_Reactor *
00157 ACE_Reactor::instance (ACE_Reactor *r,
00158                        int delete_reactor)
00159 {
00160   ACE_TRACE ("ACE_Reactor::instance");
00161 
00162   ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00163                             *ACE_Static_Object_Lock::instance (), 0));
00164   ACE_Reactor *t = ACE_Reactor::reactor_;
00165   if (delete_reactor != 0)
00166     ACE_Reactor::delete_reactor_ = 1;
00167   else
00168     // We can't safely delete it since we don't know who created it!
00169     ACE_Reactor::delete_reactor_ = 0;
00170 
00171   ACE_Reactor::reactor_ = r;
00172 
00173   // We can't register the Reactor singleton as a framework component twice.
00174   // Therefore we test to see if we had an existing reactor instance, which
00175   // if so means it must have already been registered.
00176   if (t == 0)
00177     ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Reactor, ACE_Reactor::reactor_);
00178 
00179   return t;
00180 }
00181 
00182 void
00183 ACE_Reactor::close_singleton (void)
00184 {
00185   ACE_TRACE ("ACE_Reactor::close_singleton");
00186 
00187   ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00188                      *ACE_Static_Object_Lock::instance ()));
00189 
00190   if (ACE_Reactor::delete_reactor_)
00191     {
00192       delete ACE_Reactor::reactor_;
00193       ACE_Reactor::reactor_ = 0;
00194       ACE_Reactor::delete_reactor_ = 0;
00195     }
00196 }
00197 
00198 const ACE_TCHAR *
00199 ACE_Reactor::dll_name (void)
00200 {
00201   return ACE_TEXT ("ACE");
00202 }
00203 
00204 const ACE_TCHAR *
00205 ACE_Reactor::name (void)
00206 {
00207   return ACE_TEXT ("ACE_Reactor");
00208 }
00209 
00210 int
00211 ACE_Reactor::check_reconfiguration (ACE_Reactor *)
00212 {
00213 #if !defined (ACE_HAS_WINCE)  &&  !defined (ACE_LACKS_ACE_SVCCONF)
00214   if (ACE_Service_Config::reconfig_occurred ())
00215     {
00216       ACE_Service_Config::reconfigure ();
00217       return 1;
00218     }
00219 #endif /* ! ACE_HAS_WINCE || ! ACE_LACKS_ACE_SVCCONF */
00220   return 0;
00221 }
00222 
00223 int
00224 ACE_Reactor::run_reactor_event_loop (REACTOR_EVENT_HOOK eh)
00225 {
00226   ACE_TRACE ("ACE_Reactor::run_reactor_event_loop");
00227 
00228   if (this->reactor_event_loop_done ())
00229     return 0;
00230 
00231   while (1)
00232     {
00233       int result = this->implementation_->handle_events ();
00234 
00235       if (eh != 0 && (*eh)(this))
00236         continue;
00237       else if (result == -1 && this->implementation_->deactivated ())
00238         return 0;
00239       else if (result == -1)
00240         return -1;
00241     }
00242 
00243   ACE_NOTREACHED (return 0;)
00244 }
00245 
00246 int
00247 ACE_Reactor::run_alertable_reactor_event_loop (REACTOR_EVENT_HOOK eh)
00248 {
00249   ACE_TRACE ("ACE_Reactor::run_alertable_reactor_event_loop");
00250 
00251   if (this->reactor_event_loop_done ())
00252     return 0;
00253 
00254   while (1)
00255     {
00256       int result = this->implementation_->alertable_handle_events ();
00257 
00258       if (eh != 0 && (*eh)(this))
00259         continue;
00260       else if (result == -1 && this->implementation_->deactivated ())
00261         return 0;
00262       else if (result == -1)
00263         return -1;
00264     }
00265 
00266   ACE_NOTREACHED (return 0;)
00267 }
00268 
00269 int
00270 ACE_Reactor::run_reactor_event_loop (ACE_Time_Value &tv,
00271                                      REACTOR_EVENT_HOOK eh)
00272 {
00273   ACE_TRACE ("ACE_Reactor::run_reactor_event_loop");
00274 
00275   if (this->reactor_event_loop_done ())
00276     return 0;
00277 
00278   while (1)
00279     {
00280       int result = this->implementation_->handle_events (tv);
00281 
00282       if (eh != 0 && (*eh) (this))
00283         continue;
00284       else if (result == -1)
00285         {
00286           if (this->implementation_->deactivated ())
00287             result = 0;
00288           return result;
00289         }
00290       else if (result == 0)
00291         {
00292           // The <handle_events> method timed out without dispatching
00293           // anything.  Because of rounding and conversion errors and
00294           // such, it could be that the wait loop (WFMO, select, etc.)
00295           // timed out, but the timer queue said it wasn't quite ready
00296           // to expire a timer. In this case, the ACE_Time_Value we
00297           // passed into handle_events won't have quite been reduced
00298           // to 0, and we need to go around again. If we are all the
00299           // way to 0, just return, as the entire time the caller
00300           // wanted to wait has been used up.
00301           if (tv.usec () > 0)
00302             continue;
00303           return 0;
00304         }
00305       // Else there were some events dispatched; go around again
00306     }
00307 
00308   ACE_NOTREACHED (return 0;)
00309 }
00310 
00311 int
00312 ACE_Reactor::run_alertable_reactor_event_loop (ACE_Time_Value &tv,
00313                                                REACTOR_EVENT_HOOK eh)
00314 {
00315   ACE_TRACE ("ACE_Reactor::run_alertable_reactor_event_loop");
00316 
00317   if (this->reactor_event_loop_done ())
00318     return 0;
00319 
00320   for (;;)
00321     {
00322       int result = this->implementation_->alertable_handle_events (tv);
00323 
00324       if (eh != 0 && (*eh)(this))
00325         continue;
00326       else if (result == -1 && this->implementation_->deactivated ())
00327         return 0;
00328       else if (result <= 0)
00329         return result;
00330     }
00331 }
00332 
00333 int
00334 ACE_Reactor::end_reactor_event_loop (void)
00335 {
00336   ACE_TRACE ("ACE_Reactor::end_reactor_event_loop");
00337 
00338   this->implementation_->deactivate (1);
00339 
00340   return 0;
00341 }
00342 
00343 void
00344 ACE_Reactor::reset_reactor_event_loop (void)
00345 {
00346   ACE_TRACE ("ACE_Reactor::reset_reactor_event_loop");
00347 
00348   this->implementation_->deactivate (0);
00349 }
00350 
00351 int
00352 ACE_Reactor::resumable_handler (void)
00353 {
00354   return this->implementation ()->resumable_handler ();
00355 }
00356 
00357 ACE_Reactor_Impl *
00358 ACE_Reactor::implementation (void) const
00359 {
00360   return this->implementation_;
00361 }
00362 
00363 void
00364 ACE_Reactor::implementation (ACE_Reactor_Impl *impl)
00365 {
00366   this->implementation_ = impl;
00367 }
00368 
00369 int
00370 ACE_Reactor::current_info (ACE_HANDLE handle,
00371                            size_t &size)
00372 {
00373   return this->implementation ()->current_info (handle, size);
00374 }
00375 
00376 int
00377 ACE_Reactor::open (size_t size,
00378                    int restart,
00379                    ACE_Sig_Handler *signal_handler,
00380                    ACE_Timer_Queue *timer_queue)
00381 {
00382   return this->implementation ()->open (size,
00383                                         restart,
00384                                         signal_handler,
00385                                         timer_queue);
00386 }
00387 int
00388 ACE_Reactor::set_sig_handler (ACE_Sig_Handler *signal_handler)
00389 {
00390   return this->implementation ()->set_sig_handler (signal_handler);
00391 }
00392 
00393 int
00394 ACE_Reactor::timer_queue (ACE_Timer_Queue *tq)
00395 {
00396   return this->implementation ()->timer_queue (tq);
00397 }
00398 
00399 ACE_Timer_Queue *
00400 ACE_Reactor::timer_queue (void) const
00401 {
00402   return this->implementation ()->timer_queue ();
00403 }
00404 
00405 int
00406 ACE_Reactor::close (void)
00407 {
00408   return this->implementation ()->close ();
00409 }
00410 
00411 int
00412 ACE_Reactor::work_pending (const ACE_Time_Value &max_wait_time)
00413 {
00414   return this->implementation ()->work_pending (max_wait_time);
00415 }
00416 
00417 int
00418 ACE_Reactor::handle_events (ACE_Time_Value *max_wait_time)
00419 {
00420   return this->implementation ()->handle_events (max_wait_time);
00421 }
00422 
00423 int
00424 ACE_Reactor::alertable_handle_events (ACE_Time_Value *max_wait_time)
00425 {
00426   return this->implementation ()->alertable_handle_events (max_wait_time);
00427 }
00428 
00429 int
00430 ACE_Reactor::handle_events (ACE_Time_Value &max_wait_time)
00431 {
00432   return this->implementation ()->handle_events (max_wait_time);
00433 }
00434 
00435 int
00436 ACE_Reactor::alertable_handle_events (ACE_Time_Value &max_wait_time)
00437 {
00438   return this->implementation ()->alertable_handle_events (max_wait_time);
00439 }
00440 
00441 
00442 int
00443 ACE_Reactor::register_handler (ACE_Event_Handler *event_handler,
00444                                ACE_Reactor_Mask mask)
00445 {
00446   // Remember the old reactor.
00447   ACE_Reactor *old_reactor = event_handler->reactor ();
00448 
00449   // Assign *this* <Reactor> to the <Event_Handler>.
00450   event_handler->reactor (this);
00451 
00452   int result = this->implementation ()->register_handler (event_handler,
00453                                                           mask);
00454   if (result == -1)
00455     // Reset the old reactor in case of failures.
00456     event_handler->reactor (old_reactor);
00457 
00458   return result;
00459 }
00460 
00461 int
00462 ACE_Reactor::register_handler (ACE_HANDLE io_handle,
00463                                ACE_Event_Handler *event_handler,
00464                                ACE_Reactor_Mask mask)
00465 {
00466   // Remember the old reactor.
00467   ACE_Reactor *old_reactor = event_handler->reactor ();
00468 
00469   // Assign *this* <Reactor> to the <Event_Handler>.
00470   event_handler->reactor (this);
00471 
00472   int result = this->implementation ()->register_handler (io_handle,
00473                                                           event_handler,
00474                                                           mask);
00475   if (result == -1)
00476     // Reset the old reactor in case of failures.
00477     event_handler->reactor (old_reactor);
00478 
00479   return result;
00480 }
00481 
00482 #if defined (ACE_WIN32)
00483 
00484 int
00485 ACE_Reactor::register_handler (ACE_Event_Handler *event_handler,
00486                                ACE_HANDLE event_handle)
00487 {
00488   // Remember the old reactor.
00489   ACE_Reactor *old_reactor = event_handler->reactor ();
00490 
00491   // Assign *this* <Reactor> to the <Event_Handler>.
00492   event_handler->reactor (this);
00493 
00494   int result = this->implementation ()->register_handler (event_handler,
00495                                                           event_handle);
00496   if (result == -1)
00497     // Reset the old reactor in case of failures.
00498     event_handler->reactor (old_reactor);
00499 
00500   return result;
00501 }
00502 
00503 #endif /* ACE_WIN32 */
00504 
00505 int
00506 ACE_Reactor::register_handler (ACE_HANDLE event_handle,
00507                                ACE_HANDLE io_handle,
00508                                ACE_Event_Handler *event_handler,
00509                                ACE_Reactor_Mask mask)
00510 {
00511   // Remember the old reactor.
00512   ACE_Reactor *old_reactor = event_handler->reactor ();
00513 
00514   // Assign *this* <Reactor> to the <Event_Handler>.
00515   event_handler->reactor (this);
00516 
00517   int result = this->implementation ()->register_handler (event_handle,
00518                                                           io_handle,
00519                                                           event_handler,
00520                                                           mask);
00521   if (result == -1)
00522     // Reset the old reactor in case of failures.
00523     event_handler->reactor (old_reactor);
00524 
00525   return result;
00526 }
00527 
00528 int
00529 ACE_Reactor::register_handler (const ACE_Handle_Set &handles,
00530                                ACE_Event_Handler *event_handler,
00531                                ACE_Reactor_Mask mask)
00532 {
00533   // Remember the old reactor.
00534   ACE_Reactor *old_reactor = event_handler->reactor ();
00535 
00536   // Assign *this* <Reactor> to the <Event_Handler>.
00537   event_handler->reactor (this);
00538 
00539   int result = this->implementation ()->register_handler (handles,
00540                                                           event_handler,
00541                                                           mask);
00542   if (result == -1)
00543     // Reset the old reactor in case of failures.
00544     event_handler->reactor (old_reactor);
00545 
00546   return result;
00547 }
00548 
00549 int
00550 ACE_Reactor::register_handler (int signum,
00551                                ACE_Event_Handler *new_sh,
00552                                ACE_Sig_Action *new_disp,
00553                                ACE_Event_Handler **old_sh,
00554                                ACE_Sig_Action *old_disp)
00555 {
00556   return this->implementation ()->register_handler (signum,
00557                                                     new_sh,
00558                                                     new_disp,
00559                                                     old_sh,
00560                                                     old_disp);
00561 }
00562 
00563 int
00564 ACE_Reactor::register_handler (const ACE_Sig_Set &sigset,
00565                                ACE_Event_Handler *new_sh,
00566                                ACE_Sig_Action *new_disp)
00567 {
00568   return this->implementation ()->register_handler (sigset,
00569                                                     new_sh,
00570                                                     new_disp);
00571 }
00572 
00573 int
00574 ACE_Reactor::remove_handler (ACE_Event_Handler *event_handler,
00575                              ACE_Reactor_Mask mask)
00576 {
00577   return this->implementation ()->remove_handler (event_handler,
00578                                                   mask);
00579 }
00580 
00581 int
00582 ACE_Reactor::remove_handler (ACE_HANDLE handle,
00583                              ACE_Reactor_Mask mask)
00584 {
00585   return this->implementation ()->remove_handler (handle,
00586                                                   mask);
00587 }
00588 
00589 int
00590 ACE_Reactor::remove_handler (const ACE_Handle_Set &handle_set,
00591                              ACE_Reactor_Mask mask)
00592 {
00593   return this->implementation ()->remove_handler (handle_set,
00594                                                   mask);
00595 }
00596 
00597 int
00598 ACE_Reactor::remove_handler (int signum,
00599                              ACE_Sig_Action *new_disp,
00600                              ACE_Sig_Action *old_disp,
00601                              int sigkey)
00602 {
00603   return this->implementation ()->remove_handler (signum,
00604                                                   new_disp,
00605                                                   old_disp,
00606                                                   sigkey);
00607 }
00608 
00609 int
00610 ACE_Reactor::remove_handler (const ACE_Sig_Set &sigset)
00611 {
00612   return this->implementation ()->remove_handler (sigset);
00613 }
00614 
00615 
00616 int
00617 ACE_Reactor::suspend_handler (ACE_Event_Handler *event_handler)
00618 {
00619   return this->implementation ()->suspend_handler (event_handler);
00620 }
00621 
00622 int
00623 ACE_Reactor::suspend_handler (ACE_HANDLE handle)
00624 {
00625   return this->implementation ()->suspend_handler (handle);
00626 }
00627 
00628 int
00629 ACE_Reactor::suspend_handler (const ACE_Handle_Set &handles)
00630 {
00631   return this->implementation ()->suspend_handler (handles);
00632 }
00633 
00634 int
00635 ACE_Reactor::suspend_handlers (void)
00636 {
00637   return this->implementation ()->suspend_handlers ();
00638 }
00639 
00640 int
00641 ACE_Reactor::resume_handler (ACE_Event_Handler *event_handler)
00642 {
00643   return this->implementation ()->resume_handler (event_handler);
00644 }
00645 
00646 int
00647 ACE_Reactor::resume_handler (ACE_HANDLE handle)
00648 {
00649   return this->implementation ()->resume_handler (handle);
00650 }
00651 
00652 int
00653 ACE_Reactor::resume_handler (const ACE_Handle_Set &handles)
00654 {
00655   return this->implementation ()->resume_handler (handles);
00656 }
00657 
00658 int
00659 ACE_Reactor::resume_handlers (void)
00660 {
00661   return this->implementation ()->resume_handlers ();
00662 }
00663 
00664 
00665 int
00666 ACE_Reactor::reset_timer_interval
00667   (long timer_id,
00668    const ACE_Time_Value &interval)
00669 {
00670   ACE_TRACE ("ACE_Reactor::reset_timer_interval");
00671 
00672   return this->implementation ()->reset_timer_interval
00673     (timer_id,
00674      interval);
00675 }
00676 
00677 long
00678 ACE_Reactor::schedule_timer (ACE_Event_Handler *event_handler,
00679                              const void *arg,
00680                              const ACE_Time_Value &delta,
00681                              const ACE_Time_Value &interval)
00682 {
00683   // Remember the old reactor.
00684   ACE_Reactor *old_reactor = event_handler->reactor ();
00685 
00686   // Assign *this* <Reactor> to the <Event_Handler>.
00687   event_handler->reactor (this);
00688 
00689   long result = this->implementation ()->schedule_timer (event_handler,
00690                                                          arg,
00691                                                          delta,
00692                                                          interval);
00693   if (result == -1)
00694     // Reset the old reactor in case of failures.
00695     event_handler->reactor (old_reactor);
00696 
00697   return result;
00698 }
00699 
00700 int
00701 ACE_Reactor::cancel_timer (ACE_Event_Handler *event_handler,
00702                            int dont_call_handle_close)
00703 {
00704   return this->implementation ()->cancel_timer (event_handler,
00705                                                 dont_call_handle_close);
00706 }
00707 
00708 int
00709 ACE_Reactor::cancel_timer (long timer_id,
00710                            const void **arg,
00711                            int dont_call_handle_close)
00712 {
00713   return this->implementation ()->cancel_timer (timer_id,
00714                                                 arg,
00715                                                 dont_call_handle_close);
00716 }
00717 
00718 int
00719 ACE_Reactor::schedule_wakeup (ACE_Event_Handler *event_handler,
00720                               ACE_Reactor_Mask masks_to_be_added)
00721 {
00722   // Remember the old reactor.
00723   ACE_Reactor *old_reactor = event_handler->reactor ();
00724 
00725   // Assign *this* <Reactor> to the <Event_Handler>.
00726   event_handler->reactor (this);
00727 
00728   int result = this->implementation ()->schedule_wakeup (event_handler,
00729                                                          masks_to_be_added);
00730   if (result == -1)
00731     // Reset the old reactor in case of failures.
00732     event_handler->reactor (old_reactor);
00733 
00734   return result;
00735 }
00736 
00737 int
00738 ACE_Reactor::schedule_wakeup (ACE_HANDLE handle,
00739                               ACE_Reactor_Mask masks_to_be_added)
00740 {
00741   return implementation ()->schedule_wakeup (handle,
00742                                              masks_to_be_added);
00743 }
00744 
00745 int
00746 ACE_Reactor::cancel_wakeup (ACE_Event_Handler *event_handler,
00747                             ACE_Reactor_Mask masks_to_be_cleared)
00748 {
00749   return this->implementation ()->cancel_wakeup (event_handler,
00750                                                  masks_to_be_cleared);
00751 }
00752 
00753 int
00754 ACE_Reactor::cancel_wakeup (ACE_HANDLE handle,
00755                             ACE_Reactor_Mask masks_to_be_cleared)
00756 {
00757   return this->implementation ()->cancel_wakeup (handle,
00758                                                  masks_to_be_cleared);
00759 }
00760 
00761 
00762 int
00763 ACE_Reactor::notify (ACE_Event_Handler *event_handler,
00764                      ACE_Reactor_Mask mask,
00765                      ACE_Time_Value *tv)
00766 {
00767   // First, try to remember this reactor in the event handler, in case
00768   // the event handler goes away before the notification is delivered.
00769   if (event_handler != 0 && event_handler->reactor () == 0)
00770     event_handler->reactor (this);
00771   return this->implementation ()->notify (event_handler,
00772                                           mask,
00773                                           tv);
00774 }
00775 
00776 void
00777 ACE_Reactor::max_notify_iterations (int iterations)
00778 {
00779   this->implementation ()->max_notify_iterations (iterations);
00780 }
00781 
00782 int
00783 ACE_Reactor::max_notify_iterations (void)
00784 {
00785   return this->implementation ()->max_notify_iterations ();
00786 }
00787 
00788 int
00789 ACE_Reactor::purge_pending_notifications (ACE_Event_Handler *eh,
00790                                           ACE_Reactor_Mask   mask)
00791 {
00792   return this->implementation ()->purge_pending_notifications (eh, mask);
00793 }
00794 
00795 ACE_Event_Handler *
00796 ACE_Reactor::find_handler (ACE_HANDLE handle)
00797 {
00798   return this->implementation ()->find_handler (handle);
00799 }
00800 
00801 int
00802 ACE_Reactor::handler (ACE_HANDLE handle,
00803                       ACE_Reactor_Mask mask,
00804                       ACE_Event_Handler **event_handler)
00805 {
00806   return this->implementation ()->handler (handle,
00807                                            mask,
00808                                            event_handler);
00809 }
00810 
00811 int
00812 ACE_Reactor::handler (int signum,
00813                       ACE_Event_Handler **event_handler)
00814 {
00815   return this->implementation ()->handler (signum,
00816                                            event_handler);
00817 }
00818 
00819 int
00820 ACE_Reactor::initialized (void)
00821 {
00822   return this->implementation ()->initialized ();
00823 }
00824 
00825 ACE_Lock &
00826 ACE_Reactor::lock (void)
00827 {
00828   return this->implementation ()->lock ();
00829 }
00830 
00831 void
00832 ACE_Reactor::wakeup_all_threads (void)
00833 {
00834   this->implementation ()->wakeup_all_threads ();
00835 }
00836 
00837 int
00838 ACE_Reactor::owner (ACE_thread_t new_owner,
00839                     ACE_thread_t *old_owner)
00840 {
00841   return this->implementation ()->owner (new_owner,
00842                                          old_owner);
00843 }
00844 
00845 int
00846 ACE_Reactor::owner (ACE_thread_t *owner)
00847 {
00848   return this->implementation ()->owner (owner);
00849 }
00850 
00851 int
00852 ACE_Reactor::restart (void)
00853 {
00854   return this->implementation ()->restart ();
00855 }
00856 
00857 int
00858 ACE_Reactor::restart (int r)
00859 {
00860   return this->implementation ()->restart (r);
00861 }
00862 
00863 void
00864 ACE_Reactor::requeue_position (int position)
00865 {
00866   this->implementation ()->requeue_position (position);
00867 }
00868 
00869 int
00870 ACE_Reactor::requeue_position (void)
00871 {
00872   return this->implementation ()->requeue_position ();
00873 }
00874 
00875 
00876 int
00877 ACE_Reactor::mask_ops (ACE_Event_Handler *event_handler,
00878                        ACE_Reactor_Mask mask,
00879                        int ops)
00880 {
00881   return this->implementation ()->mask_ops (event_handler,
00882                                             mask,
00883                                             ops);
00884 }
00885 
00886 int
00887 ACE_Reactor::mask_ops (ACE_HANDLE handle,
00888                        ACE_Reactor_Mask mask,
00889                        int ops)
00890 {
00891   return this->implementation ()->mask_ops (handle,
00892                                             mask,
00893                                             ops);
00894 }
00895 
00896 int
00897 ACE_Reactor::ready_ops (ACE_Event_Handler *event_handler,
00898                         ACE_Reactor_Mask mask,
00899                         int ops)
00900 {
00901   return this->implementation ()->ready_ops (event_handler,
00902                                              mask,
00903                                              ops);
00904 }
00905 
00906 int
00907 ACE_Reactor::ready_ops (ACE_HANDLE handle,
00908                         ACE_Reactor_Mask mask,
00909                         int ops)
00910 {
00911   return this->implementation ()->ready_ops (handle,
00912                                              mask,
00913                                              ops);
00914 }
00915 
00916 int
00917 ACE_Reactor::reactor_event_loop_done (void)
00918 {
00919   ACE_TRACE ("ACE_Reactor::reactor_event_loop_done");
00920   return this->implementation_->deactivated ();
00921 }
00922 
00923 size_t
00924 ACE_Reactor::size (void) const
00925 {
00926   return this->implementation ()->size ();
00927 }
00928 
00929 int
00930 ACE_Reactor::uses_event_associations (void)
00931 {
00932   return this->implementation ()->uses_event_associations ();
00933 }
00934 
00935 void
00936 ACE_Reactor::dump (void) const
00937 {
00938 #if defined (ACE_HAS_DUMP)
00939   ACE_TRACE ("ACE_Reactor::dump");
00940 
00941   implementation_->dump ();
00942 #endif /* ACE_HAS_DUMP */
00943 }
00944 
00945 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Sun Jan 27 12:05:36 2008 for ACE by doxygen 1.3.6