ACE_Dev_Poll_Reactor Class Reference

A `/dev/poll' or `/dev/epoll' based Reactor implemenatation. More...

#include <Dev_Poll_Reactor.h>

Inheritance diagram for ACE_Dev_Poll_Reactor:

Inheritance graph
[legend]
Collaboration diagram for ACE_Dev_Poll_Reactor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Dev_Poll_Reactor (ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, int disable_notify_pipe=0, ACE_Reactor_Notify *notify=0, int mask_signals=1, int s_queue=ACE_DEV_POLL_TOKEN::FIFO)
 Initialize ACE_Dev_Poll_Reactor with the default size.

 ACE_Dev_Poll_Reactor (size_t size, int restart=0, ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, int disable_notify_pipe=0, ACE_Reactor_Notify *notify=0, int mask_signals=1, int s_queue=ACE_DEV_POLL_TOKEN::FIFO)
 Initialize ACE_Dev_Poll_Reactor with size size.

virtual ~ACE_Dev_Poll_Reactor (void)
 Close down and release all resources.

virtual int open (size_t size, int restart=0, ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, int disable_notify_pipe=0, ACE_Reactor_Notify *=0)
 Initialization.

virtual int current_info (ACE_HANDLE handle, size_t &)
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
virtual int close (void)
 Close down and release all 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 *event_handler, ACE_Reactor_Mask mask)
virtual int register_handler (ACE_HANDLE io_handle, ACE_Event_Handler *event_handler, 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)
virtual int register_handler (const ACE_Handle_Set &handles, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask)
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 *event_handler, ACE_Reactor_Mask mask)
 Removes event_handler.

virtual int remove_handler (ACE_HANDLE handle, ACE_Reactor_Mask mask)
virtual int remove_handler (const ACE_Handle_Set &handle_set, ACE_Reactor_Mask 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 for every signal in .

virtual int suspend_handler (ACE_Event_Handler *event_handler)
virtual int suspend_handler (ACE_HANDLE handle)
 Suspend handle temporarily.

virtual int suspend_handler (const ACE_Handle_Set &handles)
 Suspend all handles in handle set temporarily.

virtual int suspend_handlers (void)
 Suspend all handles temporarily.

virtual int resume_handler (ACE_Event_Handler *event_handler)
virtual int resume_handler (ACE_HANDLE handle)
 Resume handle.

virtual int resume_handler (const ACE_Handle_Set &handles)
 Resume all handles in handle set.

virtual int resume_handlers (void)
 Resume all handles.

virtual int resumable_handler (void)
virtual int 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 *event_handler, ACE_Reactor_Mask masks_to_be_added)
virtual int schedule_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask masks_to_be_added)
virtual int cancel_wakeup (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks_to_be_cleared)
 Clear from the 's entry.

virtual int cancel_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask masks_to_be_cleared)
 Clear from the 's entry.

virtual int notify (ACE_Event_Handler *event_handler=0, ACE_Reactor_Mask mask=ACE_Event_Handler::EXCEPT_MASK, ACE_Time_Value *=0)
virtual void max_notify_iterations (int)
virtual int max_notify_iterations (void)
virtual int purge_pending_notifications (ACE_Event_Handler *=0, ACE_Reactor_Mask=ACE_Event_Handler::ALL_EVENTS_MASK)
virtual ACE_Event_Handlerfind_handler (ACE_HANDLE handle)
virtual int handler (ACE_HANDLE handle, ACE_Reactor_Mask mask, ACE_Event_Handler **event_handler=0)
virtual int handler (int signum, ACE_Event_Handler **=0)
virtual int initialized (void)
virtual size_t size (void) const
virtual ACE_Locklock (void)
 Returns a reference to the Reactor's internal lock.

virtual void wakeup_all_threads (void)
 Wake up all threads waiting in the event loop.

virtual int owner (ACE_thread_t new_owner, ACE_thread_t *old_owner=0)
 Transfers ownership of Reactor_Impl to the new_owner.

virtual int owner (ACE_thread_t *owner)
 Return the ID of the "owner" thread.

virtual int restart (void)
 Get the existing restart value.

virtual int restart (int r)
 Set a new value for restart and return the original value.

virtual void requeue_position (int)
 Set position of the owner thread.

virtual int requeue_position (void)
 Get position of the owner thread.

virtual void dump (void) const
 Dump the state of an object.

Low-level wait_set mask manipulation methods
Low-level methods to manipulate the event/reactor mask associated with a handle and event handler when polling for events.
The "interest set," i.e. the wait set, can be directly manipulated with these methods.


virtual int mask_ops (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask, int ops)
virtual int mask_ops (ACE_HANDLE handle, ACE_Reactor_Mask mask, int ops)
Low-level ready_set mask manipulation methods
These methods are unimplemented.

virtual int ready_ops (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask, int ops)
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.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Member Functions

int work_pending_i (ACE_Time_Value *max_wait_time)
 Non-locking version of wait_pending().

int handle_events_i (ACE_Time_Value *max_wait_time, Token_Guard &guard)
int upcall (ACE_Event_Handler *event_handler, int(ACE_Event_Handler::*callback)(ACE_HANDLE), ACE_HANDLE handle)
 Perform the upcall with the given event handler method.

int dispatch (Token_Guard &guard)
int dispatch_timer_handler (Token_Guard &guard)
int dispatch_io_event (Token_Guard &guard)
int register_handler_i (ACE_HANDLE handle, ACE_Event_Handler *eh, ACE_Reactor_Mask mask)
 Register the given event handler with the reactor.

int remove_handler_i (ACE_HANDLE handle, ACE_Reactor_Mask mask)
int suspend_handler_i (ACE_HANDLE handle)
 Temporarily remove the given handle from the "interest set.".

int resume_handler_i (ACE_HANDLE handle)
int mask_ops_i (ACE_HANDLE handle, ACE_Reactor_Mask mask, int ops)
short reactor_mask_to_poll_event (ACE_Reactor_Mask mask)
 Convert a reactor mask to its corresponding poll() event mask.


Protected Attributes

bool initialized_
 Has the reactor been initialized.

ACE_HANDLE poll_fd_
size_t size_
epoll_event * events_
 Table of event structures to be filled by epoll_wait:.

epoll_event * start_pevents_
epoll_event * end_pevents_
 The last element in the event array plus one.

sig_atomic_t deactivated_
ACE_Dev_Poll_Reactor_Token token_
 Lock used for synchronization of reactor state.

ACE_Lock_Adapter< ACE_Dev_Poll_Reactor_Tokenlock_adapter_
 Adapter used to return internal lock to outside world.

ACE_Dev_Poll_Reactor_Handler_Repository handler_rep_
 The repository that contains all registered event handlers.

ACE_Timer_Queuetimer_queue_
 Defined as a pointer to allow overriding by derived classes...

int delete_timer_queue_
ACE_Sig_Handlersignal_handler_
 Handle signals without requiring global/static variables.

int delete_signal_handler_
ACE_Reactor_Notifynotify_handler_
int delete_notify_handler_
int mask_signals_
int restart_

Detailed Description

A `/dev/poll' or `/dev/epoll' based Reactor implemenatation.

Attention:
This reactor is experimental.
The ACE_Dev_Poll_Reactor uses the `/dev/poll' or '/dev/epoll' character devices to demultiplex events on a given set of file descriptors. Unlike select(), `/dev/poll' and `/dev/epoll' have no hard-coded limit on the number of file descriptors that may be handled at any given time. As such, the ACE_Dev_Poll_Reactor can generally handle a much larger number of file descriptors than select() -based reactors. Furthermore, since `/dev/poll' and `/dev/epoll' both return a set of file descriptors that are active, there is no need to "walk" the set of file descriptors to determine which ones are active, such as what is done with the select() and poll() system calls. All returned file descriptors are active. This makes event dispatching very efficient.

