ACE_Reactor Class Reference

The responsibility of this class is to forward all methods to its delegation/implementation class, e.g., ACE_Select_Reactor or ACE_WFMO_Reactor. More...

#include <Reactor.h>

Inheritance diagram for ACE_Reactor:

Inheritance graph
[legend]
Collaboration diagram for ACE_Reactor:

Collaboration graph
[legend]
List of all members.

Public Types

typedef int(*) REACTOR_EVENT_HOOK (ACE_Reactor *)
 GET_MASK = 1
 SET_MASK = 2
 Set value of bits to new mask (changes the entire mask).
 ADD_MASK = 3
 CLR_MASK = 4
enum  { GET_MASK = 1, SET_MASK = 2, ADD_MASK = 3, CLR_MASK = 4 }
 Operations on the "ready" mask and the "dispatch" mask. More...

Public Member Functions

int run_reactor_event_loop (REACTOR_EVENT_HOOK=0)
int run_alertable_reactor_event_loop (REACTOR_EVENT_HOOK=0)
int run_reactor_event_loop (ACE_Time_Value &tv, REACTOR_EVENT_HOOK=0)
int run_alertable_reactor_event_loop (ACE_Time_Value &tv, REACTOR_EVENT_HOOK=0)
int end_reactor_event_loop (void)
int reactor_event_loop_done (void)
 Indicate if the Reactor's event loop has been ended.
void reset_reactor_event_loop (void)
 ACE_Reactor (ACE_Reactor_Impl *implementation=0, bool delete_implementation=false)
virtual ~ACE_Reactor (void)
 Close down and release all resources.
int open (size_t max_number_of_handles, int restart=0, ACE_Sig_Handler *signal_handler=0, ACE_Timer_Queue *timer_queue=0)
int set_sig_handler (ACE_Sig_Handler *signal_handler)
 Use a user specified signal handler instead.
int timer_queue (ACE_Timer_Queue *tq)
 Set a user-specified timer queue.
ACE_Timer_Queuetimer_queue (void) const
 Return the current ACE_Timer_Queue.
int close (void)
 Close down and release all resources.
int work_pending (const ACE_Time_Value &max_wait_time=ACE_Time_Value::zero)
int handle_events (ACE_Time_Value *max_wait_time=0)
int alertable_handle_events (ACE_Time_Value *max_wait_time=0)
int handle_events (ACE_Time_Value &max_wait_time)
int alertable_handle_events (ACE_Time_Value &max_wait_time)
int register_handler (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask)
int register_handler (ACE_HANDLE io_handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask)
int register_handler (ACE_HANDLE event_handle, ACE_HANDLE io_handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask)
int register_handler (const ACE_Handle_Set &handles, ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks)
int register_handler (int signum, ACE_Event_Handler *new_sh, ACE_Sig_Action *new_disp=0, ACE_Event_Handler **old_sh=0, ACE_Sig_Action *old_disp=0)
int register_handler (const ACE_Sig_Set &sigset, ACE_Event_Handler *event_handler, ACE_Sig_Action *sig_action=0)
int remove_handler (ACE_HANDLE handle, ACE_Reactor_Mask masks)
int remove_handler (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks)
int remove_handler (const ACE_Handle_Set &handles, ACE_Reactor_Mask masks)
int remove_handler (int signum, ACE_Sig_Action *new_disp, ACE_Sig_Action *old_disp=0, int sigkey=-1)
int remove_handler (const ACE_Sig_Set &sigset)
int suspend_handler (ACE_HANDLE handle)
int suspend_handler (ACE_Event_Handler *event_handler)
int suspend_handler (const ACE_Handle_Set &handles)
int suspend_handlers (void)
int resume_handler (ACE_HANDLE handle)
int resume_handler (ACE_Event_Handler *event_handler)
int resume_handler (const ACE_Handle_Set &handles)
int resume_handlers (void)
int resumable_handler (void)
virtual long schedule_timer (ACE_Event_Handler *event_handler, const void *arg, const ACE_Time_Value &delay, const ACE_Time_Value &interval=ACE_Time_Value::zero)
virtual int reset_timer_interval (long timer_id, const ACE_Time_Value &interval)
virtual int cancel_timer (long timer_id, const void **arg=0, int dont_call_handle_close=1)
virtual int cancel_timer (ACE_Event_Handler *event_handler, int dont_call_handle_close=1)
int schedule_wakeup (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks_to_be_added)
int schedule_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask masks_to_be_added)
int cancel_wakeup (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks_to_be_cleared)
int cancel_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask masks_to_be_cleared)
int notify (ACE_Event_Handler *event_handler=0, ACE_Reactor_Mask masks=ACE_Event_Handler::EXCEPT_MASK, ACE_Time_Value *timeout=0)
void max_notify_iterations (int iterations)
int max_notify_iterations (void)
int purge_pending_notifications (ACE_Event_Handler *eh, ACE_Reactor_Mask=ACE_Event_Handler::ALL_EVENTS_MASK)
ACE_Event_Handlerfind_handler (ACE_HANDLE handle)
int handler (ACE_HANDLE handle, ACE_Reactor_Mask mask, ACE_Event_Handler **event_handler=0)
int handler (int signum, ACE_Event_Handler **event_handler=0)
int initialized (void)
size_t size (void) const
ACE_Locklock (void)
 Returns a reference to the Reactor's internal lock.
void wakeup_all_threads (void)
 Wake up all threads in waiting in the event loop.
int owner (ACE_thread_t new_owner, ACE_thread_t *old_owner=0)
 Transfers ownership of Reactor to the new_owner.
int owner (ACE_thread_t *owner)
 Return the ID of the "owner" thread.
void requeue_position (int position)
 Set position of the owner thread.
int requeue_position (void)
 Get position of the owner thread.
int restart (void)
 Get the existing restart value.
int restart (int r)
 Set a new value for restart and return the original value.
int mask_ops (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask, int ops)
int mask_ops (ACE_HANDLE handle, ACE_Reactor_Mask mask, int ops)
int ready_ops (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask, int ops)
int ready_ops (ACE_HANDLE handle, ACE_Reactor_Mask mask, int ops)
 GET/SET/ADD/CLR the ready "bit" bound with the <handle> and mask.
ACE_Reactor_Implimplementation (void) const
 Get the implementation class.
int current_info (ACE_HANDLE handle, size_t &msg_size)
int uses_event_associations (void)
void dump (void) const
 Dump the state of the object.

Static Public Member Functions

static ACE_Reactorinstance (void)
 Get pointer to a process-wide ACE_Reactor.
static ACE_Reactorinstance (ACE_Reactor *, bool delete_reactor=false)
static void close_singleton (void)
 Delete the dynamically allocated Singleton.
static const ACE_TCHARdll_name (void)
 Name of the dll in which the dll lives.
static const ACE_TCHARname (void)
 Name of the component--ACE_Reactor in this case.
static int run_event_loop (void)
static int run_alertable_event_loop (void)
static int run_event_loop (ACE_Time_Value &tv)
static int run_alertable_event_loop (ACE_Time_Value &tv)
static int end_event_loop (void)
static int event_loop_done (void)
static void reset_event_loop (void)
static int check_reconfiguration (ACE_Reactor *)

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Protected Member Functions

void implementation (ACE_Reactor_Impl *implementation)
 Set the implementation class.
 ACE_Reactor (const ACE_Reactor &)
 Deny access since member-wise won't work...
ACE_Reactoroperator= (const ACE_Reactor &)

Protected Attributes

ACE_Reactor_Implimplementation_
bool delete_implementation_

Static Protected Attributes

static ACE_Reactorreactor_ = 0
 Pointer to a process-wide ACE_Reactor singleton.
static bool delete_reactor_ = false
 Must delete the reactor_ singleton if true.

Detailed Description

The responsibility of this class is to forward all methods to its delegation/implementation class, e.g., ACE_Select_Reactor or ACE_WFMO_Reactor.

Definition at line 58 of file Reactor.h.


Member Typedef Documentation

typedef int(*) ACE_Reactor::REACTOR_EVENT_HOOK(ACE_Reactor *)

You can specify a hook function to event-handling methods that will be called after each iteration of event handling. If the hook function returns a non-zero value, the event loop will immediately resume waiting for the next event(s) to process without checking the error status of the just-completed iteration of event handling or the end-of-loop indication. If the hook function returns 0, the event handling error status and the end-of-loop indication will be checked as normal, just as if there is no hook function specified.

