ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN > Class Template Reference

An object oriented event demultiplexor and event handler dispatcher. More...

#include <Select_Reactor_T.h>

Inheritance diagram for ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >:
Inheritance graph
[legend]
Collaboration diagram for ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ACE_Select_Reactor_T (ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, int disable_notify_pipe=ACE_DISABLE_NOTIFY_PIPE_DEFAULT, ACE_Reactor_Notify *notify=0, bool mask_signals=true, int s_queue=ACE_SELECT_TOKEN::FIFO)
 ACE_Select_Reactor_T (size_t size, bool restart=false, ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, int disable_notify_pipe=ACE_DISABLE_NOTIFY_PIPE_DEFAULT, ACE_Reactor_Notify *notify=0, bool mask_signals=true, int s_queue=ACE_SELECT_TOKEN::FIFO)
virtual int open (size_t max_number_of_handles=DEFAULT_SIZE, bool restart=false, ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, int disable_notify_pipe=ACE_DISABLE_NOTIFY_PIPE_DEFAULT, ACE_Reactor_Notify *=0)
virtual int current_info (ACE_HANDLE, size_t &size)
 Returns -1 (not used in this implementation);.
virtual int set_sig_handler (ACE_Sig_Handler *signal_handler)
 Use a user specified signal handler instead.
virtual int timer_queue (ACE_Timer_Queue *tq)
 Set a user-specified timer queue.
virtual ACE_Timer_Queuetimer_queue (void) const
 Return the current ACE_Timer_Queue.
virtual int close (void)
 Close down the select_reactor and release all of its resources.
virtual ~ACE_Select_Reactor_T (void)
 Close down the select_reactor and release all of its resources.
virtual int work_pending (const ACE_Time_Value &max_wait_time=ACE_Time_Value::zero)
virtual int handle_events (ACE_Time_Value *max_wait_time=0)
virtual int alertable_handle_events (ACE_Time_Value *max_wait_time=0)
virtual int handle_events (ACE_Time_Value &max_wait_time)
virtual int alertable_handle_events (ACE_Time_Value &max_wait_time)
virtual int deactivated (void)
virtual void deactivate (int do_stop)
virtual int register_handler (ACE_Event_Handler *eh, ACE_Reactor_Mask mask)
virtual int register_handler (ACE_HANDLE handle, ACE_Event_Handler *eh, ACE_Reactor_Mask mask)
virtual int register_handler (ACE_HANDLE event_handle, ACE_HANDLE io_handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask)
 Not implemented.
virtual int register_handler (const ACE_Handle_Set &handles, ACE_Event_Handler *eh, ACE_Reactor_Mask mask)
 Register eh with all the handles in the <Handle_Set>.
virtual 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)
virtual int register_handler (const ACE_Sig_Set &sigset, ACE_Event_Handler *new_sh, ACE_Sig_Action *new_disp=0)
virtual int remove_handler (ACE_Event_Handler *eh, ACE_Reactor_Mask mask)
virtual int remove_handler (ACE_HANDLE handle, ACE_Reactor_Mask)
virtual int remove_handler (const ACE_Handle_Set &handle_set, ACE_Reactor_Mask)
virtual int remove_handler (int signum, ACE_Sig_Action *new_disp, ACE_Sig_Action *old_disp=0, int sigkey=-1)
virtual int remove_handler (const ACE_Sig_Set &sigset)
 Calls <remove_handler> for every signal in sigset.
virtual int suspend_handler (ACE_Event_Handler *eh)
 Temporarily suspend the <Event_Handler> associated with eh.
virtual int suspend_handler (ACE_HANDLE handle)
 Temporarily suspend the Event_Handler associated with handle.
virtual int suspend_handler (const ACE_Handle_Set &handles)
 Suspend all handles in handle set temporarily.
virtual int suspend_handlers (void)
 Suspend all the <Event_Handlers> in the Select_Reactor.
virtual int resume_handler (ACE_Event_Handler *eh)
virtual int resume_handler (ACE_HANDLE handle)
virtual int resume_handler (const ACE_Handle_Set &handles)
 Resume all handles in handle set.
virtual int resume_handlers (void)
 Resume all the <Event_Handlers> in the Select_Reactor.
virtual bool uses_event_associations (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 (ACE_Event_Handler *event_handler, int dont_call_handle_close=1)
virtual int cancel_timer (long timer_id, const void **arg=0, int dont_call_handle_close=1)
virtual int schedule_wakeup (ACE_Event_Handler *eh, ACE_Reactor_Mask mask)
 ADD the dispatch MASK "bit" bound with the eh and the mask.
virtual int schedule_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask mask)
 ADD the dispatch MASK "bit" bound with the handle and the mask.
virtual int cancel_wakeup (ACE_Event_Handler *eh, ACE_Reactor_Mask mask)
 CLR the dispatch MASK "bit" bound with the eh and the mask.
virtual int cancel_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask mask)
 CLR the dispatch MASK "bit" bound with the handle and the mask.
virtual int notify (ACE_Event_Handler *=0, ACE_Reactor_Mask=ACE_Event_Handler::EXCEPT_MASK, ACE_Time_Value *=0)
virtual void max_notify_iterations (int)
virtual int max_notify_iterations (void)
virtual bool restart (void)
 Get the existing restart value.
virtual bool restart (bool r)
 Set a new value for restart and return the original value.
virtual void requeue_position (int)
virtual int requeue_position (void)
virtual int mask_ops (ACE_Event_Handler *eh, ACE_Reactor_Mask mask, int ops)
virtual int mask_ops (ACE_HANDLE handle, ACE_Reactor_Mask mask, int ops)
virtual int ready_ops (ACE_Event_Handler *eh, ACE_Reactor_Mask mask, int ops)
 GET/SET/ADD/CLR the ready "bit" bound with the eh and mask.
virtual int ready_ops (ACE_HANDLE handle, ACE_Reactor_Mask, int ops)
 GET/SET/ADD/CLR the ready "bit" bound with the handle and mask.
virtual void wakeup_all_threads (void)
 Wake up all threads in waiting in the event loop.
virtual int owner (ACE_thread_t n_id, ACE_thread_t *o_id=0)
 Set the new owner of the thread and return the old owner.
virtual int owner (ACE_thread_t *)
 Return the current owner of the thread.
virtual ACE_Event_Handlerfind_handler (ACE_HANDLE handle)
virtual int handler (ACE_HANDLE handle, ACE_Reactor_Mask mask, ACE_Event_Handler **eh=0)
virtual int handler (int signum, ACE_Event_Handler **=0)
virtual bool initialized (void)
 Returns true if we've been successfully initialized, else false.
virtual size_t size (void) const
virtual ACE_Locklock (void)
virtual void dump (void) const
 Dump the state of an object.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Protected Member Functions

virtual int register_handler_i (ACE_HANDLE handle, ACE_Event_Handler *eh, ACE_Reactor_Mask mask)
virtual int register_handler_i (const ACE_Handle_Set &handles, ACE_Event_Handler *handler, ACE_Reactor_Mask mask)
 Register a set of handles.
virtual int remove_handler_i (ACE_HANDLE handle, ACE_Reactor_Mask)
virtual int remove_handler_i (const ACE_Handle_Set &handles, ACE_Reactor_Mask)
 Remove a set of handles.
virtual int suspend_i (ACE_HANDLE handle)
 Suspend the <Event_Handler> associated with handle.
virtual int is_suspended_i (ACE_HANDLE handle)
virtual int resume_i (ACE_HANDLE handle)
 Resume the <Event_Handler> associated with handle.
virtual ACE_Event_Handlerfind_handler_i (ACE_HANDLE handle)
 Implement the public handler method.
virtual int handler_i (ACE_HANDLE handle, ACE_Reactor_Mask, ACE_Event_Handler **=0)
 Implement the public handler method.
virtual int handler_i (int signum, ACE_Event_Handler **=0)
 Implement the public handler method.
virtual int any_ready (ACE_Select_Reactor_Handle_Set &handle_set)
virtual int any_ready_i (ACE_Select_Reactor_Handle_Set &handle_set)
virtual int handle_error (void)
 Take corrective action when errors occur.
virtual int check_handles (void)
 Make sure the handles are all valid.
virtual int wait_for_multiple_events (ACE_Select_Reactor_Handle_Set &, ACE_Time_Value *)
 Wait for events to occur.
virtual int dispatch (int nfound, ACE_Select_Reactor_Handle_Set &)
virtual int dispatch_timer_handlers (int &number_dispatched)
virtual int dispatch_notification_handlers (ACE_Select_Reactor_Handle_Set &dispatch_set, int &number_of_active_handles, int &number_of_handlers_dispatched)
virtual int dispatch_io_handlers (ACE_Select_Reactor_Handle_Set &dispatch_set, int &number_of_active_handles, int &number_of_handlers_dispatched)
virtual int dispatch_io_set (int number_of_active_handles, int &number_of_handlers_dispatched, int mask, ACE_Handle_Set &dispatch_mask, ACE_Handle_Set &ready_mask, ACE_EH_PTMF callback)
virtual void notify_handle (ACE_HANDLE handle, ACE_Reactor_Mask mask, ACE_Handle_Set &, ACE_Event_Handler *eh, ACE_EH_PTMF callback)
virtual void renew (void)
int release_token (void)
 Release the token lock when a Win32 structured exception occurs.
int handle_events_i (ACE_Time_Value *max_wait_time=0)
 Stops the VC++ compiler from bitching about exceptions and destructors.

Protected Attributes

ACE_SELECT_REACTOR_TOKEN token_
 Synchronization token for the MT_SAFE ACE_Select_Reactor.
ACE_Lock_Adapter
< ACE_SELECT_REACTOR_TOKEN > 
lock_adapter_
 Adapter used to return internal lock to outside world.
sig_atomic_t deactivated_

Detailed Description

template<class ACE_SELECT_REACTOR_TOKEN>
class ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >

An object oriented event demultiplexor and event handler dispatcher.

The ACE_Select_Reactor is an object-oriented event demultiplexor and event handler dispatcher. The sources of events that the ACE_Select_Reactor waits for and dispatches includes I/O events, signals, and timer events. All public methods acquire the main ACE_Reactor_Token lock and call down to private or protected methods, which assume that the lock is held and so therefore don't (re)acquire the lock.

Definition at line 55 of file Select_Reactor_T.h.


Constructor & Destructor Documentation

template<class ACE_SELECT_REACTOR_TOKEN >
ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::ACE_Select_Reactor_T ( ACE_Sig_Handler sh = 0,
ACE_Timer_Queue tq = 0,
int  disable_notify_pipe = ACE_DISABLE_NOTIFY_PIPE_DEFAULT,
ACE_Reactor_Notify notify = 0,
bool  mask_signals = true,
int  s_queue = ACE_SELECT_TOKEN::FIFO 
) [inline]