Note:
In general, this reactor may only be used to demultiplex events on sockets. Demultiplexing events on pipes, for example may not work. This is due to a limitation in the underlying `/dev/poll' device driver.

It is only possible to achieve millisecond timeout resolutions with the ACE_Dev_Poll_Reactor. However, the timeout resolution for timers is independent of the reactors timeout resolution. As such, it may be possible to achieve sub-millisecond timeout resolutions for timers but that is entirely platform dependent.

Definition at line 474 of file Dev_Poll_Reactor.h.


Constructor & Destructor Documentation

ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor ACE_Sig_Handler = 0,
ACE_Timer_Queue = 0,
int  disable_notify_pipe = 0,
ACE_Reactor_Notify notify = 0,
int  mask_signals = 1,
int  s_queue = ACE_DEV_POLL_TOKEN::FIFO
 

Initialize ACE_Dev_Poll_Reactor with the default size.

The default size for the ACE_Dev_Poll_Reactor is the maximum number of open file descriptors for the process.

Definition at line 727 of file Dev_Poll_Reactor.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_Timer_Queue, ACE_TRACE, LM_ERROR, and open().

00733   : initialized_ (false)
00734   , poll_fd_ (ACE_INVALID_HANDLE)
00735   , size_ (0)
00736   // , ready_set_ ()
00737 #if defined (ACE_HAS_EVENT_POLL)
00738   , events_ (0)
00739   , start_pevents_ (0)
00740   , end_pevents_ (0)
00741 #else
00742   , dp_fds_ (0)
00743   , start_pfds_ (0)
00744   , end_pfds_ (0)
00745 #endif  /* ACE_HAS_EVENT_POLL */
00746   , deactivated_ (0)
00747   , token_ (*this, s_queue)
00748   , lock_adapter_ (token_)
00749   , timer_queue_ (0)
00750   , delete_timer_queue_ (0)
00751   , signal_handler_ (0)
00752   , delete_signal_handler_ (0)
00753   , notify_handler_ (0)
00754   , delete_notify_handler_ (0)
00755   , mask_signals_ (mask_signals)
00756   , restart_ (0)
00757 {
00758   ACE_TRACE ("ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor");
00759 
00760   if (this->open (ACE::max_handles (),
00761                   0,
00762                   sh,
00763                   tq,
00764                   disable_notify_pipe,
00765                   notify) == -1)
00766     ACE_ERROR ((LM_ERROR,
00767                 ACE_LIB_TEXT ("%p\n"),
00768                 ACE_LIB_TEXT ("ACE_Dev_Poll_Reactor::open ")
00769                 ACE_LIB_TEXT ("failed inside ")
00770                 ACE_LIB_TEXT ("ACE_Dev_Poll_Reactor::CTOR")));
00771 }

ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor size_t  size,
int  restart = 0,
ACE_Sig_Handler = 0,
ACE_Timer_Queue = 0,
int  disable_notify_pipe = 0,
ACE_Reactor_Notify notify = 0,
int  mask_signals = 1,
int  s_queue = ACE_DEV_POLL_TOKEN::FIFO
 

Initialize ACE_Dev_Poll_Reactor with size size.

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. If the size parameter is less than the process maximum, the process maximum will be decreased in order to prevent potential access violations.

Definition at line 773 of file Dev_Poll_Reactor.cpp.

References ACE_ERROR, ACE_LIB_TEXT, ACE_Timer_Queue, LM_ERROR, and open().

00781   : initialized_ (false)
00782   , poll_fd_ (ACE_INVALID_HANDLE)
00783   , size_ (0)
00784   // , ready_set_ ()
00785 #if defined (ACE_HAS_EVENT_POLL)
00786   , events_ (0)
00787   , start_pevents_ (0)
00788   , end_pevents_ (0)
00789 #else
00790   , dp_fds_ (0)
00791   , start_pfds_ (0)
00792   , end_pfds_ (0)
00793 #endif  /* ACE_HAS_EVENT_POLL */
00794   , deactivated_ (0)
00795   , token_ (*this, s_queue)
00796   , lock_adapter_ (token_)
00797   , timer_queue_ (0)
00798   , delete_timer_queue_ (0)
00799   , signal_handler_ (0)
00800   , delete_signal_handler_ (0)
00801   , notify_handler_ (0)
00802   , delete_notify_handler_ (0)
00803   , mask_signals_ (mask_signals)
00804   , restart_ (0)
00805 {
00806   if (this->open (size,
00807                   rs,
00808                   sh,
00809                   tq,
00810                   disable_notify_pipe,
00811                   notify) == -1)
00812     ACE_ERROR ((LM_ERROR,
00813                 ACE_LIB_TEXT ("%p\n"),
00814                 ACE_LIB_TEXT ("ACE_Dev_Poll_Reactor::open ")
00815                 ACE_LIB_TEXT ("failed inside ACE_Dev_Poll_Reactor::CTOR")));
00816 }

ACE_Dev_Poll_Reactor::~ACE_Dev_Poll_Reactor void   )  [virtual]
 

Close down and release all resources.

Definition at line 818 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and close().

00819 {
00820   ACE_TRACE ("ACE_Dev_Poll_Reactor::~ACE_Dev_Poll_Reactor");
00821 
00822   (void) this->close ();
00823 }


Member Function Documentation

int ACE_Dev_Poll_Reactor::alertable_handle_events ACE_Time_Value max_wait_time  )  [virtual]
 

Implements ACE_Reactor_Impl.

Definition at line 1473 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and handle_events().

01474 {
01475   ACE_TRACE ("ACE_Dev_Poll_Reactor::alertable_handle_events");
01476 
01477   return this->handle_events (max_wait_time);
01478 }

int ACE_Dev_Poll_Reactor::alertable_handle_events ACE_Time_Value max_wait_time = 0  )  [virtual]
 

Implements ACE_Reactor_Impl.

Definition at line 1457 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and handle_events().

01458 {
01459   ACE_TRACE ("ACE_Dev_Poll_Reactor::alertable_handle_events");
01460 
01461   return this->handle_events (max_wait_time);
01462 }

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

Cancel the single 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. Returns 1 if cancellation succeeded and 0 if the timer_id wasn't found.

Implements ACE_Reactor_Impl.

Definition at line 2074 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::cancel(), and timer_queue_.

02077 {
02078   ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_timer");
02079 
02080   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02081 
02082   return (this->timer_queue_ == 0
02083           ? 0
02084           : this->timer_queue_->cancel (timer_id,
02085                                         arg,
02086                                         dont_call_handle_close));
02087 }

int ACE_Dev_Poll_Reactor::cancel_timer ACE_Event_Handler event_handler,
int  dont_call_handle_close = 1
[virtual]
 

Cancel all Event_Handlers that match the address of . Returns number of handlers cancelled.

Implements ACE_Reactor_Impl.

Definition at line 2060 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::cancel(), and timer_queue_.

02062 {
02063   ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_timer");
02064 
02065   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02066 
02067   return (this->timer_queue_ == 0
02068           ? 0
02069           : this->timer_queue_->cancel (event_handler,
02070                                         dont_call_handle_close));
02071 }

int ACE_Dev_Poll_Reactor::cancel_wakeup ACE_HANDLE  handle,
ACE_Reactor_Mask  masks_to_be_cleared
[virtual]
 

Clear from the 's entry.

Implements ACE_Reactor_Impl.

Definition at line 2117 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, and mask_ops().

02119 {
02120   ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_wakeup");
02121 
02122   return this->mask_ops (handle, mask, ACE_Reactor::CLR_MASK);
02123 }

int ACE_Dev_Poll_Reactor::cancel_wakeup ACE_Event_Handler event_handler,
ACE_Reactor_Mask  masks_to_be_cleared
[virtual]
 

Clear from the 's entry.

Implements ACE_Reactor_Impl.

Definition at line 2108 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, ACE_Event_Handler::get_handle(), and mask_ops().

02110 {
02111   ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_wakeup");
02112 
02113   return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::CLR_MASK);
02114 }

int ACE_Dev_Poll_Reactor::close void   )  [virtual]
 

Close down and release all resources.

Implements ACE_Reactor_Impl.

Definition at line 978 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, ACE_Reactor_Notify::close(), ACE_Dev_Poll_Reactor_Handler_Repository::close(), ACE_OS::close(), delete_notify_handler_, delete_signal_handler_, delete_timer_queue_, end_pevents_, events_, handler_rep_, initialized_, notify_handler_, poll_fd_, signal_handler_, start_pevents_, and timer_queue_.

Referenced by open(), and ~ACE_Dev_Poll_Reactor().

00979 {
00980   ACE_TRACE ("ACE_Dev_Poll_Reactor::close");
00981 
00982   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
00983 
00984   int result = 0;
00985 
00986   if (this->poll_fd_ != ACE_INVALID_HANDLE)
00987     {
00988       result = ACE_OS::close (this->poll_fd_);
00989     }
00990 
00991 #if defined (ACE_HAS_EVENT_POLL)
00992 
00993   delete [] this->events_;
00994   this->events_ = 0;
00995 
00996 #else
00997 
00998   delete [] this->dp_fds_;
00999   this->dp_fds_ = 0;
01000 
01001 #endif  /* ACE_HAS_EVENT_POLL */
01002 
01003   if (this->delete_signal_handler_)
01004     {
01005       delete this->signal_handler_;
01006       this->signal_handler_ = 0;
01007       this->delete_signal_handler_ = 0;
01008     }
01009 
01010   (void) this->handler_rep_.close ();
01011 
01012   if (this->delete_timer_queue_)
01013     {
01014       delete this->timer_queue_;
01015       this->timer_queue_ = 0;
01016       this->delete_timer_queue_ = 0;
01017     }
01018 
01019   if (this->notify_handler_ != 0)
01020     this->notify_handler_->close ();
01021 
01022   if (this->delete_notify_handler_)
01023     {
01024       delete this->notify_handler_;
01025       this->notify_handler_ = 0;
01026       this->delete_notify_handler_ = 0;
01027     }
01028 
01029   this->poll_fd_ = ACE_INVALID_HANDLE;
01030 
01031 #if defined (ACE_HAS_EVENT_POLL)
01032   this->start_pevents_ = 0;
01033   this->end_pevents_   = 0;
01034 #else
01035   this->start_pfds_ = 0;
01036   this->end_pfds_ = 0;
01037 #endif /* ACE_HAS_EVENT_POLL */
01038 
01039   this->initialized_ = false;
01040 
01041   return result;
01042 }

int ACE_Dev_Poll_Reactor::current_info ACE_HANDLE  handle,
size_t & 
[virtual]
 

Parameters:
handle allows the reactor to check if the caller is valid.
Returns:
0 if the size of the current message has been put in size. -1 if not.

Implements ACE_Reactor_Impl.

Definition at line 940 of file Dev_Poll_Reactor.cpp.

References ACE_NOTSUP_RETURN.

00941 {
00942   ACE_NOTSUP_RETURN (-1);
00943 }

void ACE_Dev_Poll_Reactor::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 desired.

Implements ACE_Reactor_Impl.

Definition at line 1487 of file Dev_Poll_Reactor.cpp.

References deactivated_, and wakeup_all_threads().

01488 {
01489   this->deactivated_ = do_stop;
01490   this->wakeup_all_threads ();
01491 }

int ACE_Dev_Poll_Reactor::deactivated void   )  [virtual]
 

Returns:
The status of Reactor. If this function returns 0, the reactor is actively handling events. If it returns non-zero, handle_events() and handle_alertable_events() return -1 immediately.

Implements ACE_Reactor_Impl.

Definition at line 1481 of file Dev_Poll_Reactor.cpp.

References deactivated_.

01482 {
01483   return this->deactivated_;
01484 }

int ACE_Dev_Poll_Reactor::dispatch Token_Guard guard  )  [protected]
 

Dispatch 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 1217 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, dispatch_io_event(), and dispatch_timer_handler().

Referenced by handle_events_i().

01218 {
01219   ACE_TRACE ("ACE_Dev_Poll_Reactor::dispatch");
01220 
01221   // Perform the Template Method for dispatching the first located event.
01222   // We dispatch only one to effectively dispatch events concurrently.
01223   // As soon as an event is located, the token is released, allowing the
01224   // next waiter to begin getting an event while we dispatch one here.
01225   int result = 0;
01226 
01227   // Handle timers early since they may have higher latency
01228   // constraints than I/O handlers.  Ideally, the order of
01229   // dispatching should be a strategy...
01230   if ((result = this->dispatch_timer_handler (guard)) != 0)
01231     return result;
01232 
01233   // Check to see if there are no more I/O handles left to
01234   // dispatch AFTER we've handled the timers.
01235 
01236   // Finally, dispatch the I/O handlers.
01237   result = this->dispatch_io_event (guard);
01238 
01239   return result;
01240 }

int ACE_Dev_Poll_Reactor::dispatch_io_event Token_Guard guard  )  [protected]
 

Dispatch an IO event to the corresponding event handler. Returns Returns: 0 if no events ready (token still held), 1 if an event was expired (token released), -1 on error (token still held).

Definition at line 1306 of file Dev_Poll_Reactor.cpp.

References ACE_BIT_ENABLED, ACE_CLR_BITS, ACE_ERROR, ACE_TEXT, end_pevents_, ACE_Dev_Poll_Reactor_Handler_Repository::find(), handler_rep_, LM_ERROR, ACE_Dev_Poll_Reactor::Token_Guard::release_token(), remove_handler(), remove_handler_i(), start_pevents_, and upcall().

Referenced by dispatch().

01307 {
01308 
01309   // Define bits to check for while dispatching.
01310 #if defined (ACE_HAS_EVENT_POLL)
01311   const __uint32_t out_event = EPOLLOUT;
01312   const __uint32_t exc_event = EPOLLPRI;
01313   const __uint32_t in_event  = EPOLLIN;
01314   const __uint32_t err_event = EPOLLHUP | EPOLLERR;
01315 #else
01316   const short out_event = POLLOUT;
01317   const short exc_event = POLLPRI;
01318   const short in_event  = POLLIN;
01319   const short err_event = 0;              // No known bits for this
01320 #endif /* ACE_HAS_EVENT_POLL */
01321 
01322   // Since the underlying event demultiplexing mechansim (`/dev/poll'
01323   // or '/dev/epoll') is stateful, and since only one result buffer is
01324   // used, all pending events (i.e. those retrieved from a previous
01325   // poll) must be dispatched before any additional event can be
01326   // polled.  As such, the Dev_Poll_Reactor keeps track of the
01327   // progress of events that have been dispatched.
01328 
01329   // Dispatch the events.
01330   //
01331   // Select the first available handle with event(s) pending. Check for
01332   // event type in defined order of dispatch: output, exception, input.
01333   // When an event is located, clear its bit in the dispatch set. If there
01334   // are no more events for the handle, also increment the pfds pointer
01335   // to move to the next handle ready.
01336   //
01337   // Notice that pfds only contains file descriptors that have
01338   // received events.
01339 #if defined (ACE_HAS_EVENT_POLL)
01340   struct epoll_event *& pfds = this->start_pevents_;
01341   if (pfds < this->end_pevents_)
01342 #else
01343   struct pollfd *& pfds = this->start_pfds_;
01344   if (pfds < this->end_pfds_)
01345 #endif /* ACE_HAS_EVENT_POLL */
01346     {
01347 #if defined (ACE_HAS_EVENT_POLL)
01348       const ACE_HANDLE handle   = pfds->data.fd;
01349       __uint32_t &revents       = pfds->events;
01350 #else
01351       const ACE_HANDLE handle = pfds->fd;
01352       short &revents          = pfds->revents;
01353 #endif /* ACE_HAS_EVENT_POLL */
01354 
01355       // Figure out what to do first in order to make it easier to manage
01356       // the bit twiddling and possible pfds increment before releasing
01357       // the token for dispatch.
01358       // Note that if there's an error (such as the handle was closed
01359       // without being removed from the event set) the EPOLLHUP and/or
01360       // EPOLLERR bits will be set in revents.
01361       bool disp_out = false;
01362       bool disp_exc = false;
01363       bool disp_in  = false;
01364       if (ACE_BIT_ENABLED (revents, out_event))
01365         {
01366           disp_out = true;
01367           ACE_CLR_BITS (revents, out_event);
01368         }
01369       else if (ACE_BIT_ENABLED (revents, exc_event))
01370         {
01371           disp_exc = true;
01372           ACE_CLR_BITS (revents, exc_event);
01373         }
01374       else if (ACE_BIT_ENABLED (revents, in_event))
01375         {
01376           disp_in = true;
01377           ACE_CLR_BITS (revents, in_event);
01378         }
01379       else if (ACE_BIT_ENABLED (revents, err_event))
01380         {
01381           this->remove_handler_i (handle, ACE_Event_Handler::ALL_EVENTS_MASK);
01382           ++pfds;
01383           return 1;
01384         }
01385       else
01386         {
01387           ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%t) dispatch_io h %d unknown events 0x%x\n"), handle, revents));
01388           // ACE_ASSERT (0);
01389         }
01390 
01391       // Increment the pointer to the next element before we
01392       // release the token.  Otherwise event handlers end up being
01393       // dispatched multiple times for the same poll.
01394       if (revents == 0)
01395         ++pfds;
01396 
01397       /* When using sys_epoll, we can attach arbitrary user
01398          data to the descriptor, so it can be delivered when
01399          activity is detected. Perhaps we should store event
01400          handler together with descriptor, instead of looking
01401          it up in a repository ? Could it boost performance ?
01402       */
01403       ACE_Event_Handler *eh = this->handler_rep_.find (handle);
01404 
01405       if (eh)
01406         {
01407           // Modify the reference count in an exception-safe way.
01408           // Note that eh could be the notify handler. It's not strictly
01409           // necessary to manage its refcount, but since we don't enable
01410           // the counting policy, it won't do much. Management of the
01411           // notified handlers themselves is done in the notify handler.
01412           ACE_Dev_Poll_Handler_Guard eh_guard (eh);
01413 
01414           // Release the reactor token before upcall.
01415           guard.release_token ();
01416 
01417           // Dispatch the detected event
01418           if (disp_out)
01419             {
01420               const int status =
01421                 this->upcall (eh, &ACE_Event_Handler::handle_output, handle);
01422 
01423               if (status < 0)
01424                 // Note that the token is reacquired in remove_handler().
01425                 this->remove_handler (handle, ACE_Event_Handler::WRITE_MASK);
01426               return 1;
01427             }
01428 
01429           if (disp_exc)
01430             {
01431               const int status =
01432                 this->upcall (eh, &ACE_Event_Handler::handle_exception, handle);
01433 
01434               if (status < 0)
01435                 // Note that the token is reacquired in remove_handler().
01436                 this->remove_handler (handle, ACE_Event_Handler::EXCEPT_MASK);
01437               return 1;
01438             }
01439 
01440           if (disp_in)
01441             {
01442               const int status =
01443                 this->upcall (eh, &ACE_Event_Handler::handle_input, handle);
01444 
01445               if (status < 0)
01446                 // Note that the token is reacquired in remove_handler().
01447                 this->remove_handler (handle, ACE_Event_Handler::READ_MASK);
01448               return 1;
01449             }
01450         } // The reactor token is reacquired upon leaving this scope.
01451     }
01452 
01453   return 0;
01454 }