Definition at line 87 of file Reactor.h.


Member Enumeration Documentation

anonymous enum

Operations on the "ready" mask and the "dispatch" mask.

Enumerator:
GET_MASK  Retrieve current value of the the "ready" mask or the "dispatch" mask.
SET_MASK  Set value of bits to new mask (changes the entire mask).
ADD_MASK  Bitwise "or" the value into the mask (only changes enabled bits).
CLR_MASK  Bitwise "and" the negation of the value out of the mask (only changes enabled bits).

Definition at line 62 of file Reactor.h.

00063   {
00064     /// Retrieve current value of the the "ready" mask or the
00065     /// "dispatch" mask.
00066     GET_MASK = 1,
00067     /// Set value of bits to new mask (changes the entire mask).
00068     SET_MASK = 2,
00069     /// Bitwise "or" the value into the mask (only changes enabled
00070     /// bits).
00071     ADD_MASK = 3,
00072     /// Bitwise "and" the negation of the value out of the mask (only
00073     /// changes enabled bits).
00074     CLR_MASK = 4
00075   };


Constructor & Destructor Documentation

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Reactor::ACE_Reactor ( ACE_Reactor_Impl implementation = 0,
bool  delete_implementation = false 
)

Create the Reactor using implementation. The flag delete_implementation tells the Reactor whether or not to delete the implementation on destruction.

Definition at line 62 of file Reactor.cpp.

References ACE_NEW.

00064   : implementation_ (0),
00065     delete_implementation_ (delete_implementation)
00066 {
00067   this->implementation (impl);
00068 
00069   if (this->implementation () == 0)
00070     {
00071 /*
00072  * Hook to specialize the reactor implementation with the concrete
00073  * Reactor implementation known at compile time. This hook will
00074  * cause the conditionally defined code to be commented out and
00075  * the concrete Reactor directly created.
00076  */
00077 //@@ REACTOR_SPL_CONSTRUCTOR_COMMENT_HOOK_START
00078 #if !defined (ACE_WIN32) \
00079       || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) \
00080       || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) \
00081       || defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL) \
00082       || defined (ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL)
00083 #  if defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL)
00084       ACE_NEW (impl,
00085                ACE_TP_Reactor);
00086 #  else
00087 #    if defined (ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL)
00088       ACE_NEW (impl,
00089                ACE_Dev_Poll_Reactor);
00090 #    else
00091       ACE_NEW (impl,
00092                ACE_Select_Reactor);
00093 #    endif /* ACE_USE_DEV_POLL_REACTOR_FOR_REACTOR_IMPL */
00094 #  endif /* ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL */
00095 #else /* We are on Win32 and we have winsock and ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL is not defined */
00096   #if defined (ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL)
00097       ACE_NEW (impl,
00098                ACE_Msg_WFMO_Reactor);
00099   #else
00100       ACE_NEW (impl,
00101                ACE_WFMO_Reactor);
00102   #endif /* ACE_USE_MSG_WFMO_REACTOR_FOR_REACTOR_IMPL */
00103 #endif /* !defined (ACE_WIN32) || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) */
00104 
00105 /*
00106  * End hook.
00107  */
00108 //@@ REACTOR_SPL_CONSTRUCTOR_COMMENT_HOOK_END
00109 
00110       this->implementation (impl);
00111       this->delete_implementation_ = true;
00112     }
00113 }

ACE_Reactor::~ACE_Reactor ( void   )  [virtual]

Close down and release all resources.

Any notifications that remain queued on this reactor instance are lost.

Definition at line 115 of file Reactor.cpp.

References ACE_Reactor_Impl::close(), and implementation().

00116 {
00117   this->implementation ()->close ();
00118   if (this->delete_implementation_)
00119     delete this->implementation ();
00120 }

ACE_Reactor::ACE_Reactor ( const ACE_Reactor  )  [protected]

Deny access since member-wise won't work...


Member Function Documentation

ACE_INLINE int ACE_Reactor::alertable_handle_events ( ACE_Time_Value max_wait_time  ) 

Definition at line 204 of file Reactor.inl.

References ACE_Reactor_Impl::alertable_handle_events(), and implementation().

00205 {
00206   return this->implementation ()->alertable_handle_events (max_wait_time);
00207 }

ACE_INLINE int ACE_Reactor::alertable_handle_events ( ACE_Time_Value max_wait_time = 0  ) 

Definition at line 192 of file Reactor.inl.

References ACE_Reactor_Impl::alertable_handle_events(), and implementation().

00193 {
00194   return this->implementation ()->alertable_handle_events (max_wait_time);
00195 }

int ACE_Reactor::cancel_timer ( ACE_Event_Handler event_handler,
int  dont_call_handle_close = 1 
) [virtual]

Cancel all timers associated with event handler.

Shorthand for calling cancel_timer(long,const void **,int) multiple times for all timer associated with event_handler.

ACE_Event_Handler::handle_close() will be called with ACE_Event_Handler::TIMER_MASK only once irrespective of the number of timers associated with the event handler. ACE_Event_Handler::remove_reference() will also be called once for every timer associated with the event handler.

Returns number of handlers cancelled.

Implements ACE_Reactor_Timer_Interface.

Definition at line 495 of file Reactor.cpp.

References ACE_Reactor_Impl::cancel_timer(), and implementation().

00497 {
00498   return this->implementation ()->cancel_timer (event_handler,
00499                                                 dont_call_handle_close);
00500 }

int ACE_Reactor::cancel_timer ( long  timer_id,
const void **  arg = 0,
int  dont_call_handle_close = 1 
) [virtual]

Cancel timer.

Cancel timer associated with timer_id that was returned from the schedule_timer() method. If arg is non-NULL then it will be set to point to the ``magic cookie'' argument passed in when the handler was registered. This makes it possible to free up the memory and avoid memory leaks. Returns 1 if cancellation succeeded and 0 if the timer_id wasn't found.

On successful cancellation, ACE_Event_Handler::handle_close() will be called with ACE_Event_Handler::TIMER_MASK. ACE_Event_Handler::remove_reference() will also be called.

Implements ACE_Reactor_Timer_Interface.

Definition at line 503 of file Reactor.cpp.

References ACE_Reactor_Impl::cancel_timer(), and implementation().

Referenced by ACE_Oneshot_Acceptor< SVC_HANDLER, >::cancel(), and ACE_Svc_Handler<, >::shutdown().

00506 {
00507   return this->implementation ()->cancel_timer (timer_id,
00508                                                 arg,
00509                                                 dont_call_handle_close);
00510 }

ACE_INLINE int ACE_Reactor::cancel_wakeup ( ACE_HANDLE  handle,
ACE_Reactor_Mask  masks_to_be_cleared 
)

Clear masks_to_be_cleared from the <handle>'s entry. Note that this call does not cause the Reactor to re-examine its set of handlers - the new masks will be noticed the next time the Reactor waits for activity. If there is no other activity expected, or you need immediate re-examination of the wait masks, either call ACE_Reactor::notify after this call, or use ACE_Reactor::register_handler instead.

Definition at line 336 of file Reactor.inl.

References ACE_Reactor_Impl::cancel_wakeup(), and implementation().

00338 {
00339   return this->implementation ()->cancel_wakeup (handle,
00340                                                  masks_to_be_cleared);
00341 }

ACE_INLINE int ACE_Reactor::cancel_wakeup ( ACE_Event_Handler event_handler,
ACE_Reactor_Mask  masks_to_be_cleared 
)

Clear masks_to_be_cleared from the event_handler's entry. Note that this call does not cause the Reactor to re-examine its set of handlers - the new masks will be noticed the next time the Reactor waits for activity. If there is no other activity expected, or you need immediate re-examination of the wait masks, either call ACE_Reactor::notify after this call, or use ACE_Reactor::register_handler instead.

Definition at line 328 of file Reactor.inl.

References ACE_Reactor_Impl::cancel_wakeup(), and implementation().

00330 {
00331   return this->implementation ()->cancel_wakeup (event_handler,
00332                                                  masks_to_be_cleared);
00333 }

int ACE_Reactor::check_reconfiguration ( ACE_Reactor  )  [static]

The singleton reactor is used by the ACE_Service_Config. Therefore, we must check for the reconfiguration request and handle it after handling an event.

Definition at line 202 of file Reactor.cpp.