If disable_notify_pipe is non-0 then the reactor will not create a notification pipe, which will save two I/O handles but will elide the <notify()> feature. If mask_signals is true the reactor is "signal-safe" when dispatching handlers to signal events, whereas if mask_signals is false the reactor will be more efficient, but not signal-safe (which may be perfectly fine if your application doesn't use the reactor to handle signals).

Definition at line 476 of file Select_Reactor_T.cpp.

00482     : ACE_Select_Reactor_Impl (mask_signals)
00483     , token_ (s_queue)
00484     , lock_adapter_ (token_)
00485     , deactivated_ (0)
00486 {
00487   ACE_TRACE ("ACE_Select_Reactor_T::ACE_Select_Reactor_T");
00488 
00489   this->token_.reactor (*this);
00490   // First try to open the Reactor with the hard-coded default.
00491   if (this->open (ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE,
00492                   0,
00493                   sh,
00494                   tq,
00495                   disable_notify_pipe,
00496                   notify) == -1)
00497     {
00498       // The hard-coded default Reactor size failed, so attempt to
00499       // determine the size at run-time by checking the process file
00500       // descriptor limit on platforms that support this feature.
00501 
00502       // There is no need to deallocate resources from previous open()
00503       // call since the open() method deallocates any resources prior
00504       // to exiting if an error was encountered.
00505 
00506       // Set the default reactor size to be the current limit on the
00507       // number of file descriptors available to the process.  This
00508       // size is not necessarily the maximum limit.
00509       if (this->open (ACE::max_handles (),
00510                      0,
00511                      sh,
00512                      tq,
00513                      disable_notify_pipe,
00514                      notify) == -1)
00515         ACE_ERROR ((LM_ERROR,
00516                     ACE_TEXT ("%p\n"),
00517                     ACE_TEXT ("ACE_Select_Reactor_T::open ")
00518                     ACE_TEXT ("failed inside ")
00519                     ACE_TEXT ("ACE_Select_Reactor_T::CTOR")));
00520     }
00521 }

template<class ACE_SELECT_REACTOR_TOKEN >
ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::ACE_Select_Reactor_T ( size_t  size,
bool  restart = false,
ACE_Sig_Handler sh = 0,
ACE_Timer_Queue tq = 0,
int  disable_notify_pipe = ACE_DISABLE_NOTIFY_PIPE_DEFAULT,
ACE_Reactor_Notify notify = 0,
bool  mask_signals = true,
int  s_queue = ACE_SELECT_TOKEN::FIFO 
) [inline]

Initialize ACE_Select_Reactor with size

  • size. If
  • disable_notify_pipe is non-0 then the reactor will not create a notification pipe, which will save two I/O handles but will elide the notification feature. If
  • mask_signals is true the reactor is "signal-safe" when dispatching handlers to signal events, whereas if
  • mask_signals is false the reactor will be more efficient, but not signal-safe (which may be perfectly fine if your application doesn't use the reactor to handle signals).
    Note:
    On Unix platforms, the size parameter should be as large as the maximum number of file descriptors allowed for a given process. This is necessary since a file descriptor is used to directly index the array of event handlers maintained by the Reactor's handler repository. Direct indexing is used for efficiency reasons.

Definition at line 527 of file Select_Reactor_T.cpp.

00535     : ACE_Select_Reactor_Impl (mask_signals)
00536     , token_ (s_queue)
00537     , lock_adapter_ (token_)
00538     , deactivated_ (0)
00539 {
00540   ACE_TRACE ("ACE_Select_Reactor_T::ACE_Select_Reactor_T");
00541 
00542   this->token_.reactor (*this);
00543   if (this->open (size,
00544                   restart,
00545                   sh,
00546                   tq,
00547                   disable_notify_pipe,
00548                   notify) == -1)
00549     ACE_ERROR ((LM_ERROR,
00550                 ACE_TEXT ("%p\n"),
00551                 ACE_TEXT ("ACE_Select_Reactor_T::open ")
00552                 ACE_TEXT ("failed inside ACE_Select_Reactor_T::CTOR")));
00553 }

template<class ACE_SELECT_REACTOR_TOKEN >
ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::~ACE_Select_Reactor_T ( void   )  [inline, virtual]

Close down the select_reactor and release all of its resources.

Definition at line 604 of file Select_Reactor_T.cpp.

00605 {
00606   ACE_TRACE ("ACE_Select_Reactor_T::~ACE_Select_Reactor_T");
00607   this->close ();
00608 }


Member Function Documentation

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::alertable_handle_events ( ACE_Time_Value max_wait_time  )  [inline, virtual]

Implements ACE_Reactor_Impl.

Definition at line 206 of file Select_Reactor_T.inl.

00207 {
00208   return this->handle_events (max_wait_time);
00209 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::alertable_handle_events ( ACE_Time_Value max_wait_time = 0  )  [inline, virtual]

Implements ACE_Reactor_Impl.

Definition at line 200 of file Select_Reactor_T.inl.

00201 {
00202   return this->handle_events (max_wait_time);
00203 }

template<class ACE_SELECT_REACTOR_TOKEN>
virtual int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::any_ready ( ACE_Select_Reactor_Handle_Set handle_set  )  [protected, virtual]

Check if there are any HANDLEs enabled in the <ready_set_>, and if so, update the handle_set and return the number ready. If there aren't any HANDLEs enabled return 0.

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::any_ready_i ( ACE_Select_Reactor_Handle_Set handle_set  )  [inline, protected, virtual]

Implement the <any_ready> method, assuming that the Sig_Guard is beign held

Definition at line 63 of file Select_Reactor_T.cpp.

00064 {
00065   ACE_TRACE ("ACE_Select_Reactor_T::any_ready_i");
00066 
00067   int const number_ready = this->ready_set_.rd_mask_.num_set ()
00068     + this->ready_set_.wr_mask_.num_set ()
00069     + this->ready_set_.ex_mask_.num_set ();
00070 
00071   // number_ready > 0 meaning there are handles in the ready_set
00072   // &wait_set != &(this->ready_set_) means that we need to copy
00073   // the handles from the ready_set to the wait set because the
00074   // wait_set_ doesn't contain all the handles in the ready_set_
00075   if (number_ready > 0 && &wait_set != &(this->ready_set_))
00076     {
00077       wait_set.rd_mask_ = this->ready_set_.rd_mask_;
00078       wait_set.wr_mask_ = this->ready_set_.wr_mask_;
00079       wait_set.ex_mask_ = this->ready_set_.ex_mask_;
00080 
00081       this->ready_set_.rd_mask_.reset ();
00082       this->ready_set_.wr_mask_.reset ();
00083       this->ready_set_.ex_mask_.reset ();
00084     }
00085 
00086   return number_ready;
00087 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::cancel_timer ( long  timer_id,
const void **  arg = 0,
int  dont_call_handle_close = 1 
) [inline, virtual]

Cancel the single ACE_Event_Handler that matches the timer_id value (which was returned from the <schedule> method). If arg is non-NULL then it will be set to point to the ``magic cookie'' argument passed in when the Event_Handler was registered. This makes it possible to free up the memory and avoid memory leaks. If dont_call_handle_close is 0 then the <handle_close> method of <event_handler> will be invoked. Returns 1 if cancellation succeeded and 0 if the timer_id wasn't found.

Implements ACE_Reactor_Impl.

Definition at line 702 of file Select_Reactor_T.cpp.

00705 {
00706   ACE_TRACE ("ACE_Select_Reactor_T::cancel_timer");
00707   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00708 
00709   if (this->timer_queue_ != 0)
00710     return this->timer_queue_->cancel (timer_id,
00711                                        arg,
00712                                        dont_call_handle_close);
00713   else
00714     return 0;
00715 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::cancel_timer ( ACE_Event_Handler event_handler,
int  dont_call_handle_close = 1 
) [inline, virtual]

Cancel all <event_handlers> that match the address of event_handler. If dont_call_handle_close is 0 then the <handle_close> method of event_handler will be invoked. Returns number of handler's cancelled.

Implements ACE_Reactor_Impl.

Definition at line 689 of file Select_Reactor_T.cpp.

00691 {
00692   ACE_TRACE ("ACE_Select_Reactor_T::cancel_timer");
00693   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00694 
00695   if (this->timer_queue_ != 0)
00696     return this->timer_queue_->cancel (handler, dont_call_handle_close);
00697   else
00698     return 0;
00699 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::cancel_wakeup ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask 
) [inline, virtual]

CLR the dispatch MASK "bit" bound with the handle and the mask.

Implements ACE_Reactor_Impl.

Definition at line 177 of file Select_Reactor_T.inl.

00179 {
00180   ACE_TRACE ("ACE_Select_Reactor_T::cancel_wakeup");
00181   return this->mask_ops (handle, mask, ACE_Reactor::CLR_MASK);
00182 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::cancel_wakeup ( ACE_Event_Handler eh,
ACE_Reactor_Mask  mask 
) [inline, virtual]

CLR the dispatch MASK "bit" bound with the eh and the mask.

Implements ACE_Reactor_Impl.

Definition at line 161 of file Select_Reactor_T.inl.

00163 {
00164   ACE_TRACE ("ACE_Select_Reactor_T::cancel_wakeup");
00165   return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::CLR_MASK);
00166 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::check_handles ( void   )  [inline, protected, virtual]

Make sure the handles are all valid.

Definition at line 1458 of file Select_Reactor_T.cpp.

01459 {
01460   ACE_TRACE ("ACE_Select_Reactor_T::check_handles");
01461 
01462 #if defined (ACE_WIN32) || defined (__MVS__) || defined (ACE_VXWORKS)
01463   ACE_Time_Value time_poll = ACE_Time_Value::zero;
01464   ACE_Handle_Set rd_mask;
01465 #endif /* ACE_WIN32 || MVS || ACE_VXWORKS */
01466 
01467   int result = 0;
01468 
01469   /*
01470    * It's easier to run through the handler repository iterator, but that
01471    * misses handles that are registered on a handler that doesn't implement
01472    * get_handle(). So, build a handle set that's the union of the three
01473    * wait_sets (rd, wrt, ex) and run through that. Bad handles get cleared
01474    * out of all sets.
01475    */
01476   ACE_HANDLE h;
01477   ACE_Handle_Set check_set (this->wait_set_.rd_mask_);
01478   ACE_Handle_Set_Iterator wr_iter (this->wait_set_.wr_mask_);
01479   while ((h = wr_iter ()) != ACE_INVALID_HANDLE)
01480     check_set.set_bit (h);
01481   ACE_Handle_Set_Iterator ex_iter (this->wait_set_.ex_mask_);
01482   while ((h = ex_iter ()) != ACE_INVALID_HANDLE)
01483     check_set.set_bit (h);
01484 
01485   ACE_Handle_Set_Iterator check_iter (check_set);
01486   while ((h = check_iter ()) != ACE_INVALID_HANDLE)
01487     {
01488 
01489 #if defined (ACE_WIN32) || defined (__MVS__) || defined (ACE_VXWORKS)
01490       // Win32 needs to do the check this way because fstat won't work on
01491       // a socket handle.  MVS Open Edition needs to do it this way because,
01492       // even though the docs say to check a handle with either select or
01493       // fstat, the fstat method always says the handle is ok.
01494       // pSOS needs to do it this way because file handles and socket handles
01495       // are maintained by separate pieces of the system.  VxWorks needs the select
01496       // variant since fstat always returns an error on socket FDs.
01497       rd_mask.set_bit (h);
01498 
01499 #  if defined (ACE_WIN32)
01500       // This arg is ignored on Windows and causes pointer truncation
01501       // warnings on 64-bit compiles.
01502       int select_width = 0;
01503 #  else
01504       int select_width = int (h) + 1;
01505 #  endif /* ACE_WIN32 */
01506 
01507       if (ACE_OS::select (select_width,
01508                           rd_mask, 0, 0,
01509                           &time_poll) < 0)
01510         {
01511           result = 1;
01512           this->remove_handler_i (h, ACE_Event_Handler::ALL_EVENTS_MASK);
01513         }
01514       rd_mask.clr_bit (h);
01515 #else /* !ACE_WIN32 && !MVS && !VXWORKS */
01516       struct stat temp;
01517 
01518       if (ACE_OS::fstat (h, &temp) == -1)
01519         {
01520           result = 1;
01521           this->remove_handler_i (h, ACE_Event_Handler::ALL_EVENTS_MASK);
01522         }
01523 #endif /* ACE_WIN32 || MVS */
01524     }
01525 
01526   return result;
01527 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::close ( void   )  [inline, virtual]

Close down the select_reactor and release all of its resources.

Implements ACE_Reactor_Impl.

Definition at line 560 of file Select_Reactor_T.cpp.

00561 {
00562   ACE_TRACE ("ACE_Select_Reactor_T::close");
00563   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00564 
00565   if (this->delete_signal_handler_)
00566     {
00567       delete this->signal_handler_;
00568       this->signal_handler_ = 0;
00569       this->delete_signal_handler_ = false;
00570     }
00571 
00572   this->handler_rep_.close ();
00573 
00574   if (this->delete_timer_queue_)
00575     {
00576       delete this->timer_queue_;
00577       this->timer_queue_ = 0;
00578       this->delete_timer_queue_ = false;
00579     }
00580 
00581   if (this->notify_handler_ != 0)
00582     this->notify_handler_->close ();
00583 
00584   if (this->delete_notify_handler_)
00585     {
00586       delete this->notify_handler_;
00587       this->notify_handler_ = 0;
00588       this->delete_notify_handler_ = false;
00589     }
00590 
00591   this->initialized_ = false;
00592 
00593   return 0;
00594 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::current_info ( ACE_HANDLE  ,
size_t &  size 
) [inline, virtual]

Returns -1 (not used in this implementation);.

Implements ACE_Reactor_Impl.

Definition at line 598 of file Select_Reactor_T.cpp.

00599 {
00600   return -1;
00601 }

template<class ACE_SELECT_REACTOR_TOKEN >
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::deactivate ( int  do_stop  )  [inline, virtual]

Control whether the Reactor will handle any more incoming events or not. If do_stop == 1, the Reactor will be disabled. By default, a reactor is in active state and can be deactivated/reactived as wish.

Implements ACE_Reactor_Impl.

Definition at line 218 of file Select_Reactor_T.inl.

00219 {
00220   {
00221     ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN,
00222                        ace_mon,
00223                        this->token_));
00224     this->deactivated_ = do_stop;
00225   }
00226 
00227   this->wakeup_all_threads ();
00228 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::deactivated ( void   )  [inline, virtual]

Return the status of Reactor. If this function returns 0, the reactor is actively handling events. If it returns non-zero, <handling_events> and <handle_alertable_events> return -1 immediately.

Implements ACE_Reactor_Impl.

Definition at line 212 of file Select_Reactor_T.inl.

00213 {
00214   return this->deactivated_;
00215 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dispatch ( int  nfound,
ACE_Select_Reactor_Handle_Set dispatch_set 
) [inline, protected, virtual]

Template Method that dispatches ACE_Event_Handlers for time events, I/O events, and signal events. Returns the total number of ACE_Event_Handlers that were dispatched or -1 if something goes wrong.

Definition at line 1276 of file Select_Reactor_T.cpp.

01278 {
01279   ACE_TRACE ("ACE_Select_Reactor_T::dispatch");
01280 
01281   int io_handlers_dispatched = 0;
01282   int other_handlers_dispatched = 0;
01283   int signal_occurred = 0;
01284   // The following do/while loop keeps dispatching as long as there
01285   // are still active handles.  Note that the only way we should ever
01286   // iterate more than once through this loop is if signals occur
01287   // while we're dispatching other handlers.
01288 
01289   do
01290     {
01291       // We expect that the loop will decrease the number of active
01292       // handles in each iteration.  If it does not, then something is
01293       // inconsistent in the state of the Reactor and we should avoid
01294       // the loop.  Please read the comments on bug 2540 for more
01295       // details.
01296       int initial_handle_count = active_handle_count;
01297 
01298       // Note that we keep track of changes to our state.  If any of
01299       // the dispatch_*() methods below return -1 it means that the
01300       // <wait_set_> state has changed as the result of an
01301       // <ACE_Event_Handler> being dispatched.  This means that we
01302       // need to bail out and rerun the select() loop since our
01303       // existing notion of handles in <dispatch_set> may no longer be
01304       // correct.
01305       //
01306       // In the beginning, our state starts out unchanged.  After
01307       // every iteration (i.e., due to signals), our state starts out
01308       // unchanged again.
01309 
01310       this->state_changed_ = false;
01311 
01312       // Perform the Template Method for dispatching all the handlers.
01313 
01314       // First check for interrupts.
01315       if (active_handle_count == -1)
01316         {
01317           // Bail out -- we got here since <select> was interrupted.
01318           if (ACE_Sig_Handler::sig_pending () != 0)
01319             {
01320               ACE_Sig_Handler::sig_pending (0);
01321 
01322               // If any HANDLES in the <ready_set_> are activated as a
01323               // result of signals they should be dispatched since
01324               // they may be time critical...
01325               active_handle_count = this->any_ready (dispatch_set);
01326 
01327               // Record the fact that the Reactor has dispatched a
01328               // handle_signal() method.  We need this to return the
01329               // appropriate count below.
01330               signal_occurred = 1;
01331             }
01332           else
01333             return -1;
01334         }
01335 
01336       // Handle timers early since they may have higher latency
01337       // constraints than I/O handlers.  Ideally, the order of
01338       // dispatching should be a strategy...
01339       else if (this->dispatch_timer_handlers (other_handlers_dispatched) == -1)
01340         // State has changed or timer queue has failed, exit loop.
01341         break;
01342 
01343       // Check to see if there are no more I/O handles left to
01344       // dispatch AFTER we've handled the timers...
01345       else if (active_handle_count == 0)
01346         return io_handlers_dispatched
01347           + other_handlers_dispatched
01348           + signal_occurred;
01349 
01350       // Next dispatch the notification handlers (if there are any to
01351       // dispatch).  These are required to handle multi-threads that
01352       // are trying to update the <Reactor>.
01353 
01354       else if (this->dispatch_notification_handlers
01355                (dispatch_set,
01356                 active_handle_count,
01357                 other_handlers_dispatched) == -1)
01358         // State has changed or a serious failure has occured, so exit
01359         // loop.
01360         break;
01361 
01362       // Finally, dispatch the I/O handlers.
01363       else if (this->dispatch_io_handlers
01364                (dispatch_set,
01365                 active_handle_count,
01366                 io_handlers_dispatched) == -1)
01367         // State has changed, so exit loop.
01368         break;
01369 
01370       // if state changed, we need to re-eval active_handle_count,
01371       // so we will not end with an endless loop
01372       if (initial_handle_count == active_handle_count
01373           || this->state_changed_)
01374       {
01375         active_handle_count = this->any_ready (dispatch_set);
01376       }
01377     }
01378   while (active_handle_count > 0);
01379 
01380   return io_handlers_dispatched + other_handlers_dispatched + signal_occurred;
01381 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dispatch_io_handlers ( ACE_Select_Reactor_Handle_Set dispatch_set,
int &  number_of_active_handles,
int &  number_of_handlers_dispatched 
) [inline, protected, virtual]

Dispatch all the input/output/except handlers that are enabled in the dispatch_set. Updates number_of_active_handles and number_of_handlers_dispatched according to the behavior of the number Returns -1 if the state of the <wait_set_> has changed, else 0.

Definition at line 1225 of file Select_Reactor_T.cpp.

01228 {
01229   ACE_TRACE ("ACE_Select_Reactor_T::dispatch_io_handlers");
01230 
01231   // Handle output events (this code needs to come first to handle the
01232   // obscure case of piggy-backed data coming along with the final
01233   // handshake message of a nonblocking connection).
01234 
01235   if (this->dispatch_io_set (number_of_active_handles,
01236                              number_of_handlers_dispatched,
01237                              ACE_Event_Handler::WRITE_MASK,
01238                              dispatch_set.wr_mask_,
01239                              this->ready_set_.wr_mask_,
01240                              &ACE_Event_Handler::handle_output) == -1)
01241     {
01242       number_of_active_handles -= number_of_handlers_dispatched;
01243       return -1;
01244     }
01245 
01246   // ACE_DEBUG ((LM_DEBUG,  ACE_TEXT ("ACE_Select_Reactor_T::dispatch - EXCEPT\n")));
01247   if (this->dispatch_io_set (number_of_active_handles,
01248                              number_of_handlers_dispatched,
01249                              ACE_Event_Handler::EXCEPT_MASK,
01250                              dispatch_set.ex_mask_,
01251                              this->ready_set_.ex_mask_,
01252                              &ACE_Event_Handler::handle_exception) == -1)
01253     {
01254       number_of_active_handles -= number_of_handlers_dispatched;
01255       return -1;
01256     }
01257 
01258   // ACE_DEBUG ((LM_DEBUG,  ACE_TEXT ("ACE_Select_Reactor_T::dispatch - READ\n")));
01259   if (this->dispatch_io_set (number_of_active_handles,
01260                              number_of_handlers_dispatched,
01261                              ACE_Event_Handler::READ_MASK,
01262                              dispatch_set.rd_mask_,
01263                              this->ready_set_.rd_mask_,
01264                              &ACE_Event_Handler::handle_input) == -1)
01265     {
01266       number_of_active_handles -= number_of_handlers_dispatched;
01267       return -1;
01268     }
01269 
01270   number_of_active_handles -= number_of_handlers_dispatched;
01271   return 0;
01272 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dispatch_io_set ( int  number_of_active_handles,
int &  number_of_handlers_dispatched,
int  mask,
ACE_Handle_Set dispatch_mask,
ACE_Handle_Set ready_mask,
ACE_EH_PTMF  callback 
) [inline, protected, virtual]

Factors the dispatching of an io handle set (each WRITE, EXCEPT or READ set of handles). It updates the number_of_handlers_dispatched and invokes this->notify_handle for all the handles in <dispatch_set> using the mask, <ready_set> and callback parameters. Must return -1 if this->state_changed otherwise it must return 0.

Reimplemented in ACE_Priority_Reactor.

Definition at line 1184 of file Select_Reactor_T.cpp.

01190 {
01191   ACE_TRACE ("ACE_Select_Reactor_T::dispatch_io_set");
01192   ACE_HANDLE handle;
01193 
01194   ACE_Handle_Set_Iterator handle_iter (dispatch_mask);
01195 
01196   while ((handle = handle_iter ()) != ACE_INVALID_HANDLE &&
01197          number_of_handlers_dispatched < number_of_active_handles)
01198     {
01199       ++number_of_handlers_dispatched;
01200 
01201       this->notify_handle (handle,
01202                            mask,
01203                            ready_mask,
01204                            this->handler_rep_.find (handle),
01205                            callback);
01206 
01207       // clear the bit from that dispatch mask,
01208       // so when we need to restart the iteration (rebuilding the iterator...)
01209       // we will not dispatch the already dispatched handlers
01210       this->clear_dispatch_mask (handle, mask);
01211 
01212       if (this->state_changed_)
01213         {
01214 
01215           handle_iter.reset_state ();
01216           this->state_changed_ = false;
01217         }
01218     }
01219 
01220   return 0;
01221 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dispatch_notification_handlers ( ACE_Select_Reactor_Handle_Set dispatch_set,
int &  number_of_active_handles,
int &  number_of_handlers_dispatched 
) [inline, protected, virtual]

Dispatch any notification handlers. Returns -1 if the state of the <wait_set_> has changed, else returns number of handlers notified.

Definition at line 1151 of file Select_Reactor_T.cpp.

01154 {
01155   // Check to see if the ACE_HANDLE associated with the
01156   // Select_Reactor's notify hook is enabled.  If so, it means that
01157   // one or more other threads are trying to update the
01158   // ACE_Select_Reactor_T's internal tables or the notify pipe is
01159   // enabled.  We'll handle all these threads and notifications, and
01160   // then break out to continue the event loop.
01161   int const n =
01162     this->notify_handler_->dispatch_notifications (number_of_active_handles,
01163                                                    dispatch_set.rd_mask_);
01164 
01165   if (n == -1)
01166     return -1;
01167   else
01168     {
01169       number_of_handlers_dispatched += n;
01170       number_of_active_handles -= n;
01171     }
01172 
01173   // Same as dispatch_timer_handlers
01174   // No need to do anything with the state changed. That is because
01175   // unbind already handles the case where someone unregister some
01176   // kind of handle and unbind it. (::unbind calls the function
01177   // state_changed ()  to reflect ant change with that)
01178   //   return this->state_changed_ ? -1 : 0;
01179   return 0;
01180 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dispatch_timer_handlers ( int &  number_dispatched  )  [inline, protected, virtual]

Dispatch all timer handlers that have expired. Returns -1 if the state of the <wait_set_> has changed, else 0. <number_dispatched> is set to the number of timer handlers dispatched.

Definition at line 1142 of file Select_Reactor_T.cpp.

01143 {
01144   number_of_handlers_dispatched += this->timer_queue_->expire ();
01145 
01146   return 0;
01147 }

template<class ACE_SELECT_REACTOR_TOKEN >
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dump ( void   )  const [inline, virtual]

Dump the state of an object.

Implements ACE_Reactor_Impl.

Reimplemented in ACE_Priority_Reactor.

Definition at line 1530 of file Select_Reactor_T.cpp.

01531 {
01532 #if defined (ACE_HAS_DUMP)
01533   ACE_TRACE ("ACE_Select_Reactor_T::dump");
01534 
01535   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
01536 
01537   this->timer_queue_->dump ();
01538   this->handler_rep_.dump ();
01539   this->signal_handler_->dump ();
01540   ACE_DEBUG ((LM_DEBUG,
01541               ACE_TEXT ("delete_signal_handler_ = %d\n"),
01542               this->delete_signal_handler_));
01543 
01544   ACE_HANDLE h;
01545 
01546   for (ACE_Handle_Set_Iterator handle_iter_wr (this->wait_set_.wr_mask_);
01547        (h = handle_iter_wr ()) != ACE_INVALID_HANDLE;)
01548     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("write_handle = %d\n"), h));
01549 
01550   for (ACE_Handle_Set_Iterator handle_iter_rd (this->wait_set_.rd_mask_);
01551        (h = handle_iter_rd ()) != ACE_INVALID_HANDLE;)
01552     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("read_handle = %d\n"), h));
01553 
01554   for (ACE_Handle_Set_Iterator handle_iter_ex (this->wait_set_.ex_mask_);
01555        (h = handle_iter_ex ()) != ACE_INVALID_HANDLE;)
01556     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("except_handle = %d\n"), h));
01557 
01558   for (ACE_Handle_Set_Iterator handle_iter_wr_ready (this->ready_set_.wr_mask_);
01559        (h = handle_iter_wr_ready ()) != ACE_INVALID_HANDLE;)
01560     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("write_handle_ready = %d\n"), h));
01561 
01562   for (ACE_Handle_Set_Iterator handle_iter_rd_ready (this->ready_set_.rd_mask_);
01563        (h = handle_iter_rd_ready ()) != ACE_INVALID_HANDLE;)
01564     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("read_handle_ready = %d\n"), h));
01565 
01566   for (ACE_Handle_Set_Iterator handle_iter_ex_ready (this->ready_set_.ex_mask_);
01567        (h = handle_iter_ex_ready ()) != ACE_INVALID_HANDLE;)
01568     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("except_handle_ready = %d\n"), h));
01569 
01570   for (ACE_Handle_Set_Iterator handle_iter_su_ready (this->suspend_set_.wr_mask_);
01571        (h = handle_iter_su_ready ()) != ACE_INVALID_HANDLE;)
01572     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("write_handle_suspend = %d\n"), h));
01573 
01574   for (ACE_Handle_Set_Iterator handle_iter_su_ready (this->suspend_set_.rd_mask_);
01575        (h = handle_iter_su_ready ()) != ACE_INVALID_HANDLE;)
01576     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("read_handle_suspend = %d\n"), h));
01577 
01578   for (ACE_Handle_Set_Iterator handle_iter_su_ready (this->suspend_set_.ex_mask_);
01579        (h = handle_iter_su_ready ()) != ACE_INVALID_HANDLE;)
01580     ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("except_handle_suspend = %d\n"), h));
01581 
01582   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("restart_ = %d\n"), this->restart_));
01583   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("requeue_position_ = %d\n"), this->requeue_position_));
01584   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("initialized_ = %d\n"), this->initialized_));
01585   ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("owner_ = %d\n"), this->owner_));
01586 
01587 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
01588   this->notify_handler_->dump ();
01589   this->token_.dump ();
01590 #endif /* ACE_MT_SAFE */
01591 
01592   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
01593 #endif /* ACE_HAS_DUMP */
01594 }