int ACE_Dev_Poll_Reactor::dispatch_timer_handler Token_Guard guard  )  [protected]
 

Dispatch a single timer, if ready. Returns: 0 if no timers ready (token still held), 1 if a timer was expired (token released), -1 on error (token still held).

Definition at line 1243 of file Dev_Poll_Reactor.cpp.

References ACE_Timer_Node_Dispatch_Info, ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::dispatch_info(), ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::is_empty(), ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::postinvoke(), ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::preinvoke(), ACE_Dev_Poll_Reactor::Token_Guard::release_token(), timer_queue_, ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::timer_skew(), and ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::upcall().

Referenced by dispatch().

01244 {
01245   if (this->timer_queue_->is_empty())
01246     return 0;       // Empty timer queue so cannot have any expired timers.
01247 
01248   // Get the current time
01249   ACE_Time_Value cur_time (this->timer_queue_->gettimeofday () +
01250                            this->timer_queue_->timer_skew ());
01251 
01252   // Look for a node in the timer queue whose timer <= the present
01253   // time.
01254   ACE_Timer_Node_Dispatch_Info info;
01255   if (this->timer_queue_->dispatch_info (cur_time, info))
01256     {
01257       const void *upcall_act = 0;
01258 
01259       // Preinvoke (handles refcount if needed, etc.)
01260       this->timer_queue_->preinvoke (info, cur_time, upcall_act);
01261 
01262       // Release the token before expiration upcall.
01263       guard.release_token ();
01264 
01265       // call the functor
01266       this->timer_queue_->upcall (info, cur_time);
01267 
01268       // Postinvoke (undo refcount if needed, etc.)
01269       this->timer_queue_->postinvoke (info, cur_time, upcall_act);
01270 
01271       // We have dispatched a timer
01272       return 1;
01273     }
01274 
01275   return 0;
01276 }

void ACE_Dev_Poll_Reactor::dump void   )  const [virtual]
 

Dump the state of an object.

Implements ACE_Reactor_Impl.

Definition at line 2498 of file Dev_Poll_Reactor.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, and LM_DEBUG.

02499 {
02500 #if defined (ACE_HAS_DUMP)
02501   ACE_TRACE ("ACE_Dev_Poll_Reactor::dump");
02502 
02503   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
02504   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("restart_ = %d\n"), this->restart_));
02505   ACE_DEBUG ((LM_DEBUG,
02506               ACE_LIB_TEXT ("initialized_ = %d"),
02507               this->initialized_));
02508   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("poll_fd_ = %d"), this->poll_fd_));
02509   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("size_ = %u"), this->size_));
02510   ACE_DEBUG ((LM_DEBUG,
02511               ACE_LIB_TEXT ("deactivated_ = %d"),
02512               this->deactivated_));
02513   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
02514 #endif /* ACE_HAS_DUMP */
02515 }

ACE_Event_Handler * ACE_Dev_Poll_Reactor::find_handler ACE_HANDLE  handle  )  [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2174 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_READ_GUARD_RETURN, ACE_Event_Handler::add_reference(), ACE_Dev_Poll_Reactor_Handler_Repository::find(), and handler_rep_.

02175 {
02176   ACE_MT (ACE_READ_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, 0));
02177 
02178   ACE_Event_Handler *event_handler = this->handler_rep_.find (handle);
02179   if (event_handler)
02180     event_handler->add_reference ();
02181   return event_handler;
02182 }

int ACE_Dev_Poll_Reactor::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.

Note:
It is only possible to achieve millisecond timeout resolutions with the ACE_Dev_Poll_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 1465 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and handle_events().

01466 {
01467   ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events");
01468 
01469   return this->handle_events (&max_wait_time);
01470 }

int ACE_Dev_Poll_Reactor::handle_events ACE_Time_Value max_wait_time = 0  )  [virtual]
 

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

max_wait_time is decremented to reflect how much time this call took. For instance, if a time value of 3 seconds is passed to handle_events() and an event occurs after 2 seconds, max_wait_time will equal 1 second. This can be used if an application wishes to handle events for some fixed amount of time.
The only difference between alertable_handle_events() and handle_events() is that in the alertable case, the event loop will return when the system queues an I/O completion routine or an Asynchronous Procedure Call.
Returns:
The total number of ACE_Event_Handlers that were dispatched, 0 if the max_wait_time elapsed without dispatching any handlers, or -1 if an error occurs.
Note:
It is only possible to achieve millisecond timeout resolutions with the ACE_Dev_Poll_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 1143 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly(), deactivated_, handle_events_i(), and ACE_Dev_Poll_Reactor::Token_Guard::is_owner().

Referenced by alertable_handle_events(), and handle_events().

01144 {
01145   ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events");
01146 
01147   // Stash the current time
01148   //
01149   // The destructor of this object will automatically compute how much
01150   // time elapsed since this method was called.
01151   ACE_MT (ACE_Countdown_Time countdown (max_wait_time));
01152 
01153   Token_Guard guard (this->token_);
01154   int result = guard.acquire_quietly (max_wait_time);
01155 
01156   // If the guard is NOT the owner just return the retval
01157   if (!guard.is_owner ())
01158     return result;
01159 
01160   if (this->deactivated_)
01161     return -1;
01162 
01163   // Update the countdown to reflect time waiting for the mutex.
01164   ACE_MT (countdown.update ());
01165 
01166   return this->handle_events_i (max_wait_time, guard);
01167 }

int ACE_Dev_Poll_Reactor::handle_events_i ACE_Time_Value max_wait_time,
Token_Guard guard
[protected]
 

This is a helper method called by all handle_events() methods.

Definition at line 1170 of file Dev_Poll_Reactor.cpp.

References ACE_ERROR, ACE_TRACE, dispatch(), ETIME, LM_ERROR, ACE_Sig_Handler::sig_pending(), and work_pending_i().

Referenced by handle_events().

01172 {
01173   ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events_i");
01174 
01175   int result = 0;
01176   // int active_handle_count = 0;
01177 
01178   // Poll for events
01179   //
01180   // If the underlying ioctl() call was interrupted via the interrupt
01181   // signal (i.e. returned -1 with errno == EINTR) then the loop will
01182   // be restarted if so desired.
01183   do
01184     {
01185       result = this->work_pending_i (max_wait_time);
01186       if (result == -1)
01187         ACE_ERROR((LM_ERROR, "%t: %p\n", "work_pending_i"));
01188     }
01189   while (result == -1 && this->restart_ != 0 && errno == EINTR);
01190 
01191   if (result == 0 || (result == -1 && errno == ETIME))
01192     return 0;
01193   else if (result == -1)
01194     {
01195       if (errno != EINTR)
01196         return -1;
01197 
01198       // Bail out -- we got here since the poll was interrupted.
01199       // If it was due to a signal registered through our ACE_Sig_Handler,
01200       // then it was dispatched, so we count it in the number of events
01201       // handled rather than cause an error return.
01202       if (ACE_Sig_Handler::sig_pending () != 0)
01203         {
01204           ACE_Sig_Handler::sig_pending (0);
01205           return 1;
01206         }
01207       return -1;
01208     }
01209 
01210   // Dispatch an event.
01211   return this->dispatch (guard);
01212 }