References ACE_Service_Config::reconfig_occurred(), and ACE_Service_Config::reconfigure().

Referenced by run_alertable_event_loop(), and run_event_loop().

00203 {
00204 #if !defined (ACE_HAS_WINCE)  &&  !defined (ACE_LACKS_ACE_SVCCONF)
00205   if (ACE_Service_Config::reconfig_occurred ())
00206     {
00207       ACE_Service_Config::reconfigure ();
00208       return 1;
00209     }
00210 #endif /* ! ACE_HAS_WINCE || ! ACE_LACKS_ACE_SVCCONF */
00211   return 0;
00212 }

ACE_INLINE int ACE_Reactor::close ( void   ) 

Close down and release all resources.

Definition at line 174 of file Reactor.inl.

References ACE_Reactor_Impl::close(), and implementation().

Referenced by ACE_Asynch_Pseudo_Task::stop().

00175 {
00176   return this->implementation ()->close ();
00177 }

void ACE_Reactor::close_singleton ( void   )  [static]

Delete the dynamically allocated Singleton.

Definition at line 174 of file Reactor.cpp.

References ACE_GUARD, ACE_TRACE, delete_reactor_, and reactor_.

Referenced by ACE::Monitor_Control::Monitor_Admin::~Monitor_Admin().

00175 {
00176   ACE_TRACE ("ACE_Reactor::close_singleton");
00177 
00178   ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00179                      *ACE_Static_Object_Lock::instance ()));
00180 
00181   if (ACE_Reactor::delete_reactor_)
00182     {
00183       delete ACE_Reactor::reactor_;
00184       ACE_Reactor::reactor_ = 0;
00185       ACE_Reactor::delete_reactor_ = false;
00186     }
00187 }

ACE_INLINE int ACE_Reactor::current_info ( ACE_HANDLE  handle,
size_t &  msg_size 
)

Returns 0, if the size of the current message has been put in size returns -1, if not. ACE_HANDLE allows the reactor to check if the caller is valid. Used for CLASSIX Reactor implementation.

Definition at line 139 of file Reactor.inl.

References ACE_Reactor_Impl::current_info(), and implementation().

00140 {
00141   return this->implementation ()->current_info (handle, size);
00142 }

const ACE_TCHAR * ACE_Reactor::dll_name ( void   )  [static]

Name of the dll in which the dll lives.

Definition at line 190 of file Reactor.cpp.

References ACE_TEXT.

00191 {
00192   return ACE_TEXT ("ACE");
00193 }

ACE_INLINE void ACE_Reactor::dump ( void   )  const

Dump the state of the object.

Definition at line 489 of file Reactor.inl.

References ACE_TRACE, ACE_Reactor_Impl::dump(), and implementation_.

00490 {
00491 #if defined (ACE_HAS_DUMP)
00492   ACE_TRACE ("ACE_Reactor::dump");
00493 
00494   implementation_->dump ();
00495 #endif /* ACE_HAS_DUMP */
00496 }

ACE_INLINE int ACE_Reactor::end_event_loop ( void   )  [static]

Instruct the <ACE_Reactor::instance> to terminate its event loop and notifies the <ACE_Reactor::instance> so that it can wake up and close down gracefully. Note that this method can only be used by the singleton <ACE_Reactor::instance>. Thus, to terminate another reactor, use <ACE_Reactor::end_reactor_event_loop>.

Deprecated:
Use ACE_Reactor::instance()->end_reactor_event_loop() instead

Definition at line 87 of file Reactor.inl.

References ACE_TRACE, end_reactor_event_loop(), and instance().

00088 {
00089   ACE_TRACE ("ACE_Reactor::end_event_loop");
00090   ACE_Reactor::instance ()->end_reactor_event_loop ();
00091 
00092   return 0;
00093 }

ACE_INLINE int ACE_Reactor::end_reactor_event_loop ( void   ) 

Instruct the Reactor to terminate its event loop and notifies the Reactor so that it can wake up and deactivate itself. Deactivating the Reactor would allow the Reactor to be shutdown gracefully. Internally the Reactor calls deactivate () on the underlying implementation. Any queued notifications remain queued on return from this method. If the event loop is restarted in the future, the notifications will be dispatched then. If the reactor is closed or deleted without further dispatching, the notifications will be lost.

Definition at line 103 of file Reactor.inl.

References ACE_TRACE, ACE_Reactor_Impl::deactivate(), and implementation_.

Referenced by end_event_loop(), and ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_signal().

00104 {
00105   ACE_TRACE ("ACE_Reactor::end_reactor_event_loop");
00106 
00107   this->implementation_->deactivate (1);
00108 
00109   return 0;
00110 }

ACE_INLINE int ACE_Reactor::event_loop_done ( void   )  [static]

Report if the <ACE_Reactor::instance>'s event loop is finished. Note that this method can only be used by the singleton <ACE_Reactor::instance>. Thus, to check another reactor use <ACE_Reactor::reactor_event_loop_done>.

Deprecated:
Use ACE_Reactor::instance()->reactor_event_loop_done() instead

Definition at line 96 of file Reactor.inl.

References ACE_TRACE, instance(), and reactor_event_loop_done().

00097 {
00098   ACE_TRACE ("ACE_Reactor::event_loop_done");
00099   return ACE_Reactor::instance ()->reactor_event_loop_done ();
00100 }

ACE_INLINE ACE_Event_Handler * ACE_Reactor::find_handler ( ACE_HANDLE  handle  ) 

Return the Event_Handler associated with handle. Return 0 if handle is not registered.

Reactor will call ACE_Event_Handler::add_reference() on the handler before returning it.

Definition at line 363 of file Reactor.inl.

References ACE_Reactor_Impl::find_handler(), and implementation().

Referenced by ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::cancel(), and ACE_Connector< SVC_HANDLER, ACE_PEER_CONNECTOR_2 >::close().

00364 {
00365   return this->implementation ()->find_handler (handle);
00366 }

ACE_INLINE int ACE_Reactor::handle_events ( ACE_Time_Value max_wait_time  ) 

This method is just like the one above, except the max_wait_time value is a reference and can therefore never be NULL.

The only difference between <alertable_handle_events> and <handle_events> is that in the alertable case, the eventloop will return when the system queues an I/O completion routine or an Asynchronous Procedure Call.

Definition at line 198 of file Reactor.inl.

References ACE_Reactor_Impl::handle_events(), and implementation().

00199 {
00200   return this->implementation ()->handle_events (max_wait_time);
00201 }

ACE_INLINE int ACE_Reactor::handle_events ( ACE_Time_Value max_wait_time = 0  ) 

This event loop driver blocks for up to max_wait_time before returning. It will return earlier if events occur. Note that max_wait_time can be 0, in which case this method blocks indefinitely until events occur.

max_wait_time is decremented to reflect how much time this call took. For instance, if a time value of 3 seconds is passed to handle_events and an event occurs after 2 seconds, max_wait_time will equal 1 second. This can be used if an application wishes to handle events for some fixed amount of time.

Returns the total number of timers and I/O ACE_Event_Handlers that were dispatched, 0 if the max_wait_time elapsed without dispatching any handlers, or -1 if an error occurs.

The only difference between <alertable_handle_events> and <handle_events> is that in the alertable case, the eventloop will return when the system queues an I/O completion routine or an Asynchronous Procedure Call.

Definition at line 186 of file Reactor.inl.

References ACE_Reactor_Impl::handle_events(), and implementation().

00187 {
00188   return this->implementation ()->handle_events (max_wait_time);
00189 }

ACE_INLINE int ACE_Reactor::handler ( int  signum,
ACE_Event_Handler **  event_handler = 0 
)

Check to see if signum is associated with a valid Event_Handler bound to a signal. Return the event_handler associated with this handler if event_handler != 0.

Definition at line 377 of file Reactor.inl.

References ACE_Reactor_Impl::handler(), and implementation().

00379 {
00380   return this->implementation ()->handler (signum, event_handler);
00381 }

ACE_INLINE int ACE_Reactor::handler ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
ACE_Event_Handler **  event_handler = 0 
)

Check to see if handle is associated with a valid Event_Handler bound to mask. Return the event_handler associated with this handler if event_handler != 0.

Reactor will call ACE_Event_Handler::add_reference() on the handler before returning it if event_handler != 0.

Definition at line 369 of file Reactor.inl.

References ACE_Reactor_Impl::handler(), and implementation().