template<class ACE_SELECT_REACTOR_TOKEN >
ACE_Event_Handler * ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::find_handler ( ACE_HANDLE  handle  )  [inline, virtual]

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

Implements ACE_Reactor_Impl.

Definition at line 308 of file Select_Reactor_T.cpp.

00309 {
00310   ACE_TRACE ("ACE_Select_Reactor_T::find_handler");
00311   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, 0));
00312   return this->find_handler_i (handle);
00313 }

template<class ACE_SELECT_REACTOR_TOKEN >
ACE_Event_Handler * ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::find_handler_i ( ACE_HANDLE  handle  )  [inline, protected, virtual]

Implement the public handler method.

Definition at line 861 of file Select_Reactor_T.cpp.

00862 {
00863   ACE_TRACE ("ACE_Select_Reactor_T::find_handler_i");
00864 
00865   ACE_Event_Handler *event_handler = this->handler_rep_.find (handle);
00866 
00867   if (event_handler)
00868     {
00869       event_handler->add_reference ();
00870     }
00871 
00872   return event_handler;
00873 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_error ( void   )  [inline, protected, virtual]

Take corrective action when errors occur.

Definition at line 768 of file Select_Reactor_T.cpp.

00769 {
00770   ACE_TRACE ("ACE_Select_Reactor_T::handle_error");
00771 #if defined (linux) && defined (ERESTARTNOHAND)
00772   int const error = errno; // Avoid multiple TSS accesses.
00773   if (error == EINTR || error == ERESTARTNOHAND)
00774     return this->restart_;
00775 #else
00776   if (errno == EINTR)
00777     return this->restart_;
00778 #endif /* linux && ERESTARTNOHAND */
00779 #if defined (__MVS__) || defined (ACE_WIN32) || defined (ACE_VXWORKS)
00780   // On MVS Open Edition and Win32, there can be a number of failure
00781   // codes on a bad socket, so check_handles on anything other than
00782   // EINTR.  VxWorks doesn't even bother to always set errno on error
00783   // in select (specifically, it doesn't return EBADF for bad FDs).
00784   else
00785     return this->check_handles ();
00786 #else
00787   else if (errno == EBADF)
00788     return this->check_handles ();
00789   else
00790     return -1;
00791 #endif  /* __MVS__ || ACE_WIN32 */
00792 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events ( ACE_Time_Value max_wait_time  )  [inline, virtual]

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

Current <alertable_handle_events> is identical to <handle_events>.

Implements ACE_Reactor_Impl.

Reimplemented in ACE_TP_Reactor.

Definition at line 760 of file Select_Reactor_T.cpp.

00761 {
00762   ACE_TRACE ("ACE_Select_Reactor_T::handle_events");
00763 
00764   return this->handle_events (&max_wait_time);
00765 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events ( ACE_Time_Value max_wait_time = 0  )  [inline, virtual]

This event loop driver that blocks for max_wait_time before returning. It will return earlier if timer events, I/O events, or signal 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 I/O and Timer ACE_Event_Handler's that were dispatched, 0 if the max_wait_time elapsed without dispatching any handlers, or -1 if something goes wrong.

Current <alertable_handle_events> is identical to <handle_events>.

Implements ACE_Reactor_Impl.

Reimplemented in ACE_TP_Reactor.

Definition at line 1396 of file Select_Reactor_T.cpp.

01397 {
01398   ACE_TRACE ("ACE_Select_Reactor_T::handle_events");
01399 
01400 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
01401 
01402   // Stash the current time -- the destructor of this object will
01403   // automatically compute how much time elapsed since this method was
01404   // called.
01405   ACE_Countdown_Time countdown (max_wait_time);
01406 
01407   ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1);
01408 
01409   if (ACE_OS::thr_equal (ACE_Thread::self (),
01410                          this->owner_) == 0 || this->deactivated_)
01411     return -1;
01412 
01413   // Update the countdown to reflect time waiting for the mutex.
01414   countdown.update ();
01415 #else
01416   if (this->deactivated_)
01417     return -1;
01418 #endif /* ACE_MT_SAFE */
01419 
01420   return this->handle_events_i (max_wait_time);
01421 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events_i ( ACE_Time_Value max_wait_time = 0  )  [inline, protected]

Stops the VC++ compiler from bitching about exceptions and destructors.

Definition at line 1425 of file Select_Reactor_T.cpp.

01426 {
01427   int result = -1;
01428 
01429   ACE_SEH_TRY
01430     {
01431       // We use the data member dispatch_set_ as the current dispatch
01432       // set.
01433 
01434       // We need to start from a clean dispatch_set
01435       this->dispatch_set_.rd_mask_.reset ();
01436       this->dispatch_set_.wr_mask_.reset ();
01437       this->dispatch_set_.ex_mask_.reset ();
01438 
01439       int number_of_active_handles =
01440         this->wait_for_multiple_events (this->dispatch_set_,
01441                                         max_wait_time);
01442 
01443       result =
01444         this->dispatch (number_of_active_handles,
01445                         this->dispatch_set_);
01446     }
01447   ACE_SEH_EXCEPT (this->release_token ())
01448     {
01449       // As it stands now, we catch and then rethrow all Win32
01450       // structured exceptions so that we can make sure to release the
01451       // <token_> lock correctly.
01452     }
01453 
01454   return result;
01455 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handler ( int  signum,
ACE_Event_Handler **  handler = 0 
) [inline, virtual]

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

Implements ACE_Reactor_Impl.

Definition at line 101 of file Select_Reactor_T.inl.

00102 {
00103   ACE_TRACE ("ACE_Select_Reactor_T::handler");
00104   return this->handler_i (signum, handler);
00105 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handler ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
ACE_Event_Handler **  eh = 0 
) [inline, virtual]

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

Implements ACE_Reactor_Impl.

Definition at line 317 of file Select_Reactor_T.cpp.

00320 {
00321   ACE_TRACE ("ACE_Select_Reactor_T::handler");
00322   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00323   return this->handler_i (handle, mask, handler);
00324 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handler_i ( int  signum,
ACE_Event_Handler **  eh = 0 
) [inline, protected, virtual]

Implement the public handler method.

Definition at line 90 of file Select_Reactor_T.cpp.

00092 {
00093   ACE_TRACE ("ACE_Select_Reactor_T::handler_i");
00094   ACE_Event_Handler *handler = this->signal_handler_->handler (signum);
00095 
00096   if (handler == 0)
00097     return -1;
00098   else if (eh != 0)
00099     *eh = handler;
00100   return 0;
00101 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handler_i ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
ACE_Event_Handler **  eh = 0 
) [inline, protected, virtual]

Implement the public handler method.

Definition at line 879 of file Select_Reactor_T.cpp.

00882 {
00883   ACE_TRACE ("ACE_Select_Reactor_T::handler_i");
00884   ACE_Event_Handler *event_handler = this->handler_rep_.find (handle);
00885 
00886   if (event_handler == 0)
00887     return -1;
00888   else
00889     {
00890       if ((ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)
00891            || ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK))
00892           && this->wait_set_.rd_mask_.is_set (handle) == 0)
00893         return -1;
00894       if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)
00895           && this->wait_set_.wr_mask_.is_set (handle) == 0)
00896         return -1;
00897       if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK)
00898           && this->wait_set_.ex_mask_.is_set (handle) == 0)
00899         return -1;
00900     }
00901 
00902   if (eh != 0)
00903     {
00904       *eh = event_handler;
00905       event_handler->add_reference ();
00906     }
00907 
00908   return 0;
00909 }