int ACE_Dev_Poll_Reactor::handler int  signum,
ACE_Event_Handler **  = 0
[virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2210 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Sig_Handler::handler(), and signal_handler_.

02212 {
02213   ACE_TRACE ("ACE_Dev_Poll_Reactor::handler");
02214 
02215   ACE_Event_Handler *handler = this->signal_handler_->handler (signum);
02216 
02217   if (handler == 0)
02218     return -1;
02219   else if (eh != 0)
02220     *eh = handler;
02221 
02222   return 0;
02223 }

int ACE_Dev_Poll_Reactor::handler ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
ACE_Event_Handler **  event_handler = 0
[virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2185 of file Dev_Poll_Reactor.cpp.

References ACE_BIT_CMP_MASK, ACE_Dev_Poll_Reactor_Token, ACE_Reactor_Mask, ACE_READ_GUARD_RETURN, ACE_TRACE, ACE_Dev_Poll_Reactor_Handler_Repository::find(), and handler_rep_.

02188 {
02189   ACE_TRACE ("ACE_Dev_Poll_Reactor::handler");
02190 
02191   ACE_MT (ACE_READ_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02192 
02193   ACE_Event_Handler *h = this->handler_rep_.find (handle);
02194 
02195   if (h != 0
02196       && ACE_BIT_CMP_MASK (this->handler_rep_.mask (handle),
02197                            mask,  // Compare all bits in the mask
02198                            mask))
02199     {
02200       if (event_handler != 0)
02201         *event_handler = h;
02202 
02203       return 0;
02204     }
02205 
02206   return -1;
02207 }

int ACE_Dev_Poll_Reactor::initialized void   )  [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2226 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, and initialized_.

02227 {
02228   ACE_TRACE ("ACE_Dev_Poll_Reactor::initialized");
02229 
02230   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02231 
02232   return this->initialized_;
02233 }

ACE_Lock & ACE_Dev_Poll_Reactor::lock void   )  [virtual]
 

Returns a reference to the Reactor's internal lock.

Implements ACE_Reactor_Impl.

Definition at line 2242 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and lock_adapter_.

02243 {
02244   ACE_TRACE ("ACE_Dev_Poll_Reactor::lock");
02245 
02246   return this->lock_adapter_;
02247 }

int ACE_Dev_Poll_Reactor::mask_ops ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
int  ops
[virtual]
 

Returns:
Old mask on success, -1 on error.

Implements ACE_Reactor_Impl.

Definition at line 2333 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_TRACE, and mask_ops_i().

02336 {
02337   ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops");
02338 
02339   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02340 
02341   return this->mask_ops_i (handle, mask, ops);
02342 }

int ACE_Dev_Poll_Reactor::mask_ops ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask,
int  ops
[virtual]
 

Returns:
Old mask on success, -1 on error.

Implements ACE_Reactor_Impl.

Definition at line 2321 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_TRACE, ACE_Event_Handler::get_handle(), and mask_ops_i().

Referenced by cancel_wakeup(), and schedule_wakeup().

02324 {
02325   ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops");
02326 
02327   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02328 
02329   return this->mask_ops_i (event_handler->get_handle (), mask, ops);
02330 }

int ACE_Dev_Poll_Reactor::mask_ops_i ACE_HANDLE  handle,
ACE_Reactor_Mask  mask,
int  ops
[protected]
 

Returns:
Old mask on success, -1 on error.

Definition at line 2345 of file Dev_Poll_Reactor.cpp.

References ACE_CLR_BITS, ACE_Reactor_Mask, ACE_SET_BITS, ACE_TRACE, ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range(), handler_rep_, ACE_Dev_Poll_Reactor_Handler_Repository::mask(), ACE_OS::memset(), poll_fd_, reactor_mask_to_poll_event(), ACE_Dev_Poll_Reactor_Handler_Repository::suspended(), and ACE_OS::write().

Referenced by mask_ops(), register_handler_i(), and remove_handler_i().

02348 {
02349   ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops_i");
02350 
02351   if (this->handler_rep_.handle_in_range (handle) == 0)
02352     return -1;
02353 
02354   // Block out all signals until method returns.
02355   ACE_Sig_Guard sb;
02356 
02357   const ACE_Reactor_Mask old_mask = this->handler_rep_.mask (handle);
02358   ACE_Reactor_Mask new_mask = old_mask;
02359 
02360   // Perform GET, CLR, SET, and ADD operations on the interest/wait
02361   // set and the suspend set (if necessary).
02362   //
02363   // GET = 1, Retrieve current value
02364   // SET = 2, Set value of bits to new mask (changes the entire mask)
02365   // ADD = 3, Bitwise "or" the value into the mask (only changes
02366   //          enabled bits)
02367   // CLR = 4  Bitwise "and" the negation of the value out of the mask
02368   //          (only changes enabled bits)
02369   //
02370   // Returns the original mask.
02371 
02372   switch (ops)
02373     {
02374     case ACE_Reactor::GET_MASK:
02375       // The work for this operation is done in all cases at the
02376       // begining of the function.
02377       return old_mask;
02378 
02379     case ACE_Reactor::CLR_MASK:
02380       ACE_CLR_BITS (new_mask, mask);
02381       break;
02382 
02383     case ACE_Reactor::SET_MASK:
02384       new_mask = mask;
02385       break;
02386 
02387     case ACE_Reactor::ADD_MASK:
02388       ACE_SET_BITS (new_mask, mask);
02389       break;
02390 
02391     default:
02392       return -1;
02393     }
02394 
02395   /// Reset the mask for the given handle.
02396   this->handler_rep_.mask (handle, new_mask);
02397 
02398   if (this->handler_rep_.suspended (handle) == 0)
02399     {
02400       // Only attempt to alter events for the handle from the
02401       // "interest set" if it hasn't been suspended.
02402 
02403       const short events = this->reactor_mask_to_poll_event (new_mask);
02404 
02405 #if defined (sun)
02406       // Apparently events cannot be updated on-the-fly on Solaris so
02407       // remove the existing events, and then add the new ones.
02408       struct pollfd pfd[2];
02409 
02410       pfd[0].fd      = handle;
02411       pfd[0].events  = POLLREMOVE;
02412       pfd[0].revents = 0;
02413       pfd[1].fd      = (events == POLLREMOVE ? ACE_INVALID_HANDLE : handle);
02414       pfd[1].events  = events;
02415       pfd[1].revents = 0;
02416 
02417       // Change the events associated with the given file descriptor.
02418       if (ACE_OS::write (this->poll_fd_,
02419                          pfd,
02420                          sizeof (pfd)) != sizeof (pfd))
02421         return -1;
02422 #elif defined (ACE_HAS_EVENT_POLL)
02423 
02424       struct epoll_event epev;
02425       ACE_OS::memset (&epev, 0, sizeof (epev));
02426       int op;
02427 
02428       // ACE_Event_Handler::NULL_MASK ???
02429       if (new_mask == 0)
02430         {
02431           op          = EPOLL_CTL_DEL;
02432           epev.events = 0;
02433         }
02434       else
02435         {
02436           op          = EPOLL_CTL_MOD;
02437           epev.events = events;
02438         }
02439 
02440       epev.data.fd = handle;
02441 
02442       if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1)
02443         {
02444           // If a handle is closed, epoll removes it from the poll set
02445           // automatically - we may not know about it yet. If that's the
02446           // case, a mod operation will fail with ENOENT. Retry it as
02447           // an add.
02448           if (op == EPOLL_CTL_MOD && errno == ENOENT &&
02449               ::epoll_ctl (this->poll_fd_, EPOLL_CTL_ADD, handle, &epev) == -1)
02450             return -1;
02451         }
02452 
02453 #else
02454       pollfd pfd[1];
02455 
02456       pfd[0].fd      = handle;
02457       pfd[0].events  = events;
02458       pfd[0].revents = 0;
02459 
02460       // Change the events associated with the given file descriptor.
02461       if (ACE_OS::write (this->poll_fd_,
02462                          pfd,
02463                          sizeof (pfd)) != sizeof (pfd))
02464         return -1;
02465 #endif /*ACE_HAS_EVENT_POLL  */
02466     }
02467 
02468   return old_mask;
02469 }

int ACE_Dev_Poll_Reactor::max_notify_iterations void   )  [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2154 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, ACE_Reactor_Notify::max_notify_iterations(), and notify_handler_.

02155 {
02156   ACE_TRACE ("ACE_Dev_Poll_Reactor::max_notify_iterations");
02157 
02158   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02159 
02160   return this->notify_handler_->max_notify_iterations ();
02161 }

void ACE_Dev_Poll_Reactor::max_notify_iterations int   )  [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2144 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD, ACE_TRACE, ACE_Reactor_Notify::max_notify_iterations(), and notify_handler_.

02145 {
02146   ACE_TRACE ("ACE_Dev_Poll_Reactor::max_notify_iterations");
02147 
02148   ACE_MT (ACE_GUARD (ACE_Dev_Poll_Reactor_Token, mon, this->token_));
02149 
02150   this->notify_handler_->max_notify_iterations (iterations);
02151 }

int ACE_Dev_Poll_Reactor::notify ACE_Event_Handler event_handler = 0,
ACE_Reactor_Mask  mask = ACE_Event_Handler::EXCEPT_MASK,
ACE_Time_Value = 0
[virtual]
 

Notify of event. The indicates how long to blocking trying to notify. If == 0, the caller will block until action is possible, else will wait until the relative time specified in elapses).

Implements ACE_Reactor_Impl.

Definition at line 2126 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, ACE_Reactor_Notify::notify(), notify_handler_, and ssize_t.

Referenced by wakeup_all_threads().

02129 {
02130   ACE_TRACE ("ACE_Dev_Poll_Reactor::notify");
02131 
02132   ssize_t n = 0;
02133 
02134   // Pass over both the Event_Handler *and* the mask to allow the
02135   // caller to dictate which Event_Handler method the receiver
02136   // invokes.  Note that this call can timeout.
02137 
02138   n = this->notify_handler_->notify (eh, mask, timeout);
02139 
02140   return n == -1 ? -1 : 0;
02141 }

int ACE_Dev_Poll_Reactor::open size_t  size,
int  restart = 0,
ACE_Sig_Handler = 0,
ACE_Timer_Queue = 0,
int  disable_notify_pipe = 0,
ACE_Reactor_Notify = 0
[virtual]
 

Initialization.

Implements ACE_Reactor_Impl.

Definition at line 826 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_NEW_RETURN, ACE_Timer_Heap, ACE_Timer_Queue, ACE_TRACE, close(), delete_notify_handler_, delete_signal_handler_, delete_timer_queue_, handler_rep_, initialized_, notify_handler_, ACE_Reactor_Notify::open(), ACE_Dev_Poll_Reactor_Handler_Repository::open(), ACE_OS::open(), poll_fd_, register_handler_i(), signal_handler_, and timer_queue_.

Referenced by ACE_Dev_Poll_Reactor().