00372 {
00373   return this->implementation ()->handler (handle, mask, event_handler);
00374 }

ACE_INLINE void ACE_Reactor::implementation ( ACE_Reactor_Impl implementation  )  [protected]

Set the implementation class.

Definition at line 133 of file Reactor.inl.

References implementation_.

00134 {
00135   this->implementation_ = impl;
00136 }

ACE_INLINE ACE_Reactor_Impl * ACE_Reactor::implementation ( void   )  const

Get the implementation class.

Definition at line 127 of file Reactor.inl.

References implementation_.

Referenced by alertable_handle_events(), cancel_timer(), cancel_wakeup(), close(), current_info(), find_handler(), handle_events(), handler(), initialized(), lock(), mask_ops(), max_notify_iterations(), notify(), open(), owner(), purge_pending_notifications(), ready_ops(), register_handler(), remove_handler(), requeue_position(), restart(), resumable_handler(), resume_handler(), resume_handlers(), schedule_timer(), schedule_wakeup(), set_sig_handler(), size(), suspend_handler(), suspend_handlers(), timer_queue(), uses_event_associations(), wakeup_all_threads(), work_pending(), and ~ACE_Reactor().

00128 {
00129   return this->implementation_;
00130 }

ACE_INLINE int ACE_Reactor::initialized ( void   ) 

Returns true if Reactor has been successfully initialized, else false.

Definition at line 384 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::initialized().

00385 {
00386   return this->implementation ()->initialized ();
00387 }

ACE_Reactor * ACE_Reactor::instance ( ACE_Reactor ,
bool  delete_reactor = false 
) [static]

Set pointer to a process-wide ACE_Reactor and return existing pointer. If delete_reactor == true then we'll delete the Reactor at destruction time.

Definition at line 153 of file Reactor.cpp.

References ACE_GUARD_RETURN, ACE_REGISTER_FRAMEWORK_COMPONENT, ACE_TRACE, delete_reactor_, and reactor_.

00154 {
00155   ACE_TRACE ("ACE_Reactor::instance");
00156 
00157   ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00158                             *ACE_Static_Object_Lock::instance (), 0));
00159   ACE_Reactor *t = ACE_Reactor::reactor_;
00160   ACE_Reactor::delete_reactor_ = delete_reactor;
00161 
00162   ACE_Reactor::reactor_ = r;
00163 
00164   // We can't register the Reactor singleton as a framework component twice.
00165   // Therefore we test to see if we had an existing reactor instance, which
00166   // if so means it must have already been registered.
00167   if (t == 0)
00168     ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Reactor, ACE_Reactor::reactor_);
00169 
00170   return t;
00171 }

ACE_Reactor * ACE_Reactor::instance ( void   )  [static]

Get pointer to a process-wide ACE_Reactor.

Definition at line 130 of file Reactor.cpp.

References ACE_GUARD_RETURN, ACE_NEW_RETURN, ACE_REGISTER_FRAMEWORK_COMPONENT, ACE_TRACE, delete_reactor_, and reactor_.

Referenced by ACE_Schedule_All_Reactive_Strategy< SVC_HANDLER >::ACE_Schedule_All_Reactive_Strategy(), end_event_loop(), event_loop_done(), ACE_Service_Manager::fini(), ACE_Service_Manager::handle_input(), ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_signal(), ACE_Service_Manager::init(), ACE_Logging_Strategy::init(), ACE_Service_Config::open_i(), ACE_Service_Config::parse_args_i(), reset_event_loop(), ACE_Service_Manager::resume(), run_alertable_event_loop(), run_event_loop(), ACE_Service_Manager::suspend(), and ACE::Monitor_Control::Monitor_Admin::~Monitor_Admin().

00131 {
00132   ACE_TRACE ("ACE_Reactor::instance");
00133 
00134   if (ACE_Reactor::reactor_ == 0)
00135     {
00136       // Perform Double-Checked Locking Optimization.
00137       ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00138                                 *ACE_Static_Object_Lock::instance (), 0));
00139 
00140       if (ACE_Reactor::reactor_ == 0)
00141         {
00142           ACE_NEW_RETURN (ACE_Reactor::reactor_,
00143                           ACE_Reactor,
00144                           0);
00145           ACE_Reactor::delete_reactor_ = true;
00146           ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Reactor, ACE_Reactor::reactor_)
00147         }
00148     }
00149   return ACE_Reactor::reactor_;
00150 }

ACE_INLINE ACE_Lock & ACE_Reactor::lock ( void   ) 

Returns a reference to the Reactor's internal lock.

Definition at line 390 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::lock().

00391 {
00392   return this->implementation ()->lock ();
00393 }

ACE_INLINE int ACE_Reactor::mask_ops ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
int  ops 
)

GET/SET/ADD/CLR the dispatch MASK "bit" bound with the handle and mask.

Definition at line 446 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::mask_ops().

00449 {
00450   return this->implementation ()->mask_ops (handle, mask, ops);
00451 }

ACE_INLINE int ACE_Reactor::mask_ops ( ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask,
int  ops 
)

GET/SET/ADD/CLR the dispatch mask "bit" bound with the event_handler and mask.

Definition at line 438 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::mask_ops().

00441 {
00442   return this->implementation ()->mask_ops (event_handler, mask, ops);
00443 }

ACE_INLINE int ACE_Reactor::max_notify_iterations ( void   ) 

Get the maximum number of times that the ACE_Reactor will iterate and dispatch the ACE_Event_Handler's that are passed in via the notify queue before breaking out of its <ACE_Message_Queue::dequeue> loop.

Definition at line 350 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::max_notify_iterations().

00351 {
00352   return this->implementation ()->max_notify_iterations ();
00353 }

ACE_INLINE void ACE_Reactor::max_notify_iterations ( int  iterations  ) 

Set the maximum number of times that ACE_Reactor will iterate and dispatch the ACE_Event_Handlers that are passed in via the notify queue before breaking out of its <ACE_Message_Queue::dequeue> loop. By default, this is set to -1, which means "iterate until the queue is empty." Setting this to a value like "1 or 2" will increase "fairness" (and thus prevent starvation) at the expense of slightly higher dispatching overhead.

Definition at line 344 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::max_notify_iterations().

00345 {
00346   this->implementation ()->max_notify_iterations (iterations);
00347 }

const ACE_TCHAR * ACE_Reactor::name ( void   )  [static]

Name of the component--ACE_Reactor in this case.

Definition at line 196 of file Reactor.cpp.

References ACE_TEXT.

00197 {
00198   return ACE_TEXT ("ACE_Reactor");
00199 }

int ACE_Reactor::notify ( ACE_Event_Handler event_handler = 0,
ACE_Reactor_Mask  masks = ACE_Event_Handler::EXCEPT_MASK,
ACE_Time_Value timeout = 0 
)

Dispatch user specified events.

Handler will be dispatched irrespective of whether it is registered, not registered, or suspended in the Reactor.

If user specified event is successfully queued, ACE_Event_Handler::add_reference() will be called. After the notify occurs and the upcall to the handler completes, the handler will be implicitly removed from the Reactor and ACE_Event_Handler::remove_reference() will be called. No other upcall reference counting is done.

For I/O or OS events, the upcall is invoked with an ACE_INVALID_HANDLE.

For timer events, the upcall is invoked with a null ACT.

Parameters:
event_handler,: IN - Handler on which the event will be dispatched.
masks,: IN - Events to be dispatched - multiple events can be OR'd together.
timeout,: INOUT - Relative time up to which to wait for user specified event to be queued. If tv is 0, wait indefinitely. When the call returns, tv has the time remaining after the call completes.

Definition at line 473 of file Reactor.cpp.

References implementation(), ACE_Reactor_Impl::notify(), and ACE_Event_Handler::reactor().

Referenced by ACE_Process_Manager::handle_signal(), and ACE_Reactor_Notification_Strategy::notify().

00476 {
00477   // First, try to remember this reactor in the event handler, in case
00478   // the event handler goes away before the notification is delivered.
00479   if (event_handler != 0 && event_handler->reactor () == 0)
00480     event_handler->reactor (this);
00481   return this->implementation ()->notify (event_handler, mask, tv);
00482 }

ACE_INLINE int ACE_Reactor::open ( size_t  max_number_of_handles,
int  restart = 0,
ACE_Sig_Handler signal_handler = 0,
ACE_Timer_Queue timer_queue = 0 
)