template<class ACE_SELECT_REACTOR_TOKEN >
bool ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::initialized ( void   )  [inline, virtual]

Returns true if we've been successfully initialized, else false.

Implements ACE_Reactor_Impl.

Definition at line 104 of file Select_Reactor_T.cpp.

00105 {
00106   ACE_TRACE ("ACE_Select_Reactor_T::initialized");
00107   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, false));
00108   return this->initialized_;
00109 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::is_suspended_i ( ACE_HANDLE  handle  )  [inline, protected, virtual]

Check to see if the <Event_Handler> associated with handle is suspended. Returns 0 if not, 1 if so.

Implements ACE_Select_Reactor_Impl.

Definition at line 973 of file Select_Reactor_T.cpp.

00974 {
00975   ACE_TRACE ("ACE_Select_Reactor_T::is_suspended_i");
00976   if (this->handler_rep_.find (handle) == 0)
00977     return 0;
00978 
00979   return this->suspend_set_.rd_mask_.is_set (handle) ||
00980          this->suspend_set_.wr_mask_.is_set (handle) ||
00981          this->suspend_set_.ex_mask_.is_set (handle);
00982 
00983 }

template<class ACE_SELECT_REACTOR_TOKEN >
ACE_Lock & ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::lock ( void   )  [inline, virtual]