00832 {
00833   ACE_TRACE ("ACE_Dev_Poll_Reactor::open");
00834 
00835   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
00836 
00837   // Can't initialize ourselves more than once.
00838   if (this->initialized_)
00839     return -1;
00840 
00841   this->restart_ = restart;
00842   this->signal_handler_ = sh;
00843   this->timer_queue_ = tq;
00844   this->notify_handler_ = notify;
00845 
00846   int result = 0;
00847 
00848   // Allows the signal handler to be overridden.
00849   if (this->signal_handler_ == 0)
00850     {
00851       ACE_NEW_RETURN (this->signal_handler_,
00852                       ACE_Sig_Handler,
00853                       -1);
00854 
00855       if (this->signal_handler_ == 0)
00856         result = -1;
00857       else
00858         this->delete_signal_handler_ = 1;
00859     }
00860 
00861   // Allows the timer queue to be overridden.
00862   if (result != -1 && this->timer_queue_ == 0)
00863     {
00864       ACE_NEW_RETURN (this->timer_queue_,
00865                       ACE_Timer_Heap,
00866                       -1);
00867 
00868       if (this->timer_queue_ == 0)
00869         result = -1;
00870       else
00871         this->delete_timer_queue_ = 1;
00872     }
00873 
00874   // Allows the Notify_Handler to be overridden.
00875   if (result != -1 && this->notify_handler_ == 0)
00876     {
00877       ACE_NEW_RETURN (this->notify_handler_,
00878                       ACE_Dev_Poll_Reactor_Notify,
00879                       -1);
00880 
00881       if (this->notify_handler_ == 0)
00882         result = -1;
00883       else
00884         this->delete_notify_handler_ = 1;
00885     }
00886 
00887 #if defined (ACE_HAS_EVENT_POLL)
00888 
00889   // Allocating event table:
00890   ACE_NEW_RETURN (this->events_, epoll_event[size], -1);
00891 
00892   // Initializing epoll:
00893   this->poll_fd_ = ::epoll_create (size);
00894   if (this->poll_fd_ == -1)
00895     result = -1;
00896 
00897 #else
00898 
00899   // Allocate the array before opening the device to avoid a potential
00900   // resource leak if allocation fails.
00901   ACE_NEW_RETURN (this->dp_fds_,
00902                   pollfd[size],
00903                   -1);
00904 
00905   // Open the `/dev/poll' character device.
00906   this->poll_fd_ = ACE_OS::open ("/dev/poll", O_RDWR);
00907   if (this->poll_fd_ == ACE_INVALID_HANDLE)
00908     result = -1;
00909 
00910 #endif  /* ACE_HAS_EVENT_POLL */
00911 
00912   if (result != -1 && this->handler_rep_.open (size) == -1)
00913     result = -1;
00914 
00915   // Registration of the notification handler must be done after the
00916   // /dev/poll device has been fully initialized.
00917   else if (this->notify_handler_->open (this,
00918                                         0,
00919                                         disable_notify_pipe) == -1
00920            || (disable_notify_pipe == 0
00921                && this->register_handler_i (
00922                                             this->notify_handler_->notify_handle (),
00923                                             this->notify_handler_,
00924                                             ACE_Event_Handler::READ_MASK)) == -1)
00925     result = -1;
00926 
00927   this->size_ = size;
00928 
00929   if (result != -1)
00930     // We're all set to go.
00931     this->initialized_ = true;
00932   else
00933     // This will close down all the allocated resources properly.
00934     (void) this->close ();
00935 
00936   return result;
00937 }

int ACE_Dev_Poll_Reactor::owner ACE_thread_t owner  )  [virtual]
 

Return the ID of the "owner" thread.

Note:
There is no need to set the owner of the event loop for the ACE_Dev_Poll_Reactor. Multiple threads may invoke the event loop simulataneously. As such, this method is a no-op.

Implements ACE_Reactor_Impl.

Definition at line 2274 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE.

02275 {
02276   ACE_TRACE ("ACE_Dev_Poll_Reactor::owner");
02277 
02278   // There is no need to set the owner of the event loop.  Multiple
02279   // threads may invoke the event loop simulataneously.
02280 
02281   return 0;
02282 }

int ACE_Dev_Poll_Reactor::owner ACE_thread_t  new_owner,
ACE_thread_t old_owner = 0
[virtual]
 

Transfers ownership of Reactor_Impl to the new_owner.

Note:
There is no need to set the owner of the event loop for the ACE_Dev_Poll_Reactor. Multiple threads may invoke the event loop simulataneously. As such, this method is a no-op.

Implements ACE_Reactor_Impl.

Definition at line 2262 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE.

02264 {
02265   ACE_TRACE ("ACE_Dev_Poll_Reactor::owner");
02266 
02267   // There is no need to set the owner of the event loop.  Multiple
02268   // threads may invoke the event loop simulataneously.
02269 
02270   return 0;
02271 }

int ACE_Dev_Poll_Reactor::purge_pending_notifications ACE_Event_Handler = 0,
ACE_Reactor_Mask  = ACE_Event_Handler::ALL_EVENTS_MASK
[virtual]
 

Purge any notifications pending in this reactor for the specified ACE_Event_Handler object. Returns the number of notifications purged. Returns -1 on error.

Implements ACE_Reactor_Impl.

Definition at line 2164 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, notify_handler_, and ACE_Reactor_Notify::purge_pending_notifications().

02166 {
02167   if (this->notify_handler_ == 0)
02168     return 0;
02169 
02170   return this->notify_handler_->purge_pending_notifications (eh, mask);
02171 }

short ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event ACE_Reactor_Mask  mask  )  [protected]
 

Convert a reactor mask to its corresponding poll() event mask.

Definition at line 2518 of file Dev_Poll_Reactor.cpp.

References ACE_BIT_ENABLED, ACE_Reactor_Mask, ACE_SET_BITS, and ACE_TRACE.

Referenced by mask_ops_i(), register_handler_i(), and resume_handler_i().

02519 {
02520   ACE_TRACE ("ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event");
02521 
02522   if (mask == ACE_Event_Handler::NULL_MASK)
02523     // No event.  Remove from interest set.
02524 #if defined (ACE_HAS_EVENT_POLL)
02525     return EPOLL_CTL_DEL;
02526 #else
02527     return POLLREMOVE;
02528 #endif /* ACE_HAS_EVENT_POLL */
02529 
02530   short events = 0;
02531 
02532   // READ, ACCEPT, and CONNECT flag will place the handle in the
02533   // read set.
02534   if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)
02535       || ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)
02536       || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK))
02537     {
02538 #if defined (ACE_HAS_EVENT_POLL)
02539       ACE_SET_BITS (events, EPOLLIN);
02540 #else
02541       ACE_SET_BITS (events, POLLIN);
02542 #endif /*ACE_HAS_EVENT_POLL*/
02543     }
02544 
02545   // WRITE and CONNECT flag will place the handle in the write set.
02546   if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)
02547       || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK))
02548     {
02549 #if defined (ACE_HAS_EVENT_POLL)
02550       ACE_SET_BITS (events, EPOLLOUT);
02551 #else
02552       ACE_SET_BITS (events, POLLOUT);
02553 #endif /*ACE_HAS_EVENT_POLL*/
02554     }
02555 
02556   // EXCEPT flag will place the handle in the except set.
02557   if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK))
02558     {
02559 #if defined (ACE_HAS_EVENT_POLL)
02560       ACE_SET_BITS (events, EPOLLPRI);
02561 #else
02562       ACE_SET_BITS (events, POLLPRI);
02563 #endif /*ACE_HAS_EVENT_POLL*/
02564     }
02565 
02566   return events;
02567 }

int ACE_Dev_Poll_Reactor::ready_ops ACE_HANDLE  handle,
ACE_Reactor_Mask  ,
int  ops
[virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2485 of file Dev_Poll_Reactor.cpp.

References ACE_NOTSUP_RETURN, ACE_Reactor_Mask, and ACE_TRACE.

02488 {
02489   ACE_TRACE ("ACE_Dev_Poll_Reactor::ready_ops");
02490 
02491   // Since the Dev_Poll_Reactor uses the poll result buffer, the
02492   // ready_set cannot be directly manipulated outside of the event
02493   // loop.
02494   ACE_NOTSUP_RETURN (-1);
02495 }

int ACE_Dev_Poll_Reactor::ready_ops ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask,
int  ops
[virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2472 of file Dev_Poll_Reactor.cpp.

References ACE_NOTSUP_RETURN, ACE_Reactor_Mask, and ACE_TRACE.

02475 {
02476   ACE_TRACE ("ACE_Dev_Poll_Reactor::ready_ops");
02477 
02478   // Since the Dev_Poll_Reactor uses the poll result buffer, the
02479   // ready_set cannot be directly manipulated outside of the event
02480   // loop.
02481   ACE_NOTSUP_RETURN (-1);
02482 }

int ACE_Dev_Poll_Reactor::register_handler const ACE_Sig_Set sigset,
ACE_Event_Handler new_sh,
ACE_Sig_Action new_disp = 0
[virtual]
 

Registers to handle a set of signals using the .

Implements ACE_Reactor_Impl.

Definition at line 1643 of file Dev_Poll_Reactor.cpp.

References ACE_NSIG, ACE_TRACE, ACE_Sig_Set::is_member(), ACE_Sig_Handler::register_handler(), and signal_handler_.

01646 {
01647   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
01648 
01649   int result = 0;
01650 
01651 #if (ACE_NSIG > 0)
01652 
01653   for (int s = 1; s < ACE_NSIG; ++s)
01654     if ((sigset.is_member (s) == 1)
01655         && this->signal_handler_->register_handler (s,
01656                                                     new_sh,
01657                                                     new_disp) == -1)
01658       result = -1;
01659 
01660 #else  /* ACE_NSIG <= 0 */
01661 
01662   ACE_UNUSED_ARG (sigset);
01663   ACE_UNUSED_ARG (new_sh);
01664   ACE_UNUSED_ARG (new_disp);
01665 
01666 #endif /* ACE_NSIG <= 0  */
01667 
01668   return result;
01669 }

int ACE_Dev_Poll_Reactor::register_handler int  signum,
ACE_Event_Handler new_sh,
ACE_Sig_Action new_disp = 0,
ACE_Event_Handler **  old_sh = 0,
ACE_Sig_Action old_disp = 0
[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 1627 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Sig_Handler::register_handler(), and signal_handler_.

01632 {
01633   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
01634 
01635   return this->signal_handler_->register_handler (signum,
01636                                                   new_sh,
01637                                                   new_disp,
01638                                                   old_sh,
01639                                                   old_disp);
01640 }

int ACE_Dev_Poll_Reactor::register_handler const ACE_Handle_Set handles,
ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask
[virtual]
 

Register event_handler> with all the handles> in the Handle_Set.

Implements ACE_Reactor_Impl.

Definition at line 1602 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_TRACE, and register_handler_i().

01605 {
01606   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
01607 
01608   ACE_Handle_Set_Iterator handle_iter (handle_set);
01609 
01610   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01611 
01612   // @@ It might be more efficient to construct a pollfd array and
01613   //    pass it to the write() call in register_handler_i() only once,
01614   //    instead of calling write() (a system call) once for each file
01615   //    descriptor.
01616 
01617   for (ACE_HANDLE h = handle_iter ();
01618        h != ACE_INVALID_HANDLE;
01619        h = handle_iter ())
01620     if (this->register_handler_i (h, event_handler, mask) == -1)
01621       return -1;
01622 
01623   return 0;
01624 }

int ACE_Dev_Poll_Reactor::register_handler ACE_HANDLE  event_handle,
ACE_HANDLE  io_handle,
ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask
[virtual]
 

Register an event_handler that will be notified when event_handle is signaled. mask specifies the network events that the event_handler is interested in.

Implements ACE_Reactor_Impl.

Definition at line 1592 of file Dev_Poll_Reactor.cpp.

References ACE_NOTSUP_RETURN, and ACE_Reactor_Mask.

01597 {
01598   ACE_NOTSUP_RETURN (-1);
01599 }

int ACE_Dev_Poll_Reactor::register_handler ACE_HANDLE  io_handle,
ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask
[virtual]
 

Register event_handler with mask. The I/O handle is provided through the io_handle parameter.

Implements ACE_Reactor_Impl.

Definition at line 1507 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_TRACE, and register_handler_i().

01510 {
01511   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
01512 
01513   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01514 
01515   return this->register_handler_i (handle,
01516                                    event_handler,
01517                                    mask);
01518 }

int ACE_Dev_Poll_Reactor::register_handler ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask
[virtual]
 

Register event_handler with mask. The I/O handle will always come from get_handle on the event_handler.

Implements ACE_Reactor_Impl.

Definition at line 1494 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_TRACE, ACE_Event_Handler::get_handle(), and register_handler_i().

01496 {
01497   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
01498 
01499   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01500 
01501   return this->register_handler_i (handler->get_handle (),
01502                                    handler,
01503                                    mask);
01504 }

int ACE_Dev_Poll_Reactor::register_handler_i ACE_HANDLE  handle,
ACE_Event_Handler eh,
ACE_Reactor_Mask  mask
[protected]
 

Register the given event handler with the reactor.

Definition at line 1521 of file Dev_Poll_Reactor.cpp.

References ACE_ERROR, ACE_ERROR_RETURN, ACE_Reactor_Mask, ACE_TRACE, ACE_Dev_Poll_Reactor_Handler_Repository::bind(), ACE_Dev_Poll_Reactor_Handler_Repository::find(), handler_rep_, LM_ERROR, mask_ops_i(), ACE_OS::memset(), poll_fd_, reactor_mask_to_poll_event(), ACE_Dev_Poll_Reactor_Handler_Repository::unbind(), and ACE_OS::write().

Referenced by open(), and register_handler().

01524 {
01525   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler_i");
01526 
01527   if (handle == ACE_INVALID_HANDLE
01528       || mask == ACE_Event_Handler::NULL_MASK)
01529     {
01530       errno = EINVAL;
01531       return -1;
01532     }
01533 
01534  if (this->handler_rep_.find (handle) == 0)
01535    {
01536      // Handler not present in the repository.  Bind it.
01537      if (this->handler_rep_.bind (handle, event_handler, mask) != 0)
01538        return -1;
01539 
01540 #if defined (ACE_HAS_EVENT_POLL)
01541 
01542      struct epoll_event epev;
01543      ACE_OS::memset (&epev, 0, sizeof (epev));
01544      static const int op = EPOLL_CTL_ADD;
01545 
01546      epev.events  = this->reactor_mask_to_poll_event (mask);
01547      epev.data.fd = handle;
01548 
01549      if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1)
01550        {
01551          ACE_ERROR ((LM_ERROR, "%p\n", "epoll_ctl"));
01552          (void) this->handler_rep_.unbind (handle);
01553          return -1;
01554        }
01555 
01556 #endif /* ACE_HAS_EVENT_POLL */
01557    }
01558  else
01559    {
01560      // Handler is already present in the repository, so register it
01561      // again, possibly for different event.  Add new mask to the
01562      // current one.
01563      if (this->mask_ops_i (handle, mask, ACE_Reactor::ADD_MASK) == -1)
01564        ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "mask_ops_i"), -1);
01565    }
01566 
01567 #ifndef  ACE_HAS_EVENT_POLL
01568 
01569   struct pollfd pfd;
01570 
01571   pfd.fd      = handle;
01572   pfd.events  = this->reactor_mask_to_poll_event (mask);
01573   pfd.revents = 0;
01574 
01575   // Add file descriptor to the "interest set."
01576   if (ACE_OS::write (this->poll_fd_, &pfd, sizeof (pfd)) != sizeof (pfd))
01577     {
01578       (void) this->handler_rep_.unbind (handle);
01579       return -1;
01580     }
01581 #endif /*ACE_HAS_EVENT_POLL*/
01582 
01583   // Note the fact that we've changed the state of the wait_set_,
01584   // which is used by the dispatching loop to determine whether it can
01585   // keep going or if it needs to reconsult select().
01586   // this->state_changed_ = 1;
01587 
01588   return 0;
01589 }