Initialize the ACE_Reactor to manage <max_number_of_handles>. If <restart> is non-0 then the ACE_Reactor's <handle_events> method will be restarted automatically when <EINTR> occurs. If <signal_handler> or <timer_queue> are non-0 they are used as the signal handler and timer queue, respectively.

Definition at line 145 of file Reactor.inl.

References implementation(), ACE_Reactor_Impl::open(), and timer_queue().

00149 {
00150   return this->implementation ()->open (size,
00151                                         restart,
00152                                         signal_handler,
00153                                         timer_queue);
00154 }

ACE_Reactor& ACE_Reactor::operator= ( const ACE_Reactor  )  [protected]

ACE_INLINE int ACE_Reactor::owner ( ACE_thread_t owner  ) 

Return the ID of the "owner" thread.

Definition at line 408 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::owner().

00409 {
00410   return this->implementation ()->owner (owner);
00411 }

ACE_INLINE int ACE_Reactor::owner ( ACE_thread_t  new_owner,
ACE_thread_t old_owner = 0 
)

Transfers ownership of Reactor to the new_owner.

Definition at line 402 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::owner().

Referenced by ACE_Asynch_Pseudo_Task::svc().

00403 {
00404   return this->implementation ()->owner (new_owner,  old_owner);
00405 }

ACE_INLINE int ACE_Reactor::purge_pending_notifications ( ACE_Event_Handler eh,
ACE_Reactor_Mask  = ACE_Event_Handler::ALL_EVENTS_MASK 
)

Purge any notifications pending in this reactor for the specified ACE_Event_Handler object. If eh == 0, all notifications for all handlers are removed (but not any notifications posted just to wake up the reactor itself). Returns the number of notifications purged. Returns -1 on error.

After the purging occurs, the handler will be implicitly removed from the Reactor and ACE_Event_Handler::remove_reference() will be called.

Definition at line 356 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::purge_pending_notifications().

00358 {
00359   return this->implementation ()->purge_pending_notifications (eh, mask);
00360 }

ACE_INLINE int ACE_Reactor::reactor_event_loop_done ( void   ) 

Indicate if the Reactor's event loop has been ended.

Definition at line 470 of file Reactor.inl.

References ACE_TRACE, ACE_Reactor_Impl::deactivated(), and implementation_.

Referenced by event_loop_done().

00471 {
00472   ACE_TRACE ("ACE_Reactor::reactor_event_loop_done");
00473   return this->implementation_->deactivated ();
00474 }

ACE_INLINE int ACE_Reactor::ready_ops ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
int  ops 
)

GET/SET/ADD/CLR the ready "bit" bound with the <handle> and mask.

Definition at line 462 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::ready_ops().

00465 {
00466   return this->implementation ()->ready_ops (handle, mask, ops);
00467 }

ACE_INLINE int ACE_Reactor::ready_ops ( ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask,
int  ops 
)

GET/SET/ADD/CLR the ready "bit" bound with the event_handler and mask.

Definition at line 454 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::ready_ops().

00457 {
00458   return this->implementation ()->ready_ops (event_handler, mask, ops);
00459 }

ACE_INLINE int ACE_Reactor::register_handler ( const ACE_Sig_Set sigset,
ACE_Event_Handler event_handler,
ACE_Sig_Action sig_action = 0 
)

Register handler for multiple signals.

Shorthand for calling register_handler(int,ACE_Event_Handler*,ACE_Sig_Action*,ACE_Event_Handler**,ACE_Sig_Action*) multiple times for the same event_handler and sig_action but different <signals>.

Definition at line 224 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::register_handler().

00227 {
00228   return this->implementation ()->register_handler (sigset,
00229                                                     new_sh,
00230                                                     new_disp);
00231 }

ACE_INLINE int ACE_Reactor::register_handler ( int  signum,
ACE_Event_Handler new_sh,
ACE_Sig_Action new_disp = 0,
ACE_Event_Handler **  old_sh = 0,
ACE_Sig_Action old_disp = 0 
)

Register handler for signals.

Register new_sh to handle the signal signum using the new_disp. Returns the old_sh that was previously registered (if any), along with the old_disp of the signal handler.

Reactor will call ACE_Event_Handler::add_reference() on new_sh and ACE_Event_Handler::remove_reference() on old_sh.

Definition at line 210 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::register_handler().

00215 {
00216   return this->implementation ()->register_handler (signum,
00217                                                     new_sh,
00218                                                     new_disp,
00219                                                     old_sh,
00220                                                     old_disp);
00221 }

int ACE_Reactor::register_handler ( const ACE_Handle_Set handles,
ACE_Event_Handler event_handler,
ACE_Reactor_Mask  masks 
)

Register handler for multiple I/O events.

Shorthand for calling register_handler(ACE_HANDLE,ACE_Event_Handler*,ACE_Reactor_Mask), multiple times for the same event_handler and masks but different <handles>.

Definition at line 410 of file Reactor.cpp.

References implementation(), ACE_Event_Handler::reactor(), and ACE_Reactor_Impl::register_handler().

00413 {
00414   // Remember the old reactor.
00415   ACE_Reactor *old_reactor = event_handler->reactor ();
00416 
00417   // Assign *this* <Reactor> to the <Event_Handler>.
00418   event_handler->reactor (this);
00419 
00420   int result = this->implementation ()->register_handler (handles,
00421                                                           event_handler,
00422                                                           mask);
00423   if (result == -1)
00424     // Reset the old reactor in case of failures.
00425     event_handler->reactor (old_reactor);
00426 
00427   return result;
00428 }

int ACE_Reactor::register_handler ( ACE_HANDLE  event_handle,
ACE_HANDLE  io_handle,
ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask 
)

Register handler for I/O events.

Similar to register_handler(ACE_HANDLE,ACE_Event_Handler*,ACE_Reactor_Mask), except that the user gets to specify the event handle that will be used for this registration. This only applies to Reactors that use event handles for I/O registrations.

Definition at line 387 of file Reactor.cpp.

References implementation(), ACE_Event_Handler::reactor(), and ACE_Reactor_Impl::register_handler().

00391 {
00392   // Remember the old reactor.
00393   ACE_Reactor *old_reactor = event_handler->reactor ();
00394 
00395   // Assign *this* <Reactor> to the <Event_Handler>.
00396   event_handler->reactor (this);
00397 
00398   int result = this->implementation ()->register_handler (event_handle,
00399                                                           io_handle,
00400                                                           event_handler,
00401                                                           mask);
00402   if (result == -1)
00403     // Reset the old reactor in case of failures.
00404     event_handler->reactor (old_reactor);
00405 
00406   return result;
00407 }

int ACE_Reactor::register_handler ( ACE_HANDLE  io_handle,
ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask 
)

Register handler for I/O events.

Same as register_handler(ACE_Event_Handler*,ACE_Reactor_Mask), except handle is explicitly specified.

Definition at line 343 of file Reactor.cpp.

References implementation(), ACE_Event_Handler::reactor(), and ACE_Reactor_Impl::register_handler().

00346 {
00347   // Remember the old reactor.
00348   ACE_Reactor *old_reactor = event_handler->reactor ();
00349 
00350   // Assign *this* <Reactor> to the <Event_Handler>.
00351   event_handler->reactor (this);
00352 
00353   int result = this->implementation ()->register_handler (io_handle,
00354                                                           event_handler,
00355                                                           mask);
00356   if (result == -1)
00357     // Reset the old reactor in case of failures.
00358     event_handler->reactor (old_reactor);
00359 
00360   return result;
00361 }

int ACE_Reactor::register_handler ( ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask 
)

Register handler for I/O events.

A handler can be associated with multiple handles. A handle cannot be associated with multiple handlers.

The handle will come from ACE_Event_Handler::get_handle().

Reactor will call ACE_Event_Handler::add_reference() for a new handler/handle pair.

If this handler/handle pair has already been registered, any new masks specified will be added. In this case, ACE_Event_Handler::add_reference() will not be called.

If the registered handler is currently suspended, it will remain suspended. When the handler is resumed, it will have the existing masks plus any masks added through this call. Handlers do not have partial suspensions.

Definition at line 325 of file Reactor.cpp.

References implementation(), ACE_Event_Handler::reactor(), and ACE_Reactor_Impl::register_handler().