Returns a reference to the ACE_Reactor_Token that is used to serialize the internal processing logic. This can be useful for situations where you need to avoid deadlock efficiently when ACE_Event_Handlers are used in multiple threads.

Implements ACE_Reactor_Impl.

Definition at line 185 of file Select_Reactor_T.inl.

00186 {
00187   ACE_TRACE ("ACE_Select_Reactor_T::lock");
00188   return this->lock_adapter_;
00189 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::mask_ops ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
int  ops 
) [inline, virtual]

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

Implements ACE_Reactor_Impl.

Definition at line 843 of file Select_Reactor_T.cpp.

00846 {
00847   ACE_TRACE ("ACE_Select_Reactor_T::mask_ops");
00848   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00849 
00850   // If the handle is not suspended, then set the ops on the
00851   // <wait_set_>, otherwise set the <suspend_set_>.
00852 
00853   if (this->is_suspended_i (handle))
00854     return this->bit_ops (handle, mask, this->suspend_set_, ops);
00855   else
00856     return this->bit_ops (handle, mask, this->wait_set_, ops);
00857 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::mask_ops ( ACE_Event_Handler eh,
ACE_Reactor_Mask  mask,
int  ops 
) [inline, virtual]

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

Implements ACE_Reactor_Impl.

Definition at line 144 of file Select_Reactor_T.inl.

00147 {
00148   ACE_TRACE ("ACE_Select_Reactor_T::mask_ops");
00149   return this->mask_ops (handler->get_handle (), mask, ops);
00150 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::max_notify_iterations ( void   )  [inline, virtual]

Get the maximum number of times that the <ACE_Select_Reactor_Notify::handle_input> method will iterate and dispatch the ACE_Event_Handlers that are passed in via the notify pipe before breaking out of its <recv> loop.

Implements ACE_Reactor_Impl.

Definition at line 186 of file Select_Reactor_T.cpp.

00187 {
00188   ACE_TRACE ("ACE_Select_Reactor_T::max_notify_iterations");
00189   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00190   return this->notify_handler_->max_notify_iterations ();
00191 }

template<class ACE_SELECT_REACTOR_TOKEN >
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::max_notify_iterations ( int  iterations  )  [inline, virtual]

Set the maximum number of times that the <ACE_Select_Reactor_Notify::handle_input> method will iterate and dispatch the ACE_Event_Handlers that are passed in via the notify pipe before breaking out of its <recv> loop. By default, this is set to -1, which means "iterate until the pipe 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.

Implements ACE_Reactor_Impl.

Definition at line 177 of file Select_Reactor_T.cpp.

00178 {
00179   ACE_TRACE ("ACE_Select_Reactor_T::max_notify_iterations");
00180   ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_));
00181 
00182   this->notify_handler_->max_notify_iterations (iterations);
00183 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::notify ( ACE_Event_Handler eh = 0,
ACE_Reactor_Mask  mask = ACE_Event_Handler::EXCEPT_MASK,
ACE_Time_Value timeout = 0 
) [inline, virtual]

Called by a thread when it wants to unblock the Select_Reactor. This wakeups the <ACE_Select_Reactor> if currently blocked in <select>/<poll>. Pass over both the Event_Handler *and* the mask to allow the caller to dictate which <Event_Handler> method the <Select_Reactor> will invoke. The ACE_Time_Value indicates how long to blocking trying to notify the <Select_Reactor>. If timeout == 0, the caller will block until action is possible, else will wait until the relative time specified in *timeout elapses).

Implements ACE_Reactor_Impl.

Definition at line 205 of file Select_Reactor_T.cpp.

00208 {
00209   ACE_TRACE ("ACE_Select_Reactor_T::notify");
00210 
00211   // Pass over both the Event_Handler *and* the mask to allow the
00212   // caller to dictate which Event_Handler method the receiver
00213   // invokes.  Note that this call can timeout.
00214   ssize_t n = -1;
00215   if (this->notify_handler_)
00216     {
00217       n = this->notify_handler_->notify (eh, mask, timeout);
00218     }
00219   return n == -1 ? -1 : 0;
00220 }

template<class ACE_SELECT_REACTOR_TOKEN >
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::notify_handle ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
ACE_Handle_Set ready_mask,
ACE_Event_Handler eh,
ACE_EH_PTMF  callback 
) [inline, protected, virtual]

Notify the appropriate callback in the context of the eh associated with handle that a particular event has occurred.

Reimplemented in ACE_TP_Reactor.

Definition at line 796 of file Select_Reactor_T.cpp.