int ACE_Dev_Poll_Reactor::remove_handler const ACE_Sig_Set sigset  )  [virtual]
 

Calls for every signal in .

Implements ACE_Reactor_Impl.

Definition at line 1766 of file Dev_Poll_Reactor.cpp.

References ACE_NSIG, ACE_TRACE, ACE_Sig_Set::is_member(), ACE_Sig_Handler::remove_handler(), and signal_handler_.

01767 {
01768   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
01769 
01770   int result = 0;
01771 
01772 #if (ACE_NSIG > 0)
01773 
01774   for (int s = 1; s < ACE_NSIG; ++s)
01775     if ((sigset.is_member (s) == 1)
01776         && this->signal_handler_->remove_handler (s) == -1)
01777       result = -1;
01778 
01779 #else  /* ACE_NSIG <= 0 */
01780 
01781   ACE_UNUSED_ARG (sigset);
01782 
01783 #endif /* ACE_NSIG <= 0 */
01784 
01785   return result;
01786 }

int ACE_Dev_Poll_Reactor::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 . Install the new disposition (if given) and return the previous disposition (if desired by the caller). Returns 0 on success and -1 if is invalid.

Implements ACE_Reactor_Impl.

Definition at line 1752 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Sig_Handler::remove_handler(), and signal_handler_.

01756 {
01757   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
01758 
01759   return this->signal_handler_->remove_handler (signum,
01760                                                 new_disp,
01761                                                 old_disp,
01762                                                 sigkey);
01763 }

int ACE_Dev_Poll_Reactor::remove_handler const ACE_Handle_Set handle_set,
ACE_Reactor_Mask  mask
[virtual]
 

Removes all handles in . If == <ACE_Event_Handler::DONT_CALL> then the method of the associated s is not invoked.

Implements ACE_Reactor_Impl.

Definition at line 1728 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_TRACE, and remove_handler_i().

01730 {
01731   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
01732 
01733   ACE_Handle_Set_Iterator handle_iter (handle_set);
01734 
01735   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01736 
01737   // @@ It might be more efficient to construct a pollfd array and
01738   //    pass it to the write() call in register_handler_i() only once,
01739   //    instead of calling write() (a system call) once for each file
01740   //    descriptor.
01741 
01742   for (ACE_HANDLE h = handle_iter ();
01743        h != ACE_INVALID_HANDLE;
01744        h = handle_iter ())
01745     if (this->remove_handler_i (h, mask) == -1)
01746       return -1;
01747 
01748   return 0;
01749 }

int ACE_Dev_Poll_Reactor::remove_handler ACE_HANDLE  handle,
ACE_Reactor_Mask  mask
[virtual]
 

Removes . If == <ACE_Event_Handler::DONT_CALL> then the method of the associated is not invoked.

Implements ACE_Reactor_Impl.

Definition at line 1683 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_TRACE, and remove_handler_i().

01685 {
01686   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
01687 
01688   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01689 
01690   return this->remove_handler_i (handle, mask);
01691 }

int ACE_Dev_Poll_Reactor::remove_handler ACE_Event_Handler event_handler,
ACE_Reactor_Mask  mask
[virtual]
 

Removes event_handler.

Note:
The I/O handle will be obtained using get_handle() method of event_handler . If mask == ACE_Event_Handler::DONT_CALL then the handle_close() method of the event_handler is not invoked.

Implements ACE_Reactor_Impl.

Definition at line 1672 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_TRACE, ACE_Event_Handler::get_handle(), and remove_handler_i().

Referenced by dispatch_io_event().

01674 {
01675   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
01676 
01677   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01678 
01679   return this->remove_handler_i (handler->get_handle (), mask);
01680 }

int ACE_Dev_Poll_Reactor::remove_handler_i ACE_HANDLE  handle,
ACE_Reactor_Mask  mask
[protected]
 

Remove the event handler associated with the given handle and event mask from the "interest set."

Definition at line 1694 of file Dev_Poll_Reactor.cpp.

References ACE_BIT_DISABLED, ACE_Reactor_Mask, ACE_TRACE, ACE_Dev_Poll_Reactor_Handler_Repository::find(), ACE_Event_Handler::handle_close(), handler_rep_, ACE_Dev_Poll_Reactor_Handler_Repository::mask(), mask_ops_i(), ACE_Event_Handler::reference_counting_policy(), and ACE_Dev_Poll_Reactor_Handler_Repository::unbind().

Referenced by dispatch_io_event(), and remove_handler().

01696 {
01697   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler_i");
01698 
01699   ACE_Event_Handler *eh = this->handler_rep_.find (handle);
01700 
01701   if (eh == 0 ||
01702       this->mask_ops_i (handle, mask, ACE_Reactor::CLR_MASK) == -1)
01703     return -1;
01704 
01705   // Check for ref counting now - handle_close() may delete eh.
01706   int requires_reference_counting =
01707     eh->reference_counting_policy ().value () ==
01708     ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
01709 
01710   if (ACE_BIT_DISABLED (mask, ACE_Event_Handler::DONT_CALL))
01711     (void) eh->handle_close (handle, mask);
01712 
01713   // If there are no longer any outstanding events on the given handle
01714   // then remove it from the handler repository.
01715   if (this->handler_rep_.mask (handle) == ACE_Event_Handler::NULL_MASK)
01716     this->handler_rep_.unbind (handle, requires_reference_counting);
01717 
01718   // Note the fact that we've changed the state of the wait_set,
01719   // i.e. the "interest set," which is used by the dispatching loop to
01720   // determine whether it can keep going or if it needs to reconsult
01721   // /dev/poll or /dev/epoll.
01722   // this->state_changed_ = 1;
01723 
01724   return 0;
01725 }

int ACE_Dev_Poll_Reactor::requeue_position void   )  [virtual]
 

Get position of the owner thread.

Note:
This is currently a no-op.

Implements ACE_Reactor_Impl.

Definition at line 2313 of file Dev_Poll_Reactor.cpp.

References ACE_NOTSUP_RETURN, and ACE_TRACE.

02314 {
02315   ACE_TRACE ("ACE_Dev_Poll_Reactor::requeue_position");
02316 
02317   ACE_NOTSUP_RETURN (-1);
02318 }

void ACE_Dev_Poll_Reactor::requeue_position int   )  [virtual]
 

Set position of the owner thread.

Note:
This is currently a no-op.

Implements ACE_Reactor_Impl.

Definition at line 2307 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE.

02308 {
02309   ACE_TRACE ("ACE_Dev_Poll_Reactor::requeue_position");
02310 }

int ACE_Dev_Poll_Reactor::reset_timer_interval long  timer_id,
const ACE_Time_Value interval
[virtual]
 

Resets the interval of the timer represented by to , which is specified in relative time to the current . If 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 2045 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, ESHUTDOWN, ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::reset_interval(), and timer_queue_.

02047 {
02048   ACE_TRACE ("ACE_Dev_Poll_Reactor::reset_timer_interval");
02049 
02050   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02051 
02052   if (0 != this->timer_queue_)
02053     return this->timer_queue_->reset_interval (timer_id, interval);
02054 
02055   errno = ESHUTDOWN;
02056   return -1;
02057 }

int ACE_Dev_Poll_Reactor::restart int  r  )  [virtual]
 

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

Parameters:
r If zero, then the event loop will not be automatically restarted if the underlying poll is interrupted via the INTR (interrupt) signal.
Returns:
Returns the previous "restart" value.

Implements ACE_Reactor_Impl.

Definition at line 2295 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, and ACE_TRACE.

02296 {
02297   ACE_TRACE ("ACE_Dev_Poll_Reactor::restart");
02298 
02299   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02300 
02301   int current_value = this->restart_;
02302   this->restart_ = r;
02303   return current_value;
02304 }

int ACE_Dev_Poll_Reactor::restart void   )  [virtual]
 

Get the existing restart value.

Implements ACE_Reactor_Impl.

Definition at line 2285 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, and ACE_TRACE.

02286 {
02287   ACE_TRACE ("ACE_Dev_Poll_Reactor::restart");
02288 
02289   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02290 
02291   return this->restart_;
02292 }

int ACE_Dev_Poll_Reactor::resumable_handler void   )  [virtual]
 

Does the reactor allow the application to resume the handle on its own, i.e., can it pass on the control of handle resumption to the application.

Implements ACE_Reactor_Impl.

Definition at line 2008 of file Dev_Poll_Reactor.cpp.

02009 {
02010   // @@ Is this correct?
02011 
02012   return 0;
02013 }

int ACE_Dev_Poll_Reactor::resume_handler const ACE_Handle_Set handles  )  [virtual]
 

Resume all handles in handle set.

Implements ACE_Reactor_Impl.

Definition at line 1926 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, and resume_handler_i().

01927 {
01928   ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler");
01929 
01930   ACE_Handle_Set_Iterator handle_iter (handles);
01931   ACE_HANDLE h;
01932 
01933   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01934 
01935   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
01936     if (this->resume_handler_i (h) == -1)
01937       return -1;
01938 
01939   return 0;
01940 }

