An object oriented event demultiplexor and event handler dispatcher. More...
#include <Select_Reactor_T.h>
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_Queue * | timer_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_Handler * | find_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_Lock & | lock (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_Handler * | find_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_ |
Private Member Functions | |
ACE_Select_Reactor_T (const ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN > &) | |
Deny access since member-wise won't work... | |
ACE_Select_Reactor_T < ACE_SELECT_REACTOR_TOKEN > & | operator= (const 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.
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 | |||
) |
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.
: ACE_Select_Reactor_Impl (mask_signals) , token_ (s_queue) , lock_adapter_ (token_) , deactivated_ (0) { ACE_TRACE ("ACE_Select_Reactor_T::ACE_Select_Reactor_T"); this->token_.reactor (*this); // First try to open the Reactor with the hard-coded default. if (this->open (ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>::DEFAULT_SIZE, 0, sh, tq, disable_notify_pipe, notify) == -1) { // The hard-coded default Reactor size failed, so attempt to // determine the size at run-time by checking the process file // descriptor limit on platforms that support this feature. // There is no need to deallocate resources from previous open() // call since the open() method deallocates any resources prior // to exiting if an error was encountered. // Set the default reactor size to be the current limit on the // number of file descriptors available to the process. This // size is not necessarily the maximum limit. if (this->open (ACE::max_handles (), 0, sh, tq, disable_notify_pipe, notify) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Select_Reactor_T::open ") ACE_TEXT ("failed inside ") ACE_TEXT ("ACE_Select_Reactor_T::CTOR"))); } }
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 | |||
) |
Initialize ACE_Select_Reactor
with size
Definition at line 527 of file Select_Reactor_T.cpp.
: ACE_Select_Reactor_Impl (mask_signals) , token_ (s_queue) , lock_adapter_ (token_) , deactivated_ (0) { ACE_TRACE ("ACE_Select_Reactor_T::ACE_Select_Reactor_T"); this->token_.reactor (*this); if (this->open (size, restart, sh, tq, disable_notify_pipe, notify) == -1) ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("ACE_Select_Reactor_T::open ") ACE_TEXT ("failed inside ACE_Select_Reactor_T::CTOR"))); }
ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::~ACE_Select_Reactor_T | ( | void | ) | [virtual] |
Close down the select_reactor and release all of its resources.
Definition at line 604 of file Select_Reactor_T.cpp.
ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::ACE_Select_Reactor_T | ( | const ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN > & | ) | [private] |
Deny access since member-wise won't work...
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::alertable_handle_events | ( | ACE_Time_Value * | max_wait_time = 0 |
) | [virtual] |
Implements ACE_Reactor_Impl.
Definition at line 200 of file Select_Reactor_T.inl.
{ return this->handle_events (max_wait_time); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::alertable_handle_events | ( | ACE_Time_Value & | max_wait_time | ) | [virtual] |
Implements ACE_Reactor_Impl.
Definition at line 206 of file Select_Reactor_T.inl.
{ return this->handle_events (max_wait_time); }
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.
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::any_ready_i | ( | ACE_Select_Reactor_Handle_Set & | handle_set | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::any_ready_i"); int const number_ready = this->ready_set_.rd_mask_.num_set () + this->ready_set_.wr_mask_.num_set () + this->ready_set_.ex_mask_.num_set (); // number_ready > 0 meaning there are handles in the ready_set // &wait_set != &(this->ready_set_) means that we need to copy // the handles from the ready_set to the wait set because the // wait_set_ doesn't contain all the handles in the ready_set_ if (number_ready > 0 && &wait_set != &(this->ready_set_)) { wait_set.rd_mask_ = this->ready_set_.rd_mask_; wait_set.wr_mask_ = this->ready_set_.wr_mask_; wait_set.ex_mask_ = this->ready_set_.ex_mask_; this->ready_set_.rd_mask_.reset (); this->ready_set_.wr_mask_.reset (); this->ready_set_.ex_mask_.reset (); } return number_ready; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::cancel_timer | ( | ACE_Event_Handler * | event_handler, | |
int | dont_call_handle_close = 1 | |||
) | [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.
Reimplemented in ACE_FlReactor, ACE_FoxReactor, ACE_QtReactor, ACE_TkReactor, and ACE_XtReactor.
Definition at line 689 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::cancel_timer"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); if (this->timer_queue_ != 0) return this->timer_queue_->cancel (handler, dont_call_handle_close); else return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::cancel_timer | ( | long | timer_id, | |
const void ** | arg = 0 , |
|||
int | dont_call_handle_close = 1 | |||
) | [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.
Reimplemented in ACE_FlReactor, ACE_FoxReactor, ACE_QtReactor, ACE_TkReactor, and ACE_XtReactor.
Definition at line 702 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::cancel_timer"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); if (this->timer_queue_ != 0) return this->timer_queue_->cancel (timer_id, arg, dont_call_handle_close); else return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::cancel_wakeup | ( | ACE_Event_Handler * | eh, | |
ACE_Reactor_Mask | mask | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::cancel_wakeup"); return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::CLR_MASK); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::cancel_wakeup | ( | ACE_HANDLE | handle, | |
ACE_Reactor_Mask | mask | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::cancel_wakeup"); return this->mask_ops (handle, mask, ACE_Reactor::CLR_MASK); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::check_handles | ( | void | ) | [protected, virtual] |
Make sure the handles are all valid.
Definition at line 1458 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::check_handles"); #if defined (ACE_WIN32) || defined (__MVS__) || defined (ACE_VXWORKS) ACE_Time_Value time_poll = ACE_Time_Value::zero; ACE_Handle_Set rd_mask; #endif /* ACE_WIN32 || MVS || ACE_VXWORKS */ int result = 0; /* * It's easier to run through the handler repository iterator, but that * misses handles that are registered on a handler that doesn't implement * get_handle(). So, build a handle set that's the union of the three * wait_sets (rd, wrt, ex) and run through that. Bad handles get cleared * out of all sets. */ ACE_HANDLE h; ACE_Handle_Set check_set (this->wait_set_.rd_mask_); ACE_Handle_Set_Iterator wr_iter (this->wait_set_.wr_mask_); while ((h = wr_iter ()) != ACE_INVALID_HANDLE) check_set.set_bit (h); ACE_Handle_Set_Iterator ex_iter (this->wait_set_.ex_mask_); while ((h = ex_iter ()) != ACE_INVALID_HANDLE) check_set.set_bit (h); ACE_Handle_Set_Iterator check_iter (check_set); while ((h = check_iter ()) != ACE_INVALID_HANDLE) { #if defined (ACE_WIN32) || defined (__MVS__) || defined (ACE_VXWORKS) // Win32 needs to do the check this way because fstat won't work on // a socket handle. MVS Open Edition needs to do it this way because, // even though the docs say to check a handle with either select or // fstat, the fstat method always says the handle is ok. // pSOS needs to do it this way because file handles and socket handles // are maintained by separate pieces of the system. VxWorks needs the select // variant since fstat always returns an error on socket FDs. rd_mask.set_bit (h); # if defined (ACE_WIN32) // This arg is ignored on Windows and causes pointer truncation // warnings on 64-bit compiles. int select_width = 0; # else int select_width = int (h) + 1; # endif /* ACE_WIN32 */ if (ACE_OS::select (select_width, rd_mask, 0, 0, &time_poll) < 0) { result = 1; this->remove_handler_i (h, ACE_Event_Handler::ALL_EVENTS_MASK); } rd_mask.clr_bit (h); #else /* !ACE_WIN32 && !MVS && !VXWORKS */ struct stat temp; if (ACE_OS::fstat (h, &temp) == -1) { result = 1; this->remove_handler_i (h, ACE_Event_Handler::ALL_EVENTS_MASK); } #endif /* ACE_WIN32 || MVS */ } return result; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::close | ( | void | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::close"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); if (this->delete_signal_handler_) { delete this->signal_handler_; this->signal_handler_ = 0; this->delete_signal_handler_ = false; } this->handler_rep_.close (); if (this->delete_timer_queue_) { delete this->timer_queue_; this->timer_queue_ = 0; this->delete_timer_queue_ = false; } if (this->notify_handler_ != 0) this->notify_handler_->close (); if (this->delete_notify_handler_) { delete this->notify_handler_; this->notify_handler_ = 0; this->delete_notify_handler_ = false; } this->initialized_ = false; return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::current_info | ( | ACE_HANDLE | , | |
size_t & | size | |||
) | [virtual] |
Returns -1 (not used in this implementation);.
Implements ACE_Reactor_Impl.
Definition at line 598 of file Select_Reactor_T.cpp.
{
return -1;
}
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::deactivate | ( | int | do_stop | ) | [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.
{ { ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_)); this->deactivated_ = do_stop; } this->wakeup_all_threads (); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::deactivated | ( | void | ) | [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.
{ return this->deactivated_; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dispatch | ( | int | nfound, | |
ACE_Select_Reactor_Handle_Set & | dispatch_set | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::dispatch"); int io_handlers_dispatched = 0; int other_handlers_dispatched = 0; int signal_occurred = 0; // The following do/while loop keeps dispatching as long as there // are still active handles. Note that the only way we should ever // iterate more than once through this loop is if signals occur // while we're dispatching other handlers. do { // We expect that the loop will decrease the number of active // handles in each iteration. If it does not, then something is // inconsistent in the state of the Reactor and we should avoid // the loop. Please read the comments on bug 2540 for more // details. int initial_handle_count = active_handle_count; // Note that we keep track of changes to our state. If any of // the dispatch_*() methods below return -1 it means that the // <wait_set_> state has changed as the result of an // <ACE_Event_Handler> being dispatched. This means that we // need to bail out and rerun the select() loop since our // existing notion of handles in <dispatch_set> may no longer be // correct. // // In the beginning, our state starts out unchanged. After // every iteration (i.e., due to signals), our state starts out // unchanged again. this->state_changed_ = false; // Perform the Template Method for dispatching all the handlers. // First check for interrupts. if (active_handle_count == -1) { // Bail out -- we got here since <select> was interrupted. if (ACE_Sig_Handler::sig_pending () != 0) { ACE_Sig_Handler::sig_pending (0); // If any HANDLES in the <ready_set_> are activated as a // result of signals they should be dispatched since // they may be time critical... active_handle_count = this->any_ready (dispatch_set); // Record the fact that the Reactor has dispatched a // handle_signal() method. We need this to return the // appropriate count below. signal_occurred = 1; } else return -1; } // Handle timers early since they may have higher latency // constraints than I/O handlers. Ideally, the order of // dispatching should be a strategy... else if (this->dispatch_timer_handlers (other_handlers_dispatched) == -1) // State has changed or timer queue has failed, exit loop. break; // Check to see if there are no more I/O handles left to // dispatch AFTER we've handled the timers... else if (active_handle_count == 0) return io_handlers_dispatched + other_handlers_dispatched + signal_occurred; // Next dispatch the notification handlers (if there are any to // dispatch). These are required to handle multi-threads that // are trying to update the <Reactor>. else if (this->dispatch_notification_handlers (dispatch_set, active_handle_count, other_handlers_dispatched) == -1) // State has changed or a serious failure has occured, so exit // loop. break; // Finally, dispatch the I/O handlers. else if (this->dispatch_io_handlers (dispatch_set, active_handle_count, io_handlers_dispatched) == -1) // State has changed, so exit loop. break; // if state changed, we need to re-eval active_handle_count, // so we will not end with an endless loop if (initial_handle_count == active_handle_count || this->state_changed_) { active_handle_count = this->any_ready (dispatch_set); } } while (active_handle_count > 0); return io_handlers_dispatched + other_handlers_dispatched + signal_occurred; }
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 | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::dispatch_io_handlers"); // Handle output events (this code needs to come first to handle the // obscure case of piggy-backed data coming along with the final // handshake message of a nonblocking connection). if (this->dispatch_io_set (number_of_active_handles, number_of_handlers_dispatched, ACE_Event_Handler::WRITE_MASK, dispatch_set.wr_mask_, this->ready_set_.wr_mask_, &ACE_Event_Handler::handle_output) == -1) { number_of_active_handles -= number_of_handlers_dispatched; return -1; } // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Select_Reactor_T::dispatch - EXCEPT\n"))); if (this->dispatch_io_set (number_of_active_handles, number_of_handlers_dispatched, ACE_Event_Handler::EXCEPT_MASK, dispatch_set.ex_mask_, this->ready_set_.ex_mask_, &ACE_Event_Handler::handle_exception) == -1) { number_of_active_handles -= number_of_handlers_dispatched; return -1; } // ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE_Select_Reactor_T::dispatch - READ\n"))); if (this->dispatch_io_set (number_of_active_handles, number_of_handlers_dispatched, ACE_Event_Handler::READ_MASK, dispatch_set.rd_mask_, this->ready_set_.rd_mask_, &ACE_Event_Handler::handle_input) == -1) { number_of_active_handles -= number_of_handlers_dispatched; return -1; } number_of_active_handles -= number_of_handlers_dispatched; return 0; }
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 | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::dispatch_io_set"); ACE_HANDLE handle; ACE_Handle_Set_Iterator handle_iter (dispatch_mask); while ((handle = handle_iter ()) != ACE_INVALID_HANDLE && number_of_handlers_dispatched < number_of_active_handles) { ++number_of_handlers_dispatched; this->notify_handle (handle, mask, ready_mask, this->handler_rep_.find (handle), callback); // clear the bit from that dispatch mask, // so when we need to restart the iteration (rebuilding the iterator...) // we will not dispatch the already dispatched handlers this->clear_dispatch_mask (handle, mask); if (this->state_changed_) { handle_iter.reset_state (); this->state_changed_ = false; } } return 0; }
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 | |||
) | [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.
{ // Check to see if the ACE_HANDLE associated with the // Select_Reactor's notify hook is enabled. If so, it means that // one or more other threads are trying to update the // ACE_Select_Reactor_T's internal tables or the notify pipe is // enabled. We'll handle all these threads and notifications, and // then break out to continue the event loop. int const n = this->notify_handler_->dispatch_notifications (number_of_active_handles, dispatch_set.rd_mask_); if (n == -1) return -1; else { number_of_handlers_dispatched += n; number_of_active_handles -= n; } // Same as dispatch_timer_handlers // No need to do anything with the state changed. That is because // unbind already handles the case where someone unregister some // kind of handle and unbind it. (::unbind calls the function // state_changed () to reflect ant change with that) // return this->state_changed_ ? -1 : 0; return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dispatch_timer_handlers | ( | int & | number_dispatched | ) | [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.
{ number_of_handlers_dispatched += this->timer_queue_->expire (); return 0; }
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::dump | ( | void | ) | const [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.
{ #if defined (ACE_HAS_DUMP) ACE_TRACE ("ACE_Select_Reactor_T::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); this->timer_queue_->dump (); this->handler_rep_.dump (); this->signal_handler_->dump (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("delete_signal_handler_ = %d\n"), this->delete_signal_handler_)); ACE_HANDLE h; for (ACE_Handle_Set_Iterator handle_iter_wr (this->wait_set_.wr_mask_); (h = handle_iter_wr ()) != ACE_INVALID_HANDLE;) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("write_handle = %d\n"), h)); for (ACE_Handle_Set_Iterator handle_iter_rd (this->wait_set_.rd_mask_); (h = handle_iter_rd ()) != ACE_INVALID_HANDLE;) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("read_handle = %d\n"), h)); for (ACE_Handle_Set_Iterator handle_iter_ex (this->wait_set_.ex_mask_); (h = handle_iter_ex ()) != ACE_INVALID_HANDLE;) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("except_handle = %d\n"), h)); for (ACE_Handle_Set_Iterator handle_iter_wr_ready (this->ready_set_.wr_mask_); (h = handle_iter_wr_ready ()) != ACE_INVALID_HANDLE;) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("write_handle_ready = %d\n"), h)); for (ACE_Handle_Set_Iterator handle_iter_rd_ready (this->ready_set_.rd_mask_); (h = handle_iter_rd_ready ()) != ACE_INVALID_HANDLE;) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("read_handle_ready = %d\n"), h)); for (ACE_Handle_Set_Iterator handle_iter_ex_ready (this->ready_set_.ex_mask_); (h = handle_iter_ex_ready ()) != ACE_INVALID_HANDLE;) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("except_handle_ready = %d\n"), h)); for (ACE_Handle_Set_Iterator handle_iter_su_ready (this->suspend_set_.wr_mask_); (h = handle_iter_su_ready ()) != ACE_INVALID_HANDLE;) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("write_handle_suspend = %d\n"), h)); for (ACE_Handle_Set_Iterator handle_iter_su_ready (this->suspend_set_.rd_mask_); (h = handle_iter_su_ready ()) != ACE_INVALID_HANDLE;) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("read_handle_suspend = %d\n"), h)); for (ACE_Handle_Set_Iterator handle_iter_su_ready (this->suspend_set_.ex_mask_); (h = handle_iter_su_ready ()) != ACE_INVALID_HANDLE;) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("except_handle_suspend = %d\n"), h)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("restart_ = %d\n"), this->restart_)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("requeue_position_ = %d\n"), this->requeue_position_)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("initialized_ = %d\n"), this->initialized_)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("owner_ = %d\n"), this->owner_)); #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) this->notify_handler_->dump (); this->token_.dump (); #endif /* ACE_MT_SAFE */ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); #endif /* ACE_HAS_DUMP */ }
ACE_Event_Handler * ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::find_handler | ( | ACE_HANDLE | handle | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::find_handler"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, 0)); return this->find_handler_i (handle); }
ACE_Event_Handler * ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::find_handler_i | ( | ACE_HANDLE | handle | ) | [protected, virtual] |
Implement the public handler method.
Definition at line 861 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::find_handler_i"); ACE_Event_Handler *event_handler = this->handler_rep_.find (handle); if (event_handler) { event_handler->add_reference (); } return event_handler; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_error | ( | void | ) | [protected, virtual] |
Take corrective action when errors occur.
Definition at line 768 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::handle_error"); #if defined (linux) && defined (ERESTARTNOHAND) int const error = errno; // Avoid multiple TSS accesses. if (error == EINTR || error == ERESTARTNOHAND) return this->restart_; #else if (errno == EINTR) return this->restart_; #endif /* linux && ERESTARTNOHAND */ #if defined (__MVS__) || defined (ACE_WIN32) || defined (ACE_VXWORKS) // On MVS Open Edition and Win32, there can be a number of failure // codes on a bad socket, so check_handles on anything other than // EINTR. VxWorks doesn't even bother to always set errno on error // in select (specifically, it doesn't return EBADF for bad FDs). else return this->check_handles (); #else else if (errno == EBADF) return this->check_handles (); else return -1; #endif /* __MVS__ || ACE_WIN32 */ }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events | ( | ACE_Time_Value * | max_wait_time = 0 |
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::handle_events"); #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) // Stash the current time -- the destructor of this object will // automatically compute how much time elapsed since this method was // called. ACE_Countdown_Time countdown (max_wait_time); ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1); if (ACE_OS::thr_equal (ACE_Thread::self (), this->owner_) == 0 || this->deactivated_) return -1; // Update the countdown to reflect time waiting for the mutex. countdown.update (); #else if (this->deactivated_) return -1; #endif /* ACE_MT_SAFE */ return this->handle_events_i (max_wait_time); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events | ( | ACE_Time_Value & | max_wait_time | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::handle_events"); return this->handle_events (&max_wait_time); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handle_events_i | ( | ACE_Time_Value * | max_wait_time = 0 |
) | [protected] |
Stops the VC++ compiler from bitching about exceptions and destructors.
Definition at line 1425 of file Select_Reactor_T.cpp.
{ int result = -1; ACE_SEH_TRY { // We use the data member dispatch_set_ as the current dispatch // set. // We need to start from a clean dispatch_set this->dispatch_set_.rd_mask_.reset (); this->dispatch_set_.wr_mask_.reset (); this->dispatch_set_.ex_mask_.reset (); int number_of_active_handles = this->wait_for_multiple_events (this->dispatch_set_, max_wait_time); result = this->dispatch (number_of_active_handles, this->dispatch_set_); } ACE_SEH_EXCEPT (this->release_token ()) { // As it stands now, we catch and then rethrow all Win32 // structured exceptions so that we can make sure to release the // <token_> lock correctly. } return result; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handler | ( | ACE_HANDLE | handle, | |
ACE_Reactor_Mask | mask, | |||
ACE_Event_Handler ** | eh = 0 | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::handler"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->handler_i (handle, mask, handler); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handler | ( | int | signum, | |
ACE_Event_Handler ** | handler = 0 | |||
) | [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.
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handler_i | ( | ACE_HANDLE | handle, | |
ACE_Reactor_Mask | mask, | |||
ACE_Event_Handler ** | eh = 0 | |||
) | [protected, virtual] |
Implement the public handler method.
Definition at line 879 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::handler_i"); ACE_Event_Handler *event_handler = this->handler_rep_.find (handle); if (event_handler == 0) return -1; else { if ((ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK) || ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)) && this->wait_set_.rd_mask_.is_set (handle) == 0) return -1; if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK) && this->wait_set_.wr_mask_.is_set (handle) == 0) return -1; if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK) && this->wait_set_.ex_mask_.is_set (handle) == 0) return -1; } if (eh != 0) { *eh = event_handler; event_handler->add_reference (); } return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::handler_i | ( | int | signum, | |
ACE_Event_Handler ** | eh = 0 | |||
) | [protected, virtual] |
Implement the public handler method.
Definition at line 90 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::handler_i"); ACE_Event_Handler *handler = this->signal_handler_->handler (signum); if (handler == 0) return -1; else if (eh != 0) *eh = handler; return 0; }
bool ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::initialized | ( | void | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::initialized"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, false)); return this->initialized_; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::is_suspended_i | ( | ACE_HANDLE | handle | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::is_suspended_i"); if (this->handler_rep_.find (handle) == 0) return 0; return this->suspend_set_.rd_mask_.is_set (handle) || this->suspend_set_.wr_mask_.is_set (handle) || this->suspend_set_.ex_mask_.is_set (handle); }
ACE_Lock & ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::lock | ( | void | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::lock"); return this->lock_adapter_; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::mask_ops | ( | ACE_Event_Handler * | eh, | |
ACE_Reactor_Mask | mask, | |||
int | ops | |||
) | [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.
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::mask_ops | ( | ACE_HANDLE | handle, | |
ACE_Reactor_Mask | mask, | |||
int | ops | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::mask_ops"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); // If the handle is not suspended, then set the ops on the // <wait_set_>, otherwise set the <suspend_set_>. if (this->is_suspended_i (handle)) return this->bit_ops (handle, mask, this->suspend_set_, ops); else return this->bit_ops (handle, mask, this->wait_set_, ops); }
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::max_notify_iterations | ( | int | iterations | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::max_notify_iterations"); ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_)); this->notify_handler_->max_notify_iterations (iterations); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::max_notify_iterations | ( | void | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::max_notify_iterations"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->notify_handler_->max_notify_iterations (); }
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 | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::notify"); // Pass over both the Event_Handler *and* the mask to allow the // caller to dictate which Event_Handler method the receiver // invokes. Note that this call can timeout. ssize_t n = -1; if (this->notify_handler_) { n = this->notify_handler_->notify (eh, mask, timeout); } return n == -1 ? -1 : 0; }
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 | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::notify_handle"); // Check for removed handlers. if (event_handler == 0) return; bool const reference_counting_required = event_handler->reference_counting_policy ().value () == ACE_Event_Handler::Reference_Counting_Policy::ENABLED; // Call add_reference() if needed. if (reference_counting_required) { event_handler->add_reference (); } int const status = (event_handler->*ptmf) (handle); if (status < 0) this->remove_handler_i (handle, mask); else if (status > 0) ready_mask.set_bit (handle); // Call remove_reference() if needed. if (reference_counting_required) event_handler->remove_reference (); }
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 | |||
) | [virtual] |
Initialize the ACE_Select_Reactor
to manage
ACE_Reactor's
handle_events
method will be restarted automatically when EINTR
occurs. If Implements ACE_Reactor_Impl.
Definition at line 374 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::open"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); // Can't initialize ourselves more than once. if (this->initialized_) return -1; this->owner_ = ACE_Thread::self (); this->restart_ = restart; this->signal_handler_ = sh; this->timer_queue_ = tq; this->notify_handler_ = notify; int result = 0; // Allows the signal handler to be overridden. if (this->signal_handler_ == 0) { ACE_NEW_RETURN (this->signal_handler_, ACE_Sig_Handler, -1); this->delete_signal_handler_ = true; } // Allows the timer queue to be overridden. if (result != -1 && this->timer_queue_ == 0) { ACE_NEW_RETURN (this->timer_queue_, ACE_Timer_Heap, -1); this->delete_timer_queue_ = true; } // Allows the Notify_Handler to be overridden. if (result != -1 && this->notify_handler_ == 0) { ACE_NEW_RETURN (this->notify_handler_, ACE_Select_Reactor_Notify, -1); this->delete_notify_handler_ = true; } if (result != -1 && this->handler_rep_.open (size) == -1) result = -1; else if (this->notify_handler_->open (this, 0, disable_notify_pipe) == -1) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("notification pipe open failed"))); result = -1; } if (result != -1) // We're all set to go. this->initialized_ = true; else // This will close down all the allocated resources properly. this->close (); return result; }
ACE_Select_Reactor_T<ACE_SELECT_REACTOR_TOKEN>& ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::operator= | ( | const ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN > & | ) | [private] |
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::owner | ( | ACE_thread_t | n_id, | |
ACE_thread_t * | o_id = 0 | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::owner"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); if (o_id) { *o_id = this->owner_; } this->owner_ = tid; return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::owner | ( | ACE_thread_t * | t_id | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::owner"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); *t_id = this->owner_; return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::ready_ops | ( | ACE_Event_Handler * | eh, | |
ACE_Reactor_Mask | mask, | |||
int | ops | |||
) | [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.
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::ready_ops | ( | ACE_HANDLE | handle, | |
ACE_Reactor_Mask | mask, | |||
int | ops | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::ready_ops"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->bit_ops (handle, mask, this->ready_set_, ops); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler | ( | const ACE_Handle_Set & | handles, | |
ACE_Event_Handler * | eh, | |||
ACE_Reactor_Mask | mask | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::register_handler"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->register_handler_i (handles, handler, mask); }
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 | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::register_handler"); return this->signal_handler_->register_handler (signum, new_sh, new_disp, old_sh, old_disp); }
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 | |||
) | [virtual] |
Not implemented.
Implements ACE_Reactor_Impl.
Definition at line 90 of file Select_Reactor_T.inl.
{ // Don't have an implementation for this yet... ACE_NOTSUP_RETURN (-1); }
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 | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::register_handler"); int result = 0; #if (ACE_NSIG > 0) for (int s = 1; s < ACE_NSIG; ++s) if ((sigset.is_member (s) == 1) && this->signal_handler_->register_handler (s, new_sh, new_disp) == -1) result = -1; #else /* ACE_NSIG <= 0 */ ACE_UNUSED_ARG (sigset); ACE_UNUSED_ARG (new_sh); ACE_UNUSED_ARG (new_disp); #endif /* ACE_NSIG <= 0 */ return result; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler | ( | ACE_Event_Handler * | eh, | |
ACE_Reactor_Mask | mask | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::register_handler"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->register_handler_i (handler->get_handle (), handler, mask); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler | ( | ACE_HANDLE | handle, | |
ACE_Event_Handler * | eh, | |||
ACE_Reactor_Mask | mask | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::register_handler"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->register_handler_i (handle, handler, mask); }
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 | |||
) | [protected, virtual] |
Register a set of handles.
Reimplemented in ACE_FlReactor, ACE_FoxReactor, ACE_QtReactor, ACE_TkReactor, and ACE_XtReactor.
Definition at line 629 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::register_handler_i"); ACE_HANDLE h; ACE_Handle_Set_Iterator handle_iter (handles); while ((h = handle_iter ()) != ACE_INVALID_HANDLE) if (this->register_handler_i (h, handler, mask) == -1) return -1; return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::register_handler_i | ( | ACE_HANDLE | handle, | |
ACE_Event_Handler * | eh, | |||
ACE_Reactor_Mask | mask | |||
) | [protected, virtual] |
Do the work of actually binding the handle and eh with the mask.
Reimplemented in ACE_FlReactor, ACE_FoxReactor, ACE_QtReactor, ACE_TkReactor, and ACE_XtReactor.
Definition at line 989 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::register_handler_i"); // Insert the <handle, event_handle> tuple into the Handler // Repository. return this->handler_rep_.bind (handle, event_handler, mask); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::release_token | ( | void | ) | [protected] |
Release the token lock when a Win32 structured exception occurs.
Definition at line 1384 of file Select_Reactor_T.cpp.
{ #if defined (ACE_WIN32) this->token_.release (); return (int) EXCEPTION_CONTINUE_SEARCH; #else return 0; #endif /* ACE_WIN32 */ }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler | ( | ACE_HANDLE | handle, | |
ACE_Reactor_Mask | mask | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->remove_handler_i (handle, mask); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler | ( | ACE_Event_Handler * | eh, | |
ACE_Reactor_Mask | mask | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->remove_handler_i (handler->get_handle (), mask); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler | ( | const ACE_Handle_Set & | handle_set, | |
ACE_Reactor_Mask | mask | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->remove_handler_i (handles, mask); }
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 | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler"); return this->signal_handler_->remove_handler (signum, new_disp, old_disp, sigkey); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler | ( | const ACE_Sig_Set & | sigset | ) | [virtual] |
Calls <remove_handler> for every signal in sigset.
Implements ACE_Reactor_Impl.
Definition at line 671 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler"); int result = 0; #if (ACE_NSIG > 0) for (int s = 1; s < ACE_NSIG; ++s) if ((sigset.is_member (s) == 1) && this->signal_handler_->remove_handler (s) == -1) result = -1; #else /* ACE_NSIG <= 0 */ ACE_UNUSED_ARG (sigset); #endif /* ACE_NSIG <= 0 */ return result; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler_i | ( | ACE_HANDLE | handle, | |
ACE_Reactor_Mask | mask | |||
) | [protected, virtual] |
Do the work of actually unbinding the handle and eh with the mask.
Reimplemented in ACE_FlReactor, ACE_FoxReactor, ACE_QtReactor, ACE_TkReactor, and ACE_XtReactor.
Definition at line 1002 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler_i"); // Unbind this handle. return this->handler_rep_.unbind (handle, mask); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::remove_handler_i | ( | const ACE_Handle_Set & | handles, | |
ACE_Reactor_Mask | mask | |||
) | [protected, virtual] |
Remove a set of handles.
Reimplemented in ACE_FlReactor, ACE_FoxReactor, ACE_QtReactor, ACE_TkReactor, and ACE_XtReactor.
Definition at line 612 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::remove_handler_i"); ACE_HANDLE h; ACE_Handle_Set_Iterator handle_iter (handles); while ((h = handle_iter ()) != ACE_INVALID_HANDLE) if (this->remove_handler_i (h, mask) == -1) return -1; return 0; }
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::renew | ( | void | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::renew"); #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) if (this->supress_notify_renew () == 0) this->token_.renew (this->requeue_position_); #endif /* defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0) */ }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::requeue_position | ( | void | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::requeue_position"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->requeue_position_; }
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::requeue_position | ( | int | rp | ) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::requeue_position"); ACE_MT (ACE_GUARD (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_)); #if defined (ACE_WIN32) ACE_UNUSED_ARG (rp); // Must always requeue ourselves "next" on Win32. this->requeue_position_ = 0; #else this->requeue_position_ = rp; #endif /* ACE_WIN32 */ }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::reset_timer_interval | ( | long | timer_id, | |
const ACE_Time_Value & | interval | |||
) | [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.
Reimplemented in ACE_FlReactor, ACE_FoxReactor, ACE_TkReactor, and ACE_XtReactor.
Definition at line 740 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::reset_timer_interval"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); if (0 != this->timer_queue_) { return this->timer_queue_->reset_interval (timer_id, interval); } errno = ESHUTDOWN; return -1; }
bool ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::restart | ( | bool | r | ) | [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.
{ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, false)); bool const current_value = this->restart_; this->restart_ = r; return current_value; }
bool ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::restart | ( | void | ) | [virtual] |
Get the existing restart value.
Implements ACE_Reactor_Impl.
Definition at line 139 of file Select_Reactor_T.cpp.
{ ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, false)); return this->restart_; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_handler | ( | const ACE_Handle_Set & | handles | ) | [virtual] |
Resume all handles in handle set.
Implements ACE_Reactor_Impl.
Definition at line 21 of file Select_Reactor_T.inl.
{ ACE_TRACE ("ACE_Select_Reactor_T::resume_handler"); ACE_Handle_Set_Iterator handle_iter (handles); ACE_HANDLE h; ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); while ((h = handle_iter ()) != ACE_INVALID_HANDLE) if (this->resume_i (h) == -1) return -1; return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_handler | ( | ACE_HANDLE | handle | ) | [virtual] |
Resume a temporarily suspended Event_Handler associated with handle.
Implements ACE_Reactor_Impl.
Definition at line 223 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::resume_handler"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->resume_i (handle); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_handler | ( | ACE_Event_Handler * | eh | ) | [virtual] |
Resume a temporarily suspend Event_Handler associated with eh.
Implements ACE_Reactor_Impl.
Definition at line 13 of file Select_Reactor_T.inl.
{ ACE_TRACE ("ACE_Select_Reactor_T::resume_handler"); return this->resume_handler (h->get_handle ()); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_handlers | ( | void | ) | [virtual] |
Resume all the <Event_Handlers> in the Select_Reactor.
Implements ACE_Reactor_Impl.
Definition at line 257 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::resume_handlers"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); ACE_Event_Handler *eh = 0; for (ACE_Select_Reactor_Handler_Repository_Iterator iter (&this->handler_rep_); iter.next (eh) != 0; iter.advance ()) { this->resume_i (eh->get_handle ()); } return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::resume_i | ( | ACE_HANDLE | handle | ) | [protected, virtual] |
Resume the <Event_Handler> associated with handle.
Reimplemented in ACE_XtReactor.
Definition at line 914 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::resume_i"); if (this->handler_rep_.find (handle) == 0) return -1; if (this->suspend_set_.rd_mask_.is_set (handle)) { this->wait_set_.rd_mask_.set_bit (handle); this->suspend_set_.rd_mask_.clr_bit (handle); } if (this->suspend_set_.wr_mask_.is_set (handle)) { this->wait_set_.wr_mask_.set_bit (handle); this->suspend_set_.wr_mask_.clr_bit (handle); } if (this->suspend_set_.ex_mask_.is_set (handle)) { this->wait_set_.ex_mask_.set_bit (handle); this->suspend_set_.ex_mask_.clr_bit (handle); } return 0; }
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 | |||
) | [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.
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 |
Implements ACE_Reactor_Impl.
Reimplemented in ACE_FlReactor, ACE_FoxReactor, ACE_QtReactor, ACE_TkReactor, and ACE_XtReactor.
Definition at line 719 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::schedule_timer"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); if (0 != this->timer_queue_) return this->timer_queue_->schedule (handler, arg, timer_queue_->gettimeofday () + delay_time, interval); errno = ESHUTDOWN; return -1; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::schedule_wakeup | ( | ACE_Event_Handler * | eh, | |
ACE_Reactor_Mask | mask | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::schedule_wakeup"); return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::ADD_MASK); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::schedule_wakeup | ( | ACE_HANDLE | handle, | |
ACE_Reactor_Mask | mask | |||
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::schedule_wakeup"); return this->mask_ops (handle, mask, ACE_Reactor::ADD_MASK); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::set_sig_handler | ( | ACE_Sig_Handler * | signal_handler | ) | [virtual] |
Use a user specified signal handler instead.
Implements ACE_Reactor_Impl.
Definition at line 450 of file Select_Reactor_T.cpp.
{ delete this->signal_handler_; this->signal_handler_ = signal_handler; this->delete_signal_handler_ = false; return 0; }
size_t ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::size | ( | void | ) | const [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.
{ return this->handler_rep_.size (); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_handler | ( | const ACE_Handle_Set & | handles | ) | [virtual] |
Suspend all handles in handle set temporarily.
Implements ACE_Reactor_Impl.
Definition at line 46 of file Select_Reactor_T.inl.
{ ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler"); ACE_Handle_Set_Iterator handle_iter (handles); ACE_HANDLE h; ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); while ((h = handle_iter ()) != ACE_INVALID_HANDLE) if (this->suspend_i (h) == -1) return -1; return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_handler | ( | ACE_Event_Handler * | eh | ) | [virtual] |
Temporarily suspend the <Event_Handler> associated with eh.
Implements ACE_Reactor_Impl.
Definition at line 38 of file Select_Reactor_T.inl.
{ ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler"); return this->suspend_handler (h->get_handle ()); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_handler | ( | ACE_HANDLE | handle | ) | [virtual] |
Temporarily suspend the Event_Handler associated with handle.
Implements ACE_Reactor_Impl.
Definition at line 231 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::suspend_handler"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); return this->suspend_i (handle); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_handlers | ( | void | ) | [virtual] |
Suspend all the <Event_Handlers> in the Select_Reactor.
Implements ACE_Reactor_Impl.
Definition at line 239 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::suspend_handlers"); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); ACE_Event_Handler *eh = 0; for (ACE_Select_Reactor_Handler_Repository_Iterator iter (&this->handler_rep_); iter.next (eh) != 0; iter.advance ()) { this->suspend_i (eh->get_handle ()); } return 0; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::suspend_i | ( | ACE_HANDLE | handle | ) | [protected, virtual] |
Suspend the <Event_Handler> associated with handle.
Reimplemented in ACE_XtReactor.
Definition at line 941 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::suspend_i"); if (this->handler_rep_.find (handle) == 0) return -1; if (this->wait_set_.rd_mask_.is_set (handle)) { this->suspend_set_.rd_mask_.set_bit (handle); this->wait_set_.rd_mask_.clr_bit (handle); } if (this->wait_set_.wr_mask_.is_set (handle)) { this->suspend_set_.wr_mask_.set_bit (handle); this->wait_set_.wr_mask_.clr_bit (handle); } if (this->wait_set_.ex_mask_.is_set (handle)) { this->suspend_set_.ex_mask_.set_bit (handle); this->wait_set_.ex_mask_.clr_bit (handle); } // Kobi: we need to remove that handle from the // dispatch set as well. We use that function with all the relevant // masks - rd/wr/ex - all the mask. it is completely suspended this->clear_dispatch_mask (handle, ACE_Event_Handler::RWE_MASK); return 0; }
ACE_Timer_Queue * ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::timer_queue | ( | void | ) | const [virtual] |
Return the current ACE_Timer_Queue.
Implements ACE_Reactor_Impl.
Definition at line 459 of file Select_Reactor_T.cpp.
{ return this->timer_queue_; }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::timer_queue | ( | ACE_Timer_Queue * | tq | ) | [virtual] |
Set a user-specified timer queue.
Implements ACE_Reactor_Impl.
Definition at line 466 of file Select_Reactor_T.cpp.
{ delete this->timer_queue_; this->timer_queue_ = tq; this->delete_timer_queue_ = false; return 0; }
bool ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::uses_event_associations | ( | void | ) | [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.
{ // Since the Select_Reactor does not do any event associations, this // function always return false. return false; }
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 | |||
) | [protected, virtual] |
Wait for events to occur.
Reimplemented in ACE_FlReactor, ACE_FoxReactor, ACE_QtReactor, ACE_TkReactor, and ACE_XtReactor.
Definition at line 1067 of file Select_Reactor_T.cpp.
{ ACE_TRACE ("ACE_Select_Reactor_T::wait_for_multiple_events"); ACE_Time_Value timer_buf (0); ACE_Time_Value *this_timeout = 0; int number_of_active_handles = this->any_ready (dispatch_set); // If there are any bits enabled in the <ready_set_> then we'll // handle those first, otherwise we'll block in <select>. if (number_of_active_handles == 0) { do { if (this->timer_queue_ == 0) return 0; this_timeout = this->timer_queue_->calculate_timeout (max_wait_time, &timer_buf); #ifdef ACE_WIN32 // This arg is ignored on Windows and causes pointer // truncation warnings on 64-bit compiles. int const width = 0; #else int const width = this->handler_rep_.max_handlep1 (); #endif /* ACE_WIN32 */ dispatch_set.rd_mask_ = this->wait_set_.rd_mask_; dispatch_set.wr_mask_ = this->wait_set_.wr_mask_; dispatch_set.ex_mask_ = this->wait_set_.ex_mask_; number_of_active_handles = ACE_OS::select (width, dispatch_set.rd_mask_, dispatch_set.wr_mask_, dispatch_set.ex_mask_, this_timeout); } while (number_of_active_handles == -1 && this->handle_error () > 0); if (number_of_active_handles > 0) { #if !defined (ACE_WIN32) // Resynchronize the fd_sets so their "max" is set properly. dispatch_set.rd_mask_.sync (this->handler_rep_.max_handlep1 ()); dispatch_set.wr_mask_.sync (this->handler_rep_.max_handlep1 ()); dispatch_set.ex_mask_.sync (this->handler_rep_.max_handlep1 ()); #endif /* ACE_WIN32 */ } else if (number_of_active_handles == -1) { // Normally, select() will reset the bits in dispatch_set // so that only those filed descriptors that are ready will // have bits set. However, when an error occurs, the bit // set remains as it was when the select call was first made. // Thus, we now have a dispatch_set that has every file // descriptor that was originally waited for, which is not // correct. We must clear all the bit sets because we // have no idea if any of the file descriptors is ready. // // NOTE: We dont have a test case to reproduce this // problem. But pleae dont ignore this and remove it off. dispatch_set.rd_mask_.reset (); dispatch_set.wr_mask_.reset (); dispatch_set.ex_mask_.reset (); } } // Return the number of events to dispatch. return number_of_active_handles; }
void ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::wakeup_all_threads | ( | void | ) | [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.
{ // Send a notification, but don't block if there's no one to receive // it. this->notify (0, ACE_Event_Handler::NULL_MASK, (ACE_Time_Value *) &ACE_Time_Value::zero); }
int ACE_Select_Reactor_T< ACE_SELECT_REACTOR_TOKEN >::work_pending | ( | const ACE_Time_Value & | max_wait_time = ACE_Time_Value::zero |
) | [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.
{ ACE_TRACE ("ACE_Select_Reactor_T::work_pending"); ACE_Time_Value mwt (max_wait_time); ACE_MT (ACE_Countdown_Time countdown (&mwt)); ACE_MT (ACE_GUARD_RETURN (ACE_SELECT_REACTOR_TOKEN, ace_mon, this->token_, -1)); if (this->deactivated_) return 0; // Update the countdown to reflect time waiting for the mutex. ACE_MT (countdown.update ()); ACE_Time_Value timer_buf (0); ACE_Time_Value *this_timeout = this->timer_queue_->calculate_timeout (&mwt, &timer_buf); // Check if we have timers to fire. bool const timers_pending = (this_timeout != 0 && *this_timeout != mwt ? true : false); #ifdef ACE_WIN32 // This arg is ignored on Windows and causes pointer truncation // warnings on 64-bit compiles. int const width = 0; #else int const width = this->handler_rep_.max_handlep1 (); #endif /* ACE_WIN32 */ ACE_Select_Reactor_Handle_Set fd_set; fd_set.rd_mask_ = this->wait_set_.rd_mask_; fd_set.wr_mask_ = this->wait_set_.wr_mask_; fd_set.ex_mask_ = this->wait_set_.ex_mask_; int const nfds = ACE_OS::select (width, fd_set.rd_mask_, fd_set.wr_mask_, fd_set.ex_mask_, this_timeout); // If timers are pending, override any timeout from the select() // call. return (nfds == 0 && timers_pending ? 1 : nfds); }
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.
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.
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.
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.