00801 {
00802   ACE_TRACE ("ACE_Select_Reactor_T::notify_handle");
00803   // Check for removed handlers.
00804   if (event_handler == 0)
00805     return;
00806 
00807   bool const reference_counting_required =
00808     event_handler->reference_counting_policy ().value () ==
00809     ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
00810 
00811   // Call add_reference() if needed.
00812   if (reference_counting_required)
00813     {
00814       event_handler->add_reference ();
00815     }
00816 
00817   int const status = (event_handler->*ptmf) (handle);
00818 
00819   if (status < 0)
00820     this->remove_handler_i (handle, mask);
00821   else if (status > 0)
00822     ready_mask.set_bit (handle);
00823 
00824   // Call remove_reference() if needed.
00825   if (reference_counting_required)
00826     event_handler->remove_reference ();
00827 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::open ( size_t  max_number_of_handles = DEFAULT_SIZE,
bool  restart = false,
ACE_Sig_Handler sh = 0,
ACE_Timer_Queue tq = 0,
int  disable_notify_pipe = ACE_DISABLE_NOTIFY_PIPE_DEFAULT,
ACE_Reactor_Notify notify = 0 
) [inline, virtual]

Initialize the ACE_Select_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. If
  • disable_notify_pipe is non-0 the notification pipe is not created, thereby saving two I/O handles.
Note:
On Unix platforms, the maximum_number_of_handles parameter should be as large as the maximum number of file descriptors allowed for a given process. This is necessary since a file descriptor is used to directly index the array of event handlers maintained by the Reactor's handler repository. Direct indexing is used for efficiency reasons.

Implements ACE_Reactor_Impl.

Definition at line 374 of file Select_Reactor_T.cpp.

00380 {
00381   ACE_TRACE ("ACE_Select_Reactor_T::open");
00382   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00383 
00384   // Can't initialize ourselves more than once.
00385   if (this->initialized_)
00386     return -1;
00387 
00388   this->owner_ = ACE_Thread::self ();
00389   this->restart_ = restart;
00390   this->signal_handler_ = sh;
00391   this->timer_queue_ = tq;
00392   this->notify_handler_ = notify;
00393 
00394   int result = 0;
00395 
00396   // Allows the signal handler to be overridden.
00397   if (this->signal_handler_ == 0)
00398     {
00399       ACE_NEW_RETURN (this->signal_handler_,
00400                       ACE_Sig_Handler,
00401                       -1);
00402 
00403       this->delete_signal_handler_ = true;
00404     }
00405 
00406   // Allows the timer queue to be overridden.
00407   if (result != -1 && this->timer_queue_ == 0)
00408     {
00409       ACE_NEW_RETURN (this->timer_queue_,
00410                       ACE_Timer_Heap,
00411                       -1);
00412 
00413       this->delete_timer_queue_ = true;
00414     }
00415 
00416   // Allows the Notify_Handler to be overridden.
00417   if (result != -1 && this->notify_handler_ == 0)
00418     {
00419       ACE_NEW_RETURN (this->notify_handler_,
00420                       ACE_Select_Reactor_Notify,
00421                       -1);
00422 
00423       this->delete_notify_handler_ = true;
00424     }
00425 
00426   if (result != -1 && this->handler_rep_.open (size) == -1)
00427     result = -1;
00428   else if (this->notify_handler_->open (this,
00429                                         0,
00430                                         disable_notify_pipe) == -1)
00431     {
00432       ACE_ERROR ((LM_ERROR,
00433                   ACE_TEXT ("%p\n"),
00434                   ACE_TEXT ("notification pipe open failed")));
00435       result = -1;
00436     }
00437 
00438   if (result != -1)
00439     // We're all set to go.
00440     this->initialized_ = true;
00441   else
00442     // This will close down all the allocated resources properly.
00443     this->close ();
00444 
00445   return result;
00446 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::owner ( ACE_thread_t t_id  )  [inline, virtual]

Return the current owner of the thread.

Implements ACE_Reactor_Impl.

Reimplemented in ACE_TP_Reactor.

Definition at line 130 of file Select_Reactor_T.cpp.

00131 {
00132   ACE_TRACE ("ACE_Select_Reactor_T::owner");
00133   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00134   *t_id = this->owner_;
00135   return 0;
00136 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::owner ( ACE_thread_t  n_id,
ACE_thread_t o_id = 0 
) [inline, virtual]

Set the new owner of the thread and return the old owner.

Implements ACE_Reactor_Impl.

Reimplemented in ACE_TP_Reactor.

Definition at line 113 of file Select_Reactor_T.cpp.

00115 {
00116   ACE_TRACE ("ACE_Select_Reactor_T::owner");
00117   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00118 
00119   if (o_id)
00120     {
00121       *o_id = this->owner_;
00122     }
00123 
00124   this->owner_ = tid;
00125 
00126   return 0;
00127 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::ready_ops ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
int  ops 
) [inline, virtual]

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

Implements ACE_Reactor_Impl.

Definition at line 360 of file Select_Reactor_T.cpp.

00363 {
00364   ACE_TRACE ("ACE_Select_Reactor_T::ready_ops");
00365   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00366   return this->bit_ops (handle,
00367                         mask,
00368                         this->ready_set_,
00369                         ops);
00370 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::ready_ops ( ACE_Event_Handler eh,
ACE_Reactor_Mask  mask,
int  ops 
) [inline, virtual]

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

Implements ACE_Reactor_Impl.

Definition at line 133 of file Select_Reactor_T.inl.

00136 {
00137   ACE_TRACE ("ACE_Select_Reactor_T::ready_ops");
00138   return this->ready_ops (handler->get_handle (), mask, ops);
00139 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler ( const ACE_Sig_Set sigset,
ACE_Event_Handler new_sh,
ACE_Sig_Action new_disp = 0 
) [inline, virtual]

Registers new_sh to handle a set of signals sigset using the new_disp.

Implements ACE_Reactor_Impl.

Definition at line 646 of file Select_Reactor_T.cpp.

00649 {
00650   ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
00651 
00652   int result = 0;
00653 
00654 #if (ACE_NSIG > 0)
00655   for (int s = 1; s < ACE_NSIG; ++s)
00656     if ((sigset.is_member (s) == 1)
00657         && this->signal_handler_->register_handler (s,
00658                                                     new_sh,
00659                                                     new_disp) == -1)
00660       result = -1;
00661 #else  /* ACE_NSIG <= 0 */
00662   ACE_UNUSED_ARG (sigset);
00663   ACE_UNUSED_ARG (new_sh);
00664   ACE_UNUSED_ARG (new_disp);
00665 #endif /* ACE_NSIG <= 0 */
00666   return result;
00667 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::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 
) [inline, virtual]

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.

Implements ACE_Reactor_Impl.

Definition at line 63 of file Select_Reactor_T.inl.

00068 {
00069   ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
00070   return this->signal_handler_->register_handler (signum,
00071                                                   new_sh, new_disp,
00072                                                   old_sh, old_disp);
00073 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler ( const ACE_Handle_Set handles,
ACE_Event_Handler eh,
ACE_Reactor_Mask  mask 
) [inline, virtual]

Register eh with all the handles in the <Handle_Set>.

Implements ACE_Reactor_Impl.

Definition at line 297 of file Select_Reactor_T.cpp.

00300 {
00301   ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
00302   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00303   return this->register_handler_i (handles, handler, mask);
00304 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler ( ACE_HANDLE  event_handle,
ACE_HANDLE  io_handle,
ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask 
) [inline, virtual]

Not implemented.

Implements ACE_Reactor_Impl.

Definition at line 90 of file Select_Reactor_T.inl.

00094 {
00095   // Don't have an implementation for this yet...
00096   ACE_NOTSUP_RETURN (-1);
00097 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler ( ACE_HANDLE  handle,
ACE_Event_Handler eh,
ACE_Reactor_Mask  mask 
) [inline, virtual]

Register a eh with a particular mask. Note that since the handle is given the Select_Reactor will *not* call ACE_Event_Handler::get_handle() to extract the underlying I/O handle.

Implements ACE_Reactor_Impl.

Definition at line 286 of file Select_Reactor_T.cpp.

00289 {
00290   ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
00291   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00292   return this->register_handler_i (handle, handler, mask);
00293 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler ( ACE_Event_Handler eh,
ACE_Reactor_Mask  mask 
) [inline, virtual]

Register a eh with a particular mask. Note that the <Select_Reactor> will call ACE_Event_Handler::get_handle() to extract the underlying I/O handle.

Implements ACE_Reactor_Impl.

Definition at line 276 of file Select_Reactor_T.cpp.

00278 {
00279   ACE_TRACE ("ACE_Select_Reactor_T::register_handler");
00280   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00281   return this->register_handler_i (handler->get_handle (), handler, mask);
00282 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler_i ( const ACE_Handle_Set handles,
ACE_Event_Handler handler,
ACE_Reactor_Mask  mask 
) [inline, protected, virtual]

Register a set of handles.

Definition at line 629 of file Select_Reactor_T.cpp.

00632 {
00633   ACE_TRACE ("ACE_Select_Reactor_T::register_handler_i");
00634   ACE_HANDLE h;
00635 
00636   ACE_Handle_Set_Iterator handle_iter (handles);
00637   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00638     if (this->register_handler_i (h, handler, mask) == -1)
00639       return -1;
00640 
00641   return 0;
00642 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler_i ( ACE_HANDLE  handle,
ACE_Event_Handler eh,
ACE_Reactor_Mask  mask 
) [inline, protected, virtual]

Do the work of actually binding the handle and eh with the mask.

Definition at line 989 of file Select_Reactor_T.cpp.

00992 {
00993   ACE_TRACE ("ACE_Select_Reactor_T::register_handler_i");
00994 
00995   // Insert the <handle, event_handle> tuple into the Handler
00996   // Repository.
00997   return this->handler_rep_.bind (handle, event_handler, mask);
00998 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::release_token ( void   )  [inline, protected]

Release the token lock when a Win32 structured exception occurs.

Definition at line 1384 of file Select_Reactor_T.cpp.

01385 {
01386 #if defined (ACE_WIN32)
01387   this->token_.release ();
01388   return (int) EXCEPTION_CONTINUE_SEARCH;
01389 #else
01390   return 0;
01391 #endif /* ACE_WIN32 */
01392 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler ( const ACE_Sig_Set sigset  )  [inline, virtual]

Calls <remove_handler> for every signal in sigset.

Implements ACE_Reactor_Impl.

Definition at line 671 of file Select_Reactor_T.cpp.

00672 {
00673   ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
00674   int result = 0;
00675 
00676 #if (ACE_NSIG > 0)
00677   for (int s = 1; s < ACE_NSIG; ++s)
00678     if ((sigset.is_member (s) == 1)
00679         && this->signal_handler_->remove_handler (s) == -1)
00680       result = -1;
00681 #else  /* ACE_NSIG <= 0 */
00682   ACE_UNUSED_ARG (sigset);
00683 #endif /* ACE_NSIG <= 0 */
00684 
00685   return result;
00686 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler ( int  signum,
ACE_Sig_Action new_disp,
ACE_Sig_Action old_disp = 0,
int  sigkey = -1 
) [inline, virtual]

Remove the ACE_Event_Handler currently associated with signum. sigkey is ignored in this implementation since there is only one instance of a signal handler. Install the new disposition (if given) and return the previous disposition (if desired by the caller). Returns 0 on success and -1 if signum is invalid.

Implements ACE_Reactor_Impl.

Definition at line 109 of file Select_Reactor_T.inl.

00113 {
00114   ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
00115   return this->signal_handler_->remove_handler (signum, new_disp, old_disp, sigkey);
00116 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler ( const ACE_Handle_Set handle_set,
ACE_Reactor_Mask  mask 
) [inline, virtual]

Removes all the mask bindings for handles in the handle_set bind of Event_Handler. If there are no more bindings for any of these handlers then they are removed from the Select_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 328 of file Select_Reactor_T.cpp.

00330 {
00331   ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
00332   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00333   return this->remove_handler_i (handles, mask);
00334 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask 
) [inline, virtual]

Removes the mask bind of Event_Handler whose handle is handle from the Select_Reactor. If there are no more bindings for this eh then it is removed from the Select_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 348 of file Select_Reactor_T.cpp.

00350 {
00351   ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
00352   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00353   return this->remove_handler_i (handle, mask);
00354 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler ( ACE_Event_Handler eh,
ACE_Reactor_Mask  mask 
) [inline, virtual]

Removes the mask binding of eh from the Select_Reactor. If there are no more bindings for this eh then it is removed from the Select_Reactor. Note that the Select_Reactor will call <ACE_Event_Handler::get_handle> to extract the underlying I/O handle.

Implements ACE_Reactor_Impl.

Definition at line 338 of file Select_Reactor_T.cpp.

00340 {
00341   ACE_TRACE ("ACE_Select_Reactor_T::remove_handler");
00342   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00343   return this->remove_handler_i (handler->get_handle (), mask);
00344 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler_i ( const ACE_Handle_Set handles,
ACE_Reactor_Mask  mask 
) [inline, protected, virtual]

Remove a set of handles.

Definition at line 612 of file Select_Reactor_T.cpp.

00614 {
00615   ACE_TRACE ("ACE_Select_Reactor_T::remove_handler_i");
00616   ACE_HANDLE h;
00617 
00618   ACE_Handle_Set_Iterator handle_iter (handles);
00619 
00620   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00621     if (this->remove_handler_i (h, mask) == -1)
00622       return -1;
00623 
00624   return 0;
00625 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler_i ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask 
) [inline, protected, virtual]

Do the work of actually unbinding the handle and eh with the mask.

Definition at line 1002 of file Select_Reactor_T.cpp.

01004 {
01005   ACE_TRACE ("ACE_Select_Reactor_T::remove_handler_i");
01006 
01007   // Unbind this handle.
01008   return this->handler_rep_.unbind (handle, mask);
01009 }

template<class ACE_SELECT_REACTOR_TOKEN >
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::renew ( void   )  [inline, protected, virtual]

Enqueue ourselves into the list of waiting threads at the appropriate point specified by <requeue_position_>.

Implements ACE_Select_Reactor_Impl.

Definition at line 195 of file Select_Reactor_T.cpp.

00196 {
00197   ACE_TRACE ("ACE_Select_Reactor_T::renew");
00198 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00199   if (this->supress_notify_renew () == 0)
00200     this->token_.renew (this->requeue_position_);
00201 #endif /* defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) */
00202 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::requeue_position ( void   )  [inline, virtual]

Get position that the main ACE_Select_Reactor thread is requeued in the list of waiters during a <notify> callback.

Implements ACE_Reactor_Impl.

Definition at line 169 of file Select_Reactor_T.cpp.

00170 {
00171   ACE_TRACE ("ACE_Select_Reactor_T::requeue_position");
00172   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00173   return this->requeue_position_;
00174 }

template<class ACE_SELECT_REACTOR_TOKEN >
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::requeue_position ( int  rp  )  [inline, virtual]

Set position that the main ACE_Select_Reactor thread is requeued in the list of waiters during a <notify> callback.

Implements ACE_Reactor_Impl.

Definition at line 155 of file Select_Reactor_T.cpp.

00156 {
00157   ACE_TRACE ("ACE_Select_Reactor_T::requeue_position");
00158   ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_));
00159 #if defined (ACE_WIN32)
00160   ACE_UNUSED_ARG (rp);
00161   // Must always requeue ourselves "next" on Win32.
00162   this->requeue_position_ = 0;
00163 #else
00164   this->requeue_position_ = rp;
00165 #endif /* ACE_WIN32 */
00166 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::reset_timer_interval ( long  timer_id,
const ACE_Time_Value interval 
) [inline, virtual]

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.

Implements ACE_Reactor_Impl.

Definition at line 740 of file Select_Reactor_T.cpp.

00742 {
00743   ACE_TRACE ("ACE_Select_Reactor_T::reset_timer_interval");
00744   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00745 
00746   if (0 != this->timer_queue_)
00747     {
00748       return this->timer_queue_->reset_interval (timer_id, interval);
00749     }
00750 
00751   errno = ESHUTDOWN;
00752   return -1;
00753 }

template<class ACE_SELECT_REACTOR_TOKEN >
bool ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::restart ( bool  r  )  [inline, virtual]

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

Implements ACE_Reactor_Impl.

Definition at line 146 of file Select_Reactor_T.cpp.

00147 {
00148   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, false));
00149   bool const current_value = this->restart_;
00150   this->restart_ = r;
00151   return current_value;
00152 }

template<class ACE_SELECT_REACTOR_TOKEN >
bool ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::restart ( void   )  [inline, virtual]

Get the existing restart value.

Implements ACE_Reactor_Impl.

Definition at line 139 of file Select_Reactor_T.cpp.

00140 {
00141   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, false));
00142   return this->restart_;
00143 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_handler ( const ACE_Handle_Set handles  )  [inline, virtual]

Resume all handles in handle set.

Implements ACE_Reactor_Impl.

Definition at line 21 of file Select_Reactor_T.inl.

00022 {
00023   ACE_TRACE ("ACE_Select_Reactor_T::resume_handler");
00024   ACE_Handle_Set_Iterator handle_iter (handles);
00025   ACE_HANDLE h;
00026 
00027   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00028 
00029   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00030     if (this->resume_i (h) == -1)
00031       return -1;
00032 
00033   return 0;
00034 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_handler ( ACE_HANDLE  handle  )  [inline, virtual]

Resume a temporarily suspended Event_Handler associated with handle.

Implements ACE_Reactor_Impl.

Definition at line 223 of file Select_Reactor_T.cpp.

00224 {
00225   ACE_TRACE ("ACE_Select_Reactor_T::resume_handler");
00226   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00227   return this->resume_i (handle);
00228 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_handler ( ACE_Event_Handler eh  )  [inline, virtual]

Resume a temporarily suspend Event_Handler associated with eh.

Implements ACE_Reactor_Impl.

Definition at line 13 of file Select_Reactor_T.inl.

00014 {
00015   ACE_TRACE ("ACE_Select_Reactor_T::resume_handler");
00016   return this->resume_handler (h->get_handle ());
00017 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_handlers ( void   )  [inline, virtual]

Resume all the <Event_Handlers> in the Select_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 257 of file Select_Reactor_T.cpp.

00258 {
00259   ACE_TRACE ("ACE_Select_Reactor_T::resume_handlers");
00260   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00261 
00262   ACE_Event_Handler *eh = 0;
00263 
00264   for (ACE_Select_Reactor_Handler_Repository_Iterator iter (&this->handler_rep_);
00265        iter.next (eh) != 0;
00266        iter.advance ())
00267     {
00268       this->resume_i (eh->get_handle ());
00269     }
00270 
00271   return 0;
00272 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_i ( ACE_HANDLE  handle  )  [inline, protected, virtual]

Resume the <Event_Handler> associated with handle.

Definition at line 914 of file Select_Reactor_T.cpp.

00915 {
00916   ACE_TRACE ("ACE_Select_Reactor_T::resume_i");
00917   if (this->handler_rep_.find (handle) == 0)
00918     return -1;
00919 
00920   if (this->suspend_set_.rd_mask_.is_set (handle))
00921     {
00922       this->wait_set_.rd_mask_.set_bit (handle);
00923       this->suspend_set_.rd_mask_.clr_bit (handle);
00924     }
00925   if (this->suspend_set_.wr_mask_.is_set (handle))
00926     {
00927       this->wait_set_.wr_mask_.set_bit (handle);
00928       this->suspend_set_.wr_mask_.clr_bit (handle);
00929     }
00930   if (this->suspend_set_.ex_mask_.is_set (handle))
00931     {
00932       this->wait_set_.ex_mask_.set_bit (handle);
00933       this->suspend_set_.ex_mask_.clr_bit (handle);
00934     }
00935   return 0;
00936 }

template<class ACE_SELECT_REACTOR_TOKEN >
long ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::schedule_timer ( ACE_Event_Handler event_handler,
const void *  arg,
const ACE_Time_Value delay,
const ACE_Time_Value interval = ACE_Time_Value::zero 
) [inline, virtual]

Schedule an ACE_Event_Handler that will expire after an 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.

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_Impl.

Definition at line 719 of file Select_Reactor_T.cpp.

00723 {
00724   ACE_TRACE ("ACE_Select_Reactor_T::schedule_timer");
00725   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00726 
00727   if (0 != this->timer_queue_)
00728     return this->timer_queue_->schedule
00729       (handler,
00730        arg,
00731        timer_queue_->gettimeofday () + delay_time,
00732        interval);
00733 
00734   errno = ESHUTDOWN;
00735   return -1;
00736 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::schedule_wakeup ( ACE_HANDLE  handle,
ACE_Reactor_Mask  mask 
) [inline, virtual]

ADD the dispatch MASK "bit" bound with the handle and the mask.

Implements ACE_Reactor_Impl.

Definition at line 169 of file Select_Reactor_T.inl.

00171 {
00172   ACE_TRACE ("ACE_Select_Reactor_T::schedule_wakeup");
00173   return this->mask_ops (handle, mask, ACE_Reactor::ADD_MASK);
00174 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::schedule_wakeup ( ACE_Event_Handler eh,
ACE_Reactor_Mask  mask 
) [inline, virtual]

ADD the dispatch MASK "bit" bound with the eh and the mask.

Implements ACE_Reactor_Impl.

Definition at line 153 of file Select_Reactor_T.inl.

00155 {
00156   ACE_TRACE ("ACE_Select_Reactor_T::schedule_wakeup");
00157   return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::ADD_MASK);
00158 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::set_sig_handler ( ACE_Sig_Handler signal_handler  )  [inline, virtual]

Use a user specified signal handler instead.

Implements ACE_Reactor_Impl.

Definition at line 450 of file Select_Reactor_T.cpp.

00451 {
00452   delete this->signal_handler_;
00453   this->signal_handler_ = signal_handler;
00454   this->delete_signal_handler_ = false;
00455   return 0;
00456 }

template<class ACE_SELECT_REACTOR_TOKEN >
size_t ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::size ( void   )  const [inline, virtual]

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

Implements ACE_Reactor_Impl.

Definition at line 231 of file Select_Reactor_T.inl.

00232 {
00233   return this->handler_rep_.size ();
00234 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_handler ( const ACE_Handle_Set handles  )  [inline, virtual]

Suspend all handles in handle set temporarily.

Implements ACE_Reactor_Impl.

Definition at line 46 of file Select_Reactor_T.inl.

00047 {
00048   ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler");
00049   ACE_Handle_Set_Iterator handle_iter (handles);
00050   ACE_HANDLE h;
00051 
00052   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00053 
00054   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00055     if (this->suspend_i (h) == -1)
00056       return -1;
00057 
00058   return 0;
00059 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_handler ( ACE_HANDLE  handle  )  [inline, virtual]

Temporarily suspend the Event_Handler associated with handle.

Implements ACE_Reactor_Impl.

Definition at line 231 of file Select_Reactor_T.cpp.

00232 {
00233   ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler");
00234   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00235   return this->suspend_i (handle);
00236 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_handler ( ACE_Event_Handler eh  )  [inline, virtual]

Temporarily suspend the <Event_Handler> associated with eh.

Implements ACE_Reactor_Impl.

Definition at line 38 of file Select_Reactor_T.inl.

00039 {
00040   ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler");
00041   return this->suspend_handler (h->get_handle ());
00042 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_handlers ( void   )  [inline, virtual]

Suspend all the <Event_Handlers> in the Select_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 239 of file Select_Reactor_T.cpp.

00240 {
00241   ACE_TRACE ("ACE_Select_Reactor_T::suspend_handlers");
00242   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1));
00243 
00244   ACE_Event_Handler *eh = 0;
00245 
00246   for (ACE_Select_Reactor_Handler_Repository_Iterator iter (&this->handler_rep_);
00247        iter.next (eh) != 0;
00248        iter.advance ())
00249     {
00250       this->suspend_i (eh->get_handle ());
00251     }
00252 
00253   return 0;
00254 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_i ( ACE_HANDLE  handle  )  [inline, protected, virtual]

Suspend the <Event_Handler> associated with handle.

Definition at line 941 of file Select_Reactor_T.cpp.

00942 {
00943   ACE_TRACE ("ACE_Select_Reactor_T::suspend_i");
00944   if (this->handler_rep_.find (handle) == 0)
00945     return -1;
00946 
00947   if (this->wait_set_.rd_mask_.is_set (handle))
00948     {
00949       this->suspend_set_.rd_mask_.set_bit (handle);
00950       this->wait_set_.rd_mask_.clr_bit (handle);
00951     }
00952   if (this->wait_set_.wr_mask_.is_set (handle))
00953     {
00954       this->suspend_set_.wr_mask_.set_bit (handle);
00955       this->wait_set_.wr_mask_.clr_bit (handle);
00956     }
00957   if (this->wait_set_.ex_mask_.is_set (handle))
00958     {
00959       this->suspend_set_.ex_mask_.set_bit (handle);
00960       this->wait_set_.ex_mask_.clr_bit (handle);
00961     }
00962 
00963   // Kobi: we need to remove that handle from the
00964   // dispatch set as well. We use that function with all the relevant
00965   // masks - rd/wr/ex - all the mask. it is completely suspended
00966   this->clear_dispatch_mask (handle, ACE_Event_Handler::RWE_MASK);
00967   return 0;
00968 }

template<class ACE_SELECT_REACTOR_TOKEN >
ACE_Timer_Queue * ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::timer_queue ( void   )  const [inline, virtual]

Return the current ACE_Timer_Queue.

Implements ACE_Reactor_Impl.

Definition at line 459 of file Select_Reactor_T.cpp.

00460 {
00461   return this->timer_queue_;
00462 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::timer_queue ( ACE_Timer_Queue tq  )  [inline, virtual]

Set a user-specified timer queue.

Implements ACE_Reactor_Impl.

Definition at line 466 of file Select_Reactor_T.cpp.

00467 {
00468   delete this->timer_queue_;
00469   this->timer_queue_ = tq;
00470   this->delete_timer_queue_ = false;
00471   return 0;
00472 }

template<class ACE_SELECT_REACTOR_TOKEN >
bool ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::uses_event_associations ( void   )  [inline, virtual]

Return true if we any event associations were made by the reactor for the handles that it waits on, false otherwise. Since the Select_Reactor does not do any event associations, this function always return false.

Implements ACE_Reactor_Impl.

Definition at line 120 of file Select_Reactor_T.inl.

00121 {
00122   // Since the Select_Reactor does not do any event associations, this
00123   // function always return false.
00124   return false;
00125 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::wait_for_multiple_events ( ACE_Select_Reactor_Handle_Set dispatch_set,
ACE_Time_Value max_wait_time 
) [inline, protected, virtual]

Wait for events to occur.

Definition at line 1067 of file Select_Reactor_T.cpp.

01069 {
01070   ACE_TRACE ("ACE_Select_Reactor_T::wait_for_multiple_events");
01071   ACE_Time_Value timer_buf (0);
01072   ACE_Time_Value *this_timeout = 0;
01073 
01074   int number_of_active_handles = this->any_ready (dispatch_set);
01075 
01076   // If there are any bits enabled in the <ready_set_> then we'll
01077   // handle those first, otherwise we'll block in <select>.
01078 
01079   if (number_of_active_handles == 0)
01080     {
01081       do
01082         {
01083           if (this->timer_queue_ == 0)
01084             return 0;
01085 
01086           this_timeout =
01087             this->timer_queue_->calculate_timeout (max_wait_time,
01088                                                    &timer_buf);
01089 #ifdef ACE_WIN32
01090           // This arg is ignored on Windows and causes pointer
01091           // truncation warnings on 64-bit compiles.
01092           int const width = 0;
01093 #else
01094           int const width = this->handler_rep_.max_handlep1 ();
01095 #endif  /* ACE_WIN32 */
01096 
01097           dispatch_set.rd_mask_ = this->wait_set_.rd_mask_;
01098           dispatch_set.wr_mask_ = this->wait_set_.wr_mask_;
01099           dispatch_set.ex_mask_ = this->wait_set_.ex_mask_;
01100           number_of_active_handles = ACE_OS::select (width,
01101                                                      dispatch_set.rd_mask_,
01102                                                      dispatch_set.wr_mask_,
01103                                                      dispatch_set.ex_mask_,
01104                                                      this_timeout);
01105         }
01106       while (number_of_active_handles == -1 && this->handle_error () > 0);
01107 
01108       if (number_of_active_handles > 0)
01109         {
01110 #if !defined (ACE_WIN32)
01111           // Resynchronize the fd_sets so their "max" is set properly.
01112           dispatch_set.rd_mask_.sync (this->handler_rep_.max_handlep1 ());
01113           dispatch_set.wr_mask_.sync (this->handler_rep_.max_handlep1 ());
01114           dispatch_set.ex_mask_.sync (this->handler_rep_.max_handlep1 ());
01115 #endif /* ACE_WIN32 */
01116         }
01117       else if (number_of_active_handles == -1)
01118         {
01119           // Normally, select() will reset the bits in dispatch_set
01120           // so that only those filed descriptors that are ready will
01121           // have bits set.  However, when an error occurs, the bit
01122           // set remains as it was when the select call was first made.
01123           // Thus, we now have a dispatch_set that has every file
01124           // descriptor that was originally waited for, which is not
01125           // correct.  We must clear all the bit sets because we
01126           // have no idea if any of the file descriptors is ready.
01127           //
01128           // NOTE: We dont have a test case to reproduce this
01129           // problem. But pleae dont ignore this and remove it off.
01130           dispatch_set.rd_mask_.reset ();
01131           dispatch_set.wr_mask_.reset ();
01132           dispatch_set.ex_mask_.reset ();
01133         }
01134     }
01135 
01136   // Return the number of events to dispatch.
01137   return number_of_active_handles;
01138 }

template<class ACE_SELECT_REACTOR_TOKEN >
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::wakeup_all_threads ( void   )  [inline, virtual]

Wake up all threads in waiting in the event loop.

Implements ACE_Reactor_Impl.

Definition at line 192 of file Select_Reactor_T.inl.

00193 {
00194   // Send a notification, but don't block if there's no one to receive
00195   // it.
00196   this->notify (0, ACE_Event_Handler::NULL_MASK, (ACE_Time_Value *) &ACE_Time_Value::zero);
00197 }

template<class ACE_SELECT_REACTOR_TOKEN >
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::work_pending ( const ACE_Time_Value max_wait_time = ACE_Time_Value::zero  )  [inline, virtual]

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".

Implements ACE_Reactor_Impl.

Definition at line 1013 of file Select_Reactor_T.cpp.

01014 {
01015   ACE_TRACE ("ACE_Select_Reactor_T::work_pending");
01016 
01017   ACE_Time_Value mwt (max_wait_time);
01018   ACE_MT (ACE_Countdown_Time countdown (&mwt));
01019 
01020   ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN,
01021                             ace_mon,
01022                             this->token_,
01023                             -1));
01024 
01025   if (this->deactivated_)
01026     return 0;
01027 
01028   // Update the countdown to reflect time waiting for the mutex.
01029   ACE_MT (countdown.update ());
01030 
01031   ACE_Time_Value timer_buf (0);
01032   ACE_Time_Value *this_timeout =
01033     this->timer_queue_->calculate_timeout (&mwt, &timer_buf);
01034 
01035   // Check if we have timers to fire.
01036   bool const timers_pending =
01037     (this_timeout != 0 && *this_timeout != mwt ? true : false);
01038 
01039 #ifdef ACE_WIN32
01040   // This arg is ignored on Windows and causes pointer truncation
01041   // warnings on 64-bit compiles.
01042   int const width = 0;
01043 #else
01044   int const width = this->handler_rep_.max_handlep1 ();
01045 #endif  /* ACE_WIN32 */
01046 
01047   ACE_Select_Reactor_Handle_Set fd_set;
01048   fd_set.rd_mask_ = this->wait_set_.rd_mask_;
01049   fd_set.wr_mask_ = this->wait_set_.wr_mask_;
01050   fd_set.ex_mask_ = this->wait_set_.ex_mask_;
01051 
01052   int const nfds = ACE_OS::select (width,
01053                                    fd_set.rd_mask_,
01054                                    fd_set.wr_mask_,
01055                                    fd_set.ex_mask_,
01056                                    this_timeout);
01057 
01058   // If timers are pending, override any timeout from the select()
01059   // call.
01060   return (nfds == 0 && timers_pending ? 1 : nfds);
01061 }


Member Data Documentation

template<class ACE_SELECT_REACTOR_TOKEN>
ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Reimplemented from ACE_Reactor_Impl.

Reimplemented in ACE_Priority_Reactor, and ACE_TP_Reactor.

Definition at line 545 of file Select_Reactor_T.h.

template<class ACE_SELECT_REACTOR_TOKEN>
sig_atomic_t ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::deactivated_ [protected]

This flag is used to keep track of whether we are actively handling events or not.

Definition at line 695 of file Select_Reactor_T.h.

template<class ACE_SELECT_REACTOR_TOKEN>
ACE_Lock_Adapter<ACE_SELECT_REACTOR_TOKEN> ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::lock_adapter_ [protected]

Adapter used to return internal lock to outside world.

Definition at line 685 of file Select_Reactor_T.h.

template<class ACE_SELECT_REACTOR_TOKEN>
ACE_SELECT_REACTOR_TOKEN ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::token_ [protected]

Synchronization token for the MT_SAFE ACE_Select_Reactor.

Definition at line 682 of file Select_Reactor_T.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated on Fri Nov 6 23:26:02 2009 for ACE by  doxygen 1.6.1