int ACE_Dev_Poll_Reactor::resume_handler ACE_HANDLE  handle  )  [virtual]
 

Resume handle.

Implements ACE_Reactor_Impl.

Definition at line 1916 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, and resume_handler_i().

01917 {
01918   ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler");
01919 
01920   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01921 
01922   return this->resume_handler_i (handle);
01923 }

int ACE_Dev_Poll_Reactor::resume_handler ACE_Event_Handler event_handler  )  [virtual]
 

Resume event_handler. Use ACE_Event_Handler::get_handle() to get the handle.

Implements ACE_Reactor_Impl.

Definition at line 1898 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, ACE_Event_Handler::get_handle(), and resume_handler_i().

01899 {
01900   ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler");
01901 
01902   if (event_handler == 0)
01903     {
01904       errno = EINVAL;
01905       return -1;
01906     }
01907 
01908   ACE_HANDLE handle = event_handler->get_handle ();
01909 
01910   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01911 
01912   return this->resume_handler_i (handle);
01913 }

int ACE_Dev_Poll_Reactor::resume_handler_i ACE_HANDLE  handle  )  [protected]
 

Place the given handle that was temporarily removed from the "interest set," i.e that was suspended, back in to the interest set. The given handle will once again be polled for events.

Definition at line 1960 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, ACE_Dev_Poll_Reactor_Handler_Repository::find(), handler_rep_, ACE_Dev_Poll_Reactor_Handler_Repository::mask(), ACE_OS::memset(), poll_fd_, reactor_mask_to_poll_event(), ACE_Dev_Poll_Reactor_Handler_Repository::resume(), ACE_Dev_Poll_Reactor_Handler_Repository::suspended(), and ACE_OS::write().

Referenced by resume_handler(), and resume_handlers().

01961 {
01962   ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler_i");
01963 
01964   if (this->handler_rep_.find (handle) == 0
01965       && this->handler_rep_.suspended (handle) == 0)
01966     return -1;
01967 
01968   ACE_Reactor_Mask mask = this->handler_rep_.mask (handle);
01969 
01970   if (mask == ACE_Event_Handler::NULL_MASK)
01971     return -1;
01972 
01973   // Place the handle back in to the "interest set."
01974   //
01975   // Events for the given handle will once again be polled.
01976 
01977 #if defined (ACE_HAS_EVENT_POLL)
01978 
01979   struct epoll_event epev;
01980   ACE_OS::memset (&epev, 0, sizeof (epev));
01981   static const int op = EPOLL_CTL_ADD;
01982 
01983   epev.events  = this->reactor_mask_to_poll_event (mask);
01984   epev.data.fd = handle;
01985 
01986   if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1)
01987     return -1;
01988 
01989 #else
01990 
01991   struct pollfd pfd[1];
01992 
01993   pfd[0].fd      = handle;
01994   pfd[0].events  = this->reactor_mask_to_poll_event (mask);
01995   pfd[0].revents = 0;
01996 
01997   if (ACE_OS::write (this->poll_fd_, pfd, sizeof (pfd)) != sizeof (pfd))
01998     return -1;
01999 
02000 #endif  /* ACE_HAS_EVENT_POLL */
02001 
02002   this->handler_rep_.resume (handle);
02003 
02004   return 0;
02005 }

int ACE_Dev_Poll_Reactor::resume_handlers void   )  [virtual]
 

Resume all handles.

Implements ACE_Reactor_Impl.

Definition at line 1943 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, handler_rep_, resume_handler_i(), ACE_Dev_Poll_Reactor_Handler_Repository::size(), and ACE_Dev_Poll_Reactor_Handler_Repository::suspended().

01944 {
01945   ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handlers");
01946 
01947   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01948 
01949   const size_t len = this->handler_rep_.size ();
01950 
01951   for (size_t i = 0; i < len; ++i)
01952     if (this->handler_rep_.suspended (i)
01953         && this->resume_handler_i (i) != 0)
01954       return -1;
01955 
01956   return 0;
01957 }

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

Schedule 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 for which the timer will be automatically rescheduled.
Returns:
-1 on failure, a timer_id value on success

Implements ACE_Reactor_Impl.

Definition at line 2024 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, ESHUTDOWN, ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::gettimeofday(), ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::schedule(), and timer_queue_.

02028 {
02029   ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_timer");
02030 
02031   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
02032 
02033   if (0 != this->timer_queue_)
02034     return this->timer_queue_->schedule
02035       (event_handler,
02036        arg,
02037        this->timer_queue_->gettimeofday () + delay,
02038        interval);
02039 
02040   errno = ESHUTDOWN;
02041   return -1;
02042 }

int ACE_Dev_Poll_Reactor::schedule_wakeup ACE_HANDLE  handle,
ACE_Reactor_Mask  masks_to_be_added
[virtual]
 

Add to the 's entry. associated with must already have been registered.

Implements ACE_Reactor_Impl.

Definition at line 2099 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, and mask_ops().

02101 {
02102   ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_wakeup");
02103 
02104   return this->mask_ops (handle, mask, ACE_Reactor::ADD_MASK);
02105 }

int ACE_Dev_Poll_Reactor::schedule_wakeup ACE_Event_Handler event_handler,
ACE_Reactor_Mask  masks_to_be_added
[virtual]
 

Add to the 's entry. must already have been registered.

Implements ACE_Reactor_Impl.

Definition at line 2090 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, ACE_Event_Handler::get_handle(), and mask_ops().

02092 {
02093   ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_wakeup");
02094 
02095   return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::ADD_MASK);
02096 }

int ACE_Dev_Poll_Reactor::set_sig_handler ACE_Sig_Handler signal_handler  )  [virtual]
 

Use a user specified signal handler instead.

Implements ACE_Reactor_Impl.

Definition at line 947 of file Dev_Poll_Reactor.cpp.

References delete_signal_handler_, and signal_handler_.

00948 {
00949   if (this->delete_signal_handler_ && this->signal_handler_)
00950     delete this->signal_handler_;
00951 
00952   this->signal_handler_ = signal_handler;
00953   this->delete_signal_handler_ = 0;
00954 
00955   return 0;
00956 }

size_t ACE_Dev_Poll_Reactor::size void   )  const [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2236 of file Dev_Poll_Reactor.cpp.

02237 {
02238   return this->size_;
02239 }

int ACE_Dev_Poll_Reactor::suspend_handler const ACE_Handle_Set handles  )  [virtual]
 

Suspend all handles in handle set temporarily.

Implements ACE_Reactor_Impl.

Definition at line 1817 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, and suspend_handler_i().

01818 {
01819   ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler");
01820 
01821   ACE_Handle_Set_Iterator handle_iter (handles);
01822   ACE_HANDLE h;
01823 
01824   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01825 
01826   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
01827     if (this->suspend_handler_i (h) == -1)
01828       return -1;
01829 
01830   return 0;
01831 }

int ACE_Dev_Poll_Reactor::suspend_handler ACE_HANDLE  handle  )  [virtual]
 

Suspend handle temporarily.

Implements ACE_Reactor_Impl.

Definition at line 1807 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, and suspend_handler_i().

01808 {
01809   ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler");
01810 
01811   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01812 
01813   return this->suspend_handler_i (handle);
01814 }

int ACE_Dev_Poll_Reactor::suspend_handler ACE_Event_Handler event_handler  )  [virtual]
 

Suspend event_handler temporarily. Use ACE_Event_Handler::get_handle() to get the handle.

Implements ACE_Reactor_Impl.

Definition at line 1789 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, ACE_Event_Handler::get_handle(), and suspend_handler_i().

01790 {
01791   ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler");
01792 
01793   if (event_handler == 0)
01794     {
01795       errno = EINVAL;
01796       return -1;
01797     }
01798 
01799   ACE_HANDLE handle = event_handler->get_handle ();
01800 
01801   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01802 
01803   return this->suspend_handler_i (handle);
01804 }

int ACE_Dev_Poll_Reactor::suspend_handler_i ACE_HANDLE  handle  )  [protected]
 

Temporarily remove the given handle from the "interest set.".

Definition at line 1851 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Dev_Poll_Reactor_Handler_Repository::find(), handler_rep_, ACE_OS::memset(), poll_fd_, ACE_Dev_Poll_Reactor_Handler_Repository::suspend(), ACE_Dev_Poll_Reactor_Handler_Repository::suspended(), and ACE_OS::write().

Referenced by suspend_handler(), and suspend_handlers().

01852 {
01853   ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler_i");
01854 
01855   if (this->handler_rep_.find (handle) == 0)
01856     return -1;
01857 
01858   if (this->handler_rep_.suspended (handle))
01859     return 0;  // Already suspended.  @@ Should this be an error?
01860 
01861   // Remove the handle from the "interest set."
01862   //
01863   // Note that the associated event handler is still in the handler
01864   // repository, but no events will be polled on the given handle thus
01865   // no event will be dispatched to the event handler.
01866 
01867 #if defined (ACE_HAS_EVENT_POLL)
01868 
01869   struct epoll_event epev;
01870   ACE_OS::memset (&epev, 0, sizeof (epev));
01871   static const int op = EPOLL_CTL_DEL;
01872 
01873   epev.events  = 0;
01874   epev.data.fd = handle;
01875 
01876   if (::epoll_ctl (this->poll_fd_, op, handle, &epev) == -1)
01877     return -1;
01878 
01879 #else
01880 
01881   struct pollfd pfd[1];
01882 
01883   pfd[0].fd      = handle;
01884   pfd[0].events  = POLLREMOVE;
01885   pfd[0].revents = 0;
01886 
01887   if (ACE_OS::write (this->poll_fd_, pfd, sizeof (pfd)) != sizeof (pfd))
01888     return -1;
01889 
01890 #endif  /* ACE_HAS_EVENT_POLL */
01891 
01892   this->handler_rep_.suspend (handle);
01893 
01894   return 0;
01895 }

int ACE_Dev_Poll_Reactor::suspend_handlers void   )  [virtual]
 

Suspend all handles temporarily.

Implements ACE_Reactor_Impl.

Definition at line 1834 of file Dev_Poll_Reactor.cpp.

References ACE_Dev_Poll_Reactor_Token, ACE_GUARD_RETURN, ACE_TRACE, handler_rep_, ACE_Dev_Poll_Reactor_Handler_Repository::size(), suspend_handler_i(), and ACE_Dev_Poll_Reactor_Handler_Repository::suspended().

01835 {
01836   ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handlers");
01837 
01838   ACE_MT (ACE_GUARD_RETURN (ACE_Dev_Poll_Reactor_Token, mon, this->token_, -1));
01839 
01840   const size_t len = this->handler_rep_.size ();
01841 
01842   for (size_t i = 0; i < len; ++i)
01843     if (this->handler_rep_.suspended (i) == 0
01844         && this->suspend_handler_i (i) != 0)
01845       return -1;
01846 
01847   return 0;
01848 }

ACE_Timer_Queue * ACE_Dev_Poll_Reactor::timer_queue void   )  const [virtual]
 

Get the timer queue

Returns:
The current ACE_Timer_Queue.

Implements ACE_Reactor_Impl.

Definition at line 972 of file Dev_Poll_Reactor.cpp.

References timer_queue_.

00973 {
00974   return this->timer_queue_;
00975 }

int ACE_Dev_Poll_Reactor::timer_queue ACE_Timer_Queue tq  )  [virtual]
 

Set a user-specified timer queue.

Implements ACE_Reactor_Impl.

Definition at line 959 of file Dev_Poll_Reactor.cpp.

References ACE_Timer_Queue, delete_timer_queue_, and timer_queue_.

00960 {
00961   if (this->delete_timer_queue_ && this->timer_queue_)
00962     delete this->timer_queue_;
00963 
00964   this->timer_queue_ = tq;
00965   this->delete_timer_queue_ = 0;
00966 
00967   return 0;
00968 
00969 }