Referenced by ACE_Process_Manager::append_proc(), ACE_Service_Manager::handle_input(), ACE_Svc_Handler<, >::open(), ACE_Strategy_Acceptor< SVC_HANDLER, >::open(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::open(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::register_handler(), and ACE_Event_Handler::register_stdin_handler().

00327 {
00328   // Remember the old reactor.
00329   ACE_Reactor *old_reactor = event_handler->reactor ();
00330 
00331   // Assign *this* <Reactor> to the <Event_Handler>.
00332   event_handler->reactor (this);
00333 
00334   int result = this->implementation ()->register_handler (event_handler, mask);
00335   if (result == -1)
00336     // Reset the old reactor in case of failures.
00337     event_handler->reactor (old_reactor);
00338 
00339   return result;
00340 }

ACE_INLINE int ACE_Reactor::remove_handler ( const ACE_Sig_Set sigset  ) 

Remove multiple signal handler registrations.

Shorthand for calling remove_handler(int,ACE_Sig_Action*,ACE_Sig_Action*,int) multiple times for every signal in sigset.

Definition at line 267 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::remove_handler().

00268 {
00269   return this->implementation ()->remove_handler (sigset);
00270 }

ACE_INLINE int ACE_Reactor::remove_handler ( int  signum,
ACE_Sig_Action new_disp,
ACE_Sig_Action old_disp = 0,
int  sigkey = -1 
)

Remove signal handler registration.

Remove the ACE_Event_Handler currently associated with signum. Install the new disposition (if given) and return the previous disposition (if desired by the caller).

ACE_Event_Handler::handle_close() will be called with ACE_Event_Handler::SIGNAL_MASK. ACE_Event_Handler::remove_reference() will also be called.

Definition at line 255 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::remove_handler().

00259 {
00260   return this->implementation ()->remove_handler (signum,
00261                                                   new_disp,
00262                                                   old_disp,
00263                                                   sigkey);
00264 }

ACE_INLINE int ACE_Reactor::remove_handler ( const ACE_Handle_Set handles,
ACE_Reactor_Mask  masks 
)

Remove masks from multiple <handle> registrations.

Shorthand for calling remove_handler(ACE_HANDLE,ACE_Reactor_Mask) multiple times for the same masks but different handles.

Definition at line 248 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::remove_handler().

00250 {
00251   return this->implementation ()->remove_handler (handle_set, mask);
00252 }

ACE_INLINE int ACE_Reactor::remove_handler ( ACE_Event_Handler event_handler,
ACE_Reactor_Mask  masks 
)

Remove masks from event_handler registration.

Same as remove_handler(ACE_HANDLE,ACE_Reactor_Mask), except handle comes from ACE_Event_Handler::get_handle().

Definition at line 234 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::remove_handler().

00236 {
00237   return this->implementation ()->remove_handler (event_handler, mask);
00238 }

ACE_INLINE int ACE_Reactor::remove_handler ( ACE_HANDLE  handle,
ACE_Reactor_Mask  masks 
)

Remove masks from handle registration.

For I/O handles, masks are removed from the Reactor. Unless masks includes ACE_Event_Handler::DONT_CALL, ACE_Event_Handler::handle_close() will be called with the masks that have been removed. If all masks have been removed, ACE_Event_Handler::remove_reference() will be called.

For OS handles, the handle is removed from the Reactor. Unless masks includes ACE_Event_Handler::DONT_CALL, ACE_Event_Handler::handle_close() will be called with ACE_Event_Handler::NULL_MASK. ACE_Event_Handler::remove_reference() will also be called.

Definition at line 241 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::remove_handler().

Referenced by ACE_Process_Manager::close(), ACE_Service_Manager::fini(), ACE_Strategy_Acceptor< SVC_HANDLER, >::handle_close(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::handle_close(), ACE_Asynch_Pseudo_Task::register_io_handler(), ACE_Asynch_Pseudo_Task::remove_io_handler(), ACE_Process_Manager::remove_proc(), and ACE_Event_Handler::remove_stdin_handler().

00243 {
00244   return this->implementation ()->remove_handler (handle, mask);
00245 }

ACE_INLINE int ACE_Reactor::requeue_position ( void   ) 

Get position of the owner thread.

Definition at line 432 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::requeue_position().

00433 {
00434   return this->implementation ()->requeue_position ();
00435 }

ACE_INLINE void ACE_Reactor::requeue_position ( int  position  ) 

Set position of the owner thread.

Definition at line 426 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::requeue_position().

00427 {
00428   this->implementation ()->requeue_position (position);
00429 }

ACE_INLINE void ACE_Reactor::reset_event_loop ( void   )  [static]

Resets the <ACE_Reactor::end_event_loop_> static so that the <run_event_loop> method can be restarted. Note that this method can only be used by the singleton <ACE_Reactor::instance>. Thus, to reset another reactor use <ACE_Reactor::reset_reactor_event_loop>.

Deprecated:
Use ACE_Reactor::instance()->reset_reactor_event_loop() instead

Definition at line 79 of file Reactor.inl.

References ACE_TRACE, instance(), and reset_reactor_event_loop().

00080 {
00081   ACE_TRACE ("ACE_Reactor::reset_event_loop");
00082 
00083   ACE_Reactor::instance ()->reset_reactor_event_loop ();
00084 }

ACE_INLINE void ACE_Reactor::reset_reactor_event_loop ( void   ) 

Resets the <ACE_Reactor::end_event_loop_> static so that the <run_event_loop> method can be restarted.

Definition at line 113 of file Reactor.inl.

References ACE_TRACE, ACE_Reactor_Impl::deactivate(), and implementation_.

Referenced by reset_event_loop().

00114 {
00115   ACE_TRACE ("ACE_Reactor::reset_reactor_event_loop");
00116 
00117   this->implementation_->deactivate (0);
00118 }

int ACE_Reactor::reset_timer_interval ( long  timer_id,
const ACE_Time_Value interval 
) [virtual]

Reset recurring timer interval.

Resets the interval of the timer represented by timer_id to interval, which is specified in relative time to the current <gettimeofday>. If interval is equal to ACE_Time_Value::zero, the timer will become a non-rescheduling timer. Returns 0 if successful, -1 if not.

This change will not take effect until the next timeout.

Implements ACE_Reactor_Timer_Interface.

Definition at line 486 of file Reactor.cpp.

References ACE_TRACE.

00488 {
00489   ACE_TRACE ("ACE_Reactor::reset_timer_interval");
00490 
00491   return this->implementation ()->reset_timer_interval (timer_id, interval);
00492 }

ACE_INLINE int ACE_Reactor::restart ( int  r  ) 

Set a new value for restart and return the original value.

Definition at line 420 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::restart().

00421 {
00422   return this->implementation ()->restart (r);
00423 }

ACE_INLINE int ACE_Reactor::restart ( void   ) 

Get the existing restart value.

Definition at line 414 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::restart().

00415 {
00416   return this->implementation ()->restart ();
00417 }

ACE_INLINE int ACE_Reactor::resumable_handler ( void   ) 

Does the reactor allow the application to resume the handle on its own ie. can it pass on the control of handle resumption to the application. A positive value indicates that the handlers are application resumable. A value of 0 indicates otherwise.

Definition at line 121 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::resumable_handler().

00122 {
00123   return this->implementation ()->resumable_handler ();
00124 }

ACE_INLINE int ACE_Reactor::resume_handler ( const ACE_Handle_Set handles  ) 

Resume handles.

Shorthand for calling resume_handler(ACE_HANDLE) with multiple <handles>.

Definition at line 309 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::resume_handler().

00310 {
00311   return this->implementation ()->resume_handler (handles);
00312 }

ACE_INLINE int ACE_Reactor::resume_handler ( ACE_Event_Handler event_handler  ) 

Resume event_handler.

Handle is obtained from ACE_Event_Handler::get_handle().

Definition at line 297 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::resume_handler().

00298 {
00299   return this->implementation ()->resume_handler (event_handler);
00300 }

ACE_INLINE int ACE_Reactor::resume_handler ( ACE_HANDLE  handle  ) 

Resume handle.

Definition at line 303 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::resume_handler().

Referenced by ACE_Service_Manager::resume(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::resume(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::resume(), and ACE_Asynch_Pseudo_Task::resume_io_handler().

00304 {
00305   return this->implementation ()->resume_handler (handle);
00306 }

ACE_INLINE int ACE_Reactor::resume_handlers ( void   ) 

Resume all registered handles.

Definition at line 315 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::resume_handlers().

Referenced by ACE_Schedule_All_Reactive_Strategy< SVC_HANDLER >::resume().

00316 {
00317   return this->implementation ()->resume_handlers ();
00318 }

ACE_INLINE int ACE_Reactor::run_alertable_event_loop ( ACE_Time_Value tv  )  [static]

Definition at line 66 of file Reactor.inl.

References ACE_TRACE, check_reconfiguration(), instance(), and run_alertable_reactor_event_loop().

00067 {
00068   ACE_TRACE ("ACE_Reactor::run_alertable_event_loop");
00069   ACE_Reactor *r = ACE_Reactor::instance ();
00070 
00071   if (r == 0)
00072     return -1;
00073 
00074   return r->run_alertable_reactor_event_loop
00075     (tv, ACE_Reactor::check_reconfiguration);
00076 }

ACE_INLINE int ACE_Reactor::run_alertable_event_loop ( void   )  [static]

Definition at line 50 of file Reactor.inl.

References ACE_TRACE, check_reconfiguration(), instance(), and run_alertable_reactor_event_loop().

00051 {
00052   ACE_TRACE ("ACE_Reactor::run_alertable_event_loop");
00053   ACE_Reactor *r = ACE_Reactor::instance ();
00054 
00055   if (r == 0)
00056     return -1;
00057 
00058   return r->run_alertable_reactor_event_loop (ACE_Reactor::check_reconfiguration);
00059 }

int ACE_Reactor::run_alertable_reactor_event_loop ( ACE_Time_Value tv,
REACTOR_EVENT_HOOK  = 0 
)

Definition at line 303 of file Reactor.cpp.

00305 {
00306   ACE_TRACE ("ACE_Reactor::run_alertable_reactor_event_loop");
00307 
00308   if (this->reactor_event_loop_done ())
00309     return 0;
00310 
00311   for (;;)
00312     {
00313       int result = this->implementation_->alertable_handle_events (tv);
00314 
00315       if (eh != 0 && (*eh)(this))
00316         continue;
00317       else if (result == -1 && this->implementation_->deactivated ())
00318         return 0;
00319       else if (result <= 0)
00320         return result;
00321     }
00322 }

int ACE_Reactor::run_alertable_reactor_event_loop ( REACTOR_EVENT_HOOK  = 0  ) 

Definition at line 238 of file Reactor.cpp.

References ACE_TRACE, ACE_Reactor_Impl::alertable_handle_events(), and implementation_.

Referenced by run_alertable_event_loop().

00239 {
00240   ACE_TRACE ("ACE_Reactor::run_alertable_reactor_event_loop");
00241 
00242   if (this->reactor_event_loop_done ())
00243     return 0;
00244 
00245   while (1)
00246     {
00247       int const result = this->implementation_->alertable_handle_events ();
00248 
00249       if (eh != 0 && (*eh)(this))
00250         continue;
00251       else if (result == -1 && this->implementation_->deactivated ())
00252         return 0;
00253       else if (result == -1)
00254         return -1;
00255     }
00256 
00257   ACE_NOTREACHED (return 0;)
00258 }

ACE_INLINE int ACE_Reactor::run_event_loop ( ACE_Time_Value tv  )  [static]

Run the event loop until the <ACE_Reactor::handle_events> or <ACE_Reactor::alertable_handle_events> methods returns -1, the <end_event_loop> method is invoked, or the ACE_Time_Value expires. Note that this method can only be used by the singleton <ACE_Reactor::instance>. Thus, to run another reactor use <ACE_Reactor::run_reactor_event_loop>.

Deprecated:
Use ACE_Reactor::instance()->run_reactor_event_loop() instead

Definition at line 34 of file Reactor.inl.

References ACE_TRACE, check_reconfiguration(), instance(), and run_reactor_event_loop().

00035 {
00036   ACE_TRACE ("ACE_Reactor::run_event_loop");
00037   ACE_Reactor *r = ACE_Reactor::instance ();
00038 
00039   if (r == 0)
00040     return -1;
00041 
00042   return r->run_reactor_event_loop
00043     (tv, ACE_Reactor::check_reconfiguration);
00044 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE int ACE_Reactor::run_event_loop ( void   )  [static]

Run the event loop until the <ACE_Reactor::handle_events/ACE_Reactoralertable_handle_events> method returns -1 or the <end_event_loop> method is invoked. Note that this method can only be used by the singleton <ACE_Reactor::instance>. Thus, to run another reactor use <ACE_Reactor::run_reactor_event_loop>.

Deprecated:
Use ACE_Reactor::instance()->run_reactor_event_loop() instead

Definition at line 18 of file Reactor.inl.

References ACE_TRACE, check_reconfiguration(), instance(), and run_reactor_event_loop().

00019 {
00020   ACE_TRACE ("ACE_Reactor::run_event_loop");
00021   ACE_Reactor *r = ACE_Reactor::instance ();
00022 
00023   if (r == 0)
00024     return -1;
00025 
00026   return r->run_reactor_event_loop (ACE_Reactor::check_reconfiguration);
00027 }

int ACE_Reactor::run_reactor_event_loop ( ACE_Time_Value tv,
REACTOR_EVENT_HOOK  = 0 
)

Run the event loop until the <ACE_Reactor::handle_events> or <ACE_Reactor::alertable_handle_events> methods returns -1, the <end_reactor_event_loop> method is invoked, or the ACE_Time_Value expires.

Definition at line 261 of file Reactor.cpp.

References ACE_Reactor_Impl::handle_events(), and implementation_.

00263 {
00264   ACE_TRACE ("ACE_Reactor::run_reactor_event_loop");
00265 
00266   if (this->reactor_event_loop_done ())
00267     return 0;
00268 
00269   while (1)
00270     {
00271       int result = this->implementation_->handle_events (tv);
00272 
00273       if (eh != 0 && (*eh) (this))
00274         continue;
00275       else if (result == -1)
00276         {
00277           if (this->implementation_->deactivated ())
00278             result = 0;
00279           return result;
00280         }
00281       else if (result == 0)
00282         {
00283           // The <handle_events> method timed out without dispatching
00284           // anything.  Because of rounding and conversion errors and
00285           // such, it could be that the wait loop (WFMO, select, etc.)
00286           // timed out, but the timer queue said it wasn't quite ready
00287           // to expire a timer. In this case, the ACE_Time_Value we
00288           // passed into handle_events won't have quite been reduced
00289           // to 0, and we need to go around again. If we are all the
00290           // way to 0, just return, as the entire time the caller
00291           // wanted to wait has been used up.
00292           if (tv.usec () > 0)
00293             continue;
00294           return 0;
00295         }
00296       // Else there were some events dispatched; go around again
00297     }
00298 
00299   ACE_NOTREACHED (return 0;)
00300 }

int ACE_Reactor::run_reactor_event_loop ( REACTOR_EVENT_HOOK  = 0  ) 

Run the event loop until the <ACE_Reactor::handle_events/ACE_Reactoralertable_handle_events> method returns -1 or the <end_reactor_event_loop> method is invoked.

Definition at line 215 of file Reactor.cpp.

References ACE_TRACE, ACE_Reactor_Impl::handle_events(), and implementation_.

Referenced by run_event_loop(), and ACE_Asynch_Pseudo_Task::svc().

00216 {
00217   ACE_TRACE ("ACE_Reactor::run_reactor_event_loop");
00218 
00219   if (this->reactor_event_loop_done ())
00220     return 0;
00221 
00222   while (1)
00223     {
00224       int const result = this->implementation_->handle_events ();
00225 
00226       if (eh != 0 && (*eh)(this))
00227         continue;
00228       else if (result == -1 && this->implementation_->deactivated ())
00229         return 0;
00230       else if (result == -1)
00231         return -1;
00232     }
00233 
00234   ACE_NOTREACHED (return 0;)
00235 }

long ACE_Reactor::schedule_timer ( ACE_Event_Handler event_handler,
const void *  arg,
const ACE_Time_Value delay,
const ACE_Time_Value interval = ACE_Time_Value::zero 
) [virtual]

Schedule a timer event.

Schedule a timer event that will expire after an <delay> amount of time. The return value of this method, a timer_id value, uniquely identifies the event_handler in the ACE_Reactor's internal list of timers. This timer_id value can be used to cancel the timer with the cancel_timer() call.

Reactor will call ACE_Event_Handler::add_reference() on the handler. After the timeout occurs and ACE_Event_Handler::handle_timeout() has completed, the handler will be implicitly removed from the Reactor and ACE_Event_Handler::remove_reference() will be called.

See also:
cancel_timer()

reset_timer_interval()

Parameters:
event_handler Event handler to schedule on reactor
arg Argument passed to the handle_timeout() method of event_handler
delay Time interval after which the timer will expire
interval Time interval after which the timer will be automatically rescheduled
Returns:
-1 on failure, a timer_id value on success

Implements ACE_Reactor_Timer_Interface.

Definition at line 431 of file Reactor.cpp.

References implementation(), ACE_Event_Handler::reactor(), and ACE_Reactor_Impl::schedule_timer().

Referenced by ACE::Monitor_Control::Monitor_Admin::auto_query(), ACE_Logging_Strategy::init(), and ACE::Monitor_Control::Monitor_Admin::monitor_point().

00435 {
00436   // Remember the old reactor.
00437   ACE_Reactor *old_reactor = event_handler->reactor ();
00438 
00439   // Assign *this* <Reactor> to the <Event_Handler>.
00440   event_handler->reactor (this);
00441 
00442   long result = this->implementation ()->schedule_timer (event_handler,
00443                                                          arg,
00444                                                          delta,
00445                                                          interval);
00446   if (result == -1)
00447     // Reset the old reactor in case of failures.
00448     event_handler->reactor (old_reactor);
00449 
00450   return result;
00451 }

ACE_INLINE int ACE_Reactor::schedule_wakeup ( ACE_HANDLE  handle,
ACE_Reactor_Mask  masks_to_be_added 
)

Add masks_to_be_added to the handle's entry. <event_handler> associated with handle must already have been registered. Note that this call does not cause the Reactor to re-examine its set of handlers - the new masks will be noticed the next time the Reactor waits for activity. If there is no other activity expected, or you need immediate re-examination of the wait masks, either call ACE_Reactor::notify after this call, or use ACE_Reactor::register_handler instead.

Definition at line 321 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::schedule_wakeup().

00323 {
00324   return implementation ()->schedule_wakeup (handle, masks_to_be_added);
00325 }

int ACE_Reactor::schedule_wakeup ( ACE_Event_Handler event_handler,
ACE_Reactor_Mask  masks_to_be_added 
)

Add masks_to_be_added to the event_handler's entry. event_handler must already have been registered. Note that this call does not cause the Reactor to re-examine its set of handlers - the new masks will be noticed the next time the Reactor waits for activity. If there is no other activity expected, or you need immediate re-examination of the wait masks, either call ACE_Reactor::notify after this call, or use ACE_Reactor::register_handler instead.

Definition at line 454 of file Reactor.cpp.

References implementation(), ACE_Event_Handler::reactor(), and ACE_Reactor_Impl::schedule_wakeup().

00456 {
00457   // Remember the old reactor.
00458   ACE_Reactor *old_reactor = event_handler->reactor ();
00459 
00460   // Assign *this* <Reactor> to the <Event_Handler>.
00461   event_handler->reactor (this);
00462 
00463   int result = this->implementation ()->schedule_wakeup (event_handler,
00464                                                          masks_to_be_added);
00465   if (result == -1)
00466     // Reset the old reactor in case of failures.
00467     event_handler->reactor (old_reactor);
00468 
00469   return result;
00470 }

ACE_INLINE int ACE_Reactor::set_sig_handler ( ACE_Sig_Handler signal_handler  ) 

Use a user specified signal handler instead.

Definition at line 156 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::set_sig_handler().

00157 {
00158   return this->implementation ()->set_sig_handler (signal_handler);
00159 }

ACE_INLINE size_t ACE_Reactor::size ( void   )  const

Returns the current size of the Reactor's internal descriptor table.

Definition at line 477 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::size().

00478 {
00479   return this->implementation ()->size ();
00480 }

ACE_INLINE int ACE_Reactor::suspend_handler ( const ACE_Handle_Set handles  ) 

Suspend handles temporarily.

Shorthand for calling suspend_handler(ACE_HANDLE) with multiple handles.

Definition at line 285 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::suspend_handler().

00286 {
00287   return this->implementation ()->suspend_handler (handles);
00288 }

ACE_INLINE int ACE_Reactor::suspend_handler ( ACE_Event_Handler event_handler  ) 

Suspend event_handler temporarily.

Handle is obtained from ACE_Event_Handler::get_handle().

Definition at line 273 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::suspend_handler().

00274 {
00275   return this->implementation ()->suspend_handler (event_handler);
00276 }

ACE_INLINE int ACE_Reactor::suspend_handler ( ACE_HANDLE  handle  ) 

Suspend handle temporarily.

Definition at line 279 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::suspend_handler().

Referenced by ACE_Service_Manager::suspend(), ACE_Oneshot_Acceptor< SVC_HANDLER, >::suspend(), ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::suspend(), and ACE_Asynch_Pseudo_Task::suspend_io_handler().

00280 {
00281   return this->implementation ()->suspend_handler (handle);
00282 }

ACE_INLINE int ACE_Reactor::suspend_handlers ( void   ) 

Suspend all registered handles temporarily.

Definition at line 291 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::suspend_handlers().

Referenced by ACE_Schedule_All_Reactive_Strategy< SVC_HANDLER >::suspend().

00292 {
00293   return this->implementation ()->suspend_handlers ();
00294 }

ACE_INLINE ACE_Timer_Queue * ACE_Reactor::timer_queue ( void   )  const

Return the current ACE_Timer_Queue.

Definition at line 168 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::timer_queue().

Referenced by open().

00169 {
00170   return this->implementation ()->timer_queue ();
00171 }

ACE_INLINE int ACE_Reactor::timer_queue ( ACE_Timer_Queue tq  ) 

Set a user-specified timer queue.

Definition at line 162 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::timer_queue().

00163 {
00164   return this->implementation ()->timer_queue (tq);
00165 }

ACE_INLINE int ACE_Reactor::uses_event_associations ( void   ) 

Return 1 if we any event associations were made by the reactor for the handles that it waits on, 0 otherwise.

Definition at line 483 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::uses_event_associations().

Referenced by ACE_Acceptor< SVC_HANDLER, ACE_PEER_ACCEPTOR_2 >::accept_svc_handler(), ACE_Service_Manager::handle_input(), and ACE_Oneshot_Acceptor< SVC_HANDLER, >::handle_input().

00484 {
00485   return this->implementation ()->uses_event_associations ();
00486 }

ACE_INLINE void ACE_Reactor::wakeup_all_threads ( void   ) 

Wake up all threads in waiting in the event loop.

Definition at line 396 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::wakeup_all_threads().

00397 {
00398   this->implementation ()->wakeup_all_threads ();
00399 }

ACE_INLINE int ACE_Reactor::work_pending ( const ACE_Time_Value max_wait_time = ACE_Time_Value::zero  ) 

Returns non-zero if there are I/O events "ready" for dispatching, but does not actually dispatch the event handlers. By default, don't block while checking this, i.e., "poll".

Definition at line 180 of file Reactor.inl.

References implementation(), and ACE_Reactor_Impl::work_pending().

00181 {
00182   return this->implementation ()->work_pending (max_wait_time);
00183 }


Member Data Documentation

ACE_Reactor::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Definition at line 838 of file Reactor.h.

bool ACE_Reactor::delete_implementation_ [protected]

Flag used to indicate whether we are responsible for cleaning up the implementation instance

Definition at line 853 of file Reactor.h.

bool ACE_Reactor::delete_reactor_ = false [static, protected]

Must delete the reactor_ singleton if true.

Definition at line 859 of file Reactor.h.

Referenced by close_singleton(), and instance().

ACE_Reactor_Impl* ACE_Reactor::implementation_ [protected]

Delegation/implementation class that all methods will be forwarded to.

Definition at line 849 of file Reactor.h.

Referenced by dump(), end_reactor_event_loop(), implementation(), reactor_event_loop_done(), reset_reactor_event_loop(), run_alertable_reactor_event_loop(), and run_reactor_event_loop().

ACE_Reactor * ACE_Reactor::reactor_ = 0 [static, protected]

Pointer to a process-wide ACE_Reactor singleton.

Definition at line 856 of file Reactor.h.

Referenced by close_singleton(), and instance().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:29 2010 for ACE by  doxygen 1.4.7