ACE_INLINE int ACE_Dev_Poll_Reactor::upcall ACE_Event_Handler event_handler,
int(ACE_Event_Handler::*  callback)(ACE_HANDLE),
ACE_HANDLE  handle
[protected]
 

Perform the upcall with the given event handler method.

Definition at line 169 of file Dev_Poll_Reactor.inl.

Referenced by dispatch_io_event().

00172 {
00173   // If the handler returns positive value (requesting a reactor
00174   // callback) just call back as many times as the handler requests
00175   // it.  Other threads are off handling other things.
00176   int status = 0;
00177 
00178   do
00179     {
00180       status = (event_handler->*callback) (handle);
00181     }
00182   while (status > 0);
00183 
00184   return status;
00185 }

int ACE_Dev_Poll_Reactor::uses_event_associations void   )  [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2016 of file Dev_Poll_Reactor.cpp.

02017 {
02018   // Since the Dev_Poll_Reactor does not do any event associations,
02019   // this method always return zero.
02020   return 0;
02021 }

void ACE_Dev_Poll_Reactor::wakeup_all_threads void   )  [virtual]
 

Wake up all threads waiting in the event loop.

Implements ACE_Reactor_Impl.

Definition at line 2250 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and notify().

Referenced by deactivate().

02251 {
02252   ACE_TRACE ("ACE_Dev_Poll_Reactor::wakeup_all_threads");
02253 
02254   // Send a notification, but don't block if there's no one to receive
02255   // it.
02256   this->notify (0,
02257                 ACE_Event_Handler::NULL_MASK,
02258                 (ACE_Time_Value *) &ACE_Time_Value::zero);
02259 }

int ACE_Dev_Poll_Reactor::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".

Note:
It is only possible to achieve millisecond timeout resolutions with the ACE_Dev_Poll_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 1045 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Dev_Poll_Reactor::Token_Guard::acquire_quietly(), ACE_Dev_Poll_Reactor::Token_Guard::is_owner(), and work_pending_i().

01046 {
01047   ACE_TRACE ("ACE_Dev_Poll_Reactor::work_pending");
01048 
01049   // Stash the current time
01050   //
01051   // The destructor of this object will automatically compute how much
01052   // time elapsed since this method was called.
01053   ACE_Time_Value mwt (max_wait_time);
01054   ACE_MT (ACE_Countdown_Time countdown (&mwt));
01055 
01056   Token_Guard guard (this->token_);
01057   int result = guard.acquire_quietly (&mwt);
01058 
01059   // If the guard is NOT the owner just return the retval
01060   if (!guard.is_owner ())
01061     return result;
01062 
01063   // Update the countdown to reflect time waiting for the mutex.
01064   ACE_MT (countdown.update ());
01065 
01066   return this->work_pending_i (&mwt);
01067 }

int ACE_Dev_Poll_Reactor::work_pending_i ACE_Time_Value max_wait_time  )  [protected]
 

Non-locking version of wait_pending().

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

Note:
It is only possible to achieve millisecond timeout resolutions with the ACE_Dev_Poll_Reactor.

Definition at line 1070 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::calculate_timeout(), deactivated_, end_pevents_, events_, ACE_OS::ioctl(), poll_fd_, start_pevents_, and timer_queue_.

Referenced by handle_events_i(), and work_pending().

01071 {
01072   ACE_TRACE ("ACE_Dev_Poll_Reactor::work_pending_i");
01073 
01074   if (this->deactivated_)
01075     return 0;
01076 
01077 #if defined (ACE_HAS_EVENT_POLL)
01078   if (this->start_pevents_ != this->end_pevents_)
01079 #else
01080   if (this->start_pfds_ != this->end_pfds_)
01081 #endif /* ACE_HAS_EVENT_POLL */
01082     return 1;  // We still have work_pending(). Do not poll for
01083                // additional events.
01084 
01085   ACE_Time_Value timer_buf (0);
01086   ACE_Time_Value *this_timeout = 0;
01087 
01088   this_timeout = this->timer_queue_->calculate_timeout (max_wait_time,
01089                                                         &timer_buf);
01090 
01091   // Check if we have timers to fire.
01092   const int timers_pending =
01093     ((this_timeout != 0 && max_wait_time == 0)
01094      || (this_timeout != 0 && max_wait_time != 0
01095          && *this_timeout != *max_wait_time) ? 1 : 0);
01096 
01097   const long timeout =
01098     (this_timeout == 0
01099      ? -1 /* Infinity */
01100      : static_cast<long> (this_timeout->msec ()));
01101 
01102 #if defined (ACE_HAS_EVENT_POLL)
01103 
01104    // Wait for events.
01105    const int nfds = ::epoll_wait (this->poll_fd_,
01106                                   this->events_,
01107                                   this->size_,
01108                                   static_cast<int> (timeout));
01109 
01110   if (nfds > 0)
01111     {
01112       this->start_pevents_ = this->events_;
01113       this->end_pevents_ = this->start_pevents_ + nfds;
01114     }
01115 
01116 #else
01117 
01118   struct dvpoll dvp;
01119 
01120   dvp.dp_fds = this->dp_fds_;
01121   dvp.dp_nfds = this->size_;
01122   dvp.dp_timeout = timeout;  // Milliseconds
01123 
01124   // Poll for events
01125   const int nfds = ACE_OS::ioctl (this->poll_fd_, DP_POLL, &dvp);
01126 
01127   // Retrieve the results from the pollfd array.
01128   this->start_pfds_ = dvp.dp_fds;
01129 
01130   // If nfds == 0 then end_pfds_ == start_pfds_ meaning that there is
01131   // no work pending.  If nfds > 0 then there is work pending.
01132   // Otherwise an error occurred.
01133   if (nfds > -1)
01134     this->end_pfds_ = this->start_pfds_ + nfds;
01135 #endif  /* ACE_HAS_EVENT_POLL */
01136 
01137   // If timers are pending, override any timeout from the poll.
01138   return (nfds == 0 && timers_pending != 0 ? 1 : nfds);
01139 }


Member Data Documentation

ACE_Dev_Poll_Reactor::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Reactor_Impl.

Definition at line 986 of file Dev_Poll_Reactor.h.

sig_atomic_t ACE_Dev_Poll_Reactor::deactivated_ [protected]
 

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

Definition at line 1118 of file Dev_Poll_Reactor.h.

Referenced by deactivate(), deactivated(), handle_events(), and work_pending_i().

int ACE_Dev_Poll_Reactor::delete_notify_handler_ [protected]
 

Keeps track of whether we need to delete the notify handler (if we didn't create it, then we don't delete it).

Definition at line 1149 of file Dev_Poll_Reactor.h.

Referenced by close(), and open().

int ACE_Dev_Poll_Reactor::delete_signal_handler_ [protected]
 

Keeps track of whether we should delete the signal handler (if we didn't create it, then we don't delete it).

Definition at line 1141 of file Dev_Poll_Reactor.h.

Referenced by close(), open(), and set_sig_handler().

int ACE_Dev_Poll_Reactor::delete_timer_queue_ [protected]
 

Keeps track of whether we should delete the timer queue (if we didn't create it, then we don't delete it).

Definition at line 1134 of file Dev_Poll_Reactor.h.

Referenced by close(), open(), and timer_queue().

struct epoll_event* ACE_Dev_Poll_Reactor::end_pevents_ [protected]
 

The last element in the event array plus one.

The loop that dispatches IO events stops when this->start_pevents_ == this->end_pevents_.

Definition at line 1097 of file Dev_Poll_Reactor.h.

Referenced by close(), dispatch_io_event(), and work_pending_i().

struct epoll_event* ACE_Dev_Poll_Reactor::events_ [protected]
 

Table of event structures to be filled by epoll_wait:.

Track HANDLES we are interested in for various events that must be dispatched *without* polling. ACE_Dev_Poll_Ready_Set ready_set_;

Definition at line 1086 of file Dev_Poll_Reactor.h.

Referenced by close(), and work_pending_i().

ACE_Dev_Poll_Reactor_Handler_Repository ACE_Dev_Poll_Reactor::handler_rep_ [protected]
 

The repository that contains all registered event handlers.

Definition at line 1127 of file Dev_Poll_Reactor.h.

Referenced by close(), dispatch_io_event(), find_handler(), handler(), mask_ops_i(), open(), register_handler_i(), remove_handler_i(), resume_handler_i(), resume_handlers(), suspend_handler_i(), and suspend_handlers().

bool ACE_Dev_Poll_Reactor::initialized_ [protected]
 

Has the reactor been initialized.

Definition at line 1066 of file Dev_Poll_Reactor.h.

Referenced by close(), initialized(), and open().

ACE_Lock_Adapter<ACE_Dev_Poll_Reactor_Token> ACE_Dev_Poll_Reactor::lock_adapter_ [protected]
 

Adapter used to return internal lock to outside world.

Definition at line 1124 of file Dev_Poll_Reactor.h.

Referenced by lock().

int ACE_Dev_Poll_Reactor::mask_signals_ [protected]
 

If 0 then the Reactor will not mask the signals during the event dispatching. This is useful for applications that do not register any signal handlers and want to reduce the overhead introduce by the kernel level locks required to change the mask.

Definition at line 1159 of file Dev_Poll_Reactor.h.

ACE_Reactor_Notify* ACE_Dev_Poll_Reactor::notify_handler_ [protected]
 

Callback object that unblocks the if it's sleeping.

Definition at line 1145 of file Dev_Poll_Reactor.h.

Referenced by close(), max_notify_iterations(), notify(), open(), and purge_pending_notifications().

ACE_HANDLE ACE_Dev_Poll_Reactor::poll_fd_ [protected]
 

All interactions with the `/dev/poll' or `/dev/epoll' device are done through this file descriptor.

Definition at line 1074 of file Dev_Poll_Reactor.h.

Referenced by close(), mask_ops_i(), open(), register_handler_i(), resume_handler_i(), suspend_handler_i(), and work_pending_i().

int ACE_Dev_Poll_Reactor::restart_ [protected]
 

Restart the handle_events event loop method automatically when polling function in use (ioctl() in this case) is interrupted via an EINTR signal.

Definition at line 1164 of file Dev_Poll_Reactor.h.

ACE_Sig_Handler* ACE_Dev_Poll_Reactor::signal_handler_ [protected]
 

Handle signals without requiring global/static variables.

Definition at line 1137 of file Dev_Poll_Reactor.h.

Referenced by close(), handler(), open(), register_handler(), remove_handler(), and set_sig_handler().

size_t ACE_Dev_Poll_Reactor::size_ [protected]
 

The maximum number of file descriptors over which demultiplexing will occur.

Definition at line 1078 of file Dev_Poll_Reactor.h.

struct epoll_event* ACE_Dev_Poll_Reactor::start_pevents_ [protected]
 

Pointer to the next epoll_event array element that contains the next event to be dispatched.

Definition at line 1090 of file Dev_Poll_Reactor.h.

Referenced by close(), dispatch_io_event(), and work_pending_i().

ACE_Timer_Queue* ACE_Dev_Poll_Reactor::timer_queue_ [protected]
 

Defined as a pointer to allow overriding by derived classes...

Definition at line 1130 of file Dev_Poll_Reactor.h.

Referenced by cancel_timer(), close(), dispatch_timer_handler(), open(), reset_timer_interval(), schedule_timer(), timer_queue(), and work_pending_i().

ACE_Dev_Poll_Reactor_Token ACE_Dev_Poll_Reactor::token_ [protected]
 

Lock used for synchronization of reactor state.

Definition at line 1121 of file Dev_Poll_Reactor.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:21:30 2006 for ACE by doxygen 1.3.6