Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 Methods

 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)
 Initialize ACE_Dev_Poll_Reactor with the default size. More...

 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)
 Initialize ACE_Dev_Poll_Reactor with size "size.". More...

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

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

virtual int current_info (ACE_HANDLE, size_t &)
virtual int set_sig_handler (ACE_Sig_Handler *signal_handler)
 Use a user specified signal handler instead. More...

virtual int set_timer_queue (ACE_Timer_Queue *tq)
 Set a user specified timer queue. More...

virtual int timer_queue (ACE_Timer_Queue *tq)
 Set a user-specified timer queue. More...

virtual ACE_Timer_Queuetimer_queue (void) const
 Return the current ACE_Timer_Queue. More...

virtual int close (void)
 Close down and release all resources. More...

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)
 Register event_handler with mask. The I/O handle will always come from get_handle on the event_handler. More...

virtual int register_handler (ACE_HANDLE io_handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask)
 Register event_handler with mask. The I/O handle is provided through the io_handle parameter. More...

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)
 Register <event_handler> with all the <handles> in the <Handle_Set>. More...

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)
 Registers <new_sh> to handle a set of signals <sigset> using the <new_disp>. More...

virtual int remove_handler (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask)
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 <remove_handler> for every signal in <sigset>. More...

virtual int suspend_handler (ACE_Event_Handler *event_handler)
 Suspend event_handler temporarily. Use ACE_Event_Handler::get_handle() to get the handle. More...

virtual int suspend_handler (ACE_HANDLE handle)
 Suspend handle temporarily. More...

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

virtual int suspend_handlers (void)
 Suspend all handles temporarily. More...

virtual int resume_handler (ACE_Event_Handler *event_handler)
 Resume event_handler. Use ACE_Event_Handler::get_handle() to get the handle. More...

virtual int resume_handler (ACE_HANDLE handle)
 Resume handle. More...

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

virtual int resume_handlers (void)
 Resume all handles. More...

virtual int resumable_handler (void)
 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. More...

virtual int uses_event_associations (void)
 Return 1 if we any event associations were made by the reactor for the handles that it waits on, 0 otherwise. More...

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)
 Cancel all Event_Handlers that match the address of <event_handler>. Returns number of handlers cancelled. More...

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)
 Add <masks_to_be_added> to the <event_handler>'s entry. <event_handler> must already have been registered. More...

virtual int schedule_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask masks_to_be_added)
 Add <masks_to_be_added> to the <handle>'s entry. <event_handler> associated with <handle> must already have been registered. More...

virtual int cancel_wakeup (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks_to_be_cleared)
 Clear <masks_to_be_cleared> from the <event_handler>'s entry. More...

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

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 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)
 Returns true if Reactor has been successfully initialized, else false. More...

virtual size_t size (void) const
 Returns the current size of the Reactor's internal descriptor table. More...

virtual ACE_Locklock (void)
 Returns a reference to the Reactor's internal lock. More...

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

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

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

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

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

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

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

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

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)
 GET/SET/ADD/CLR the dispatch mask "bit" bound with the event_handler and mask. More...

virtual int mask_ops (ACE_HANDLE handle, ACE_Reactor_Mask mask, int ops)
 GET/SET/ADD/CLR the dispatch MASK "bit" bound with the handle and mask. More...

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)
 GET/SET/ADD/CLR the ready "bit" bound with the event_handler and mask. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Methods

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

int handle_events_i (ACE_Time_Value *max_wait_time)
 Poll for events and return the number of event handlers that were dispatched. More...

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

int dispatch (void)
int dispatch_timer_handlers (int &number_of_handlers_dispatched)
int dispatch_io_events (int &io_handlers_dispatched)
 Dispatch all IO related events to their corresponding event handlers. More...

int register_handler_i (ACE_HANDLE handle, ACE_Event_Handler *eh, ACE_Reactor_Mask mask)
 Register the given event handler with the reactor. More...

int remove_handler_i (ACE_HANDLE handle, ACE_Reactor_Mask mask)
 Remove the event handler associated with the given handle and event mask from the "interest set.". More...

int suspend_handler_i (ACE_HANDLE handle)
 Temporarily remove the given handle from the "interest set.". More...

int resume_handler_i (ACE_HANDLE handle)
 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. More...

int mask_ops_i (ACE_HANDLE handle, ACE_Reactor_Mask mask, int ops)
 GET/SET/ADD/CLR the dispatch MASK "bit" bound with the handle and mask. This internal helper method acquires no lock. More...

short reactor_mask_to_poll_event (ACE_Reactor_Mask mask)
 Convert a reactor mask to its corresponding poll() event mask. More...


Protected Attributes

char initialized_
 Has the reactor been initialized. More...

ACE_HANDLE poll_fd_
 The file descriptor associated with the open `/dev/poll' or `/dev/epoll' device. More...

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

char * mmap_
 Track HANDLES we are interested in for various events that must be dispatched *without* polling. ACE_Dev_Poll_Ready_Set ready_set_; The memory map that `/dev/epoll' will feed its results to. More...

pollfd * start_pfds_
 Pointer to the next pollfd array element that contains the next event to be dispatched. More...

pollfd * end_pfds_
 The last element in the pollfd array plus one. More...

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

ACE_SYNCH_MUTEX lock_
 Lock used for synchronization of reactor state. More...

ACE_Lock_Adapter< ACE_SYNCH_MUTEX > lock_adapter_
 Adapter used to return internal lock to outside world. More...

ACE_Dev_Poll_Reactor_Handler_Repository handler_rep_
 The repository that contains all registered event handlers. More...

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

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

ACE_Sig_Handlersignal_handler_
 Handle signals without requiring global/static variables. More...

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

ACE_Reactor_Notifynotify_handler_
 Callback object that unblocks the <ACE_Select_Reactor> if it's sleeping. More...

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

int mask_signals_
 Flag that determines if signals are masked during event dispatching. More...

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


Detailed Description

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

Note:
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.
Note:
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 468 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
 

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

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, ACE::max_handles, and open.

00746   : initialized_ (0)
00747   , poll_fd_ (ACE_INVALID_HANDLE)
00748   , size_ (0)
00749   // , ready_set_ ()
00750 #if defined (ACE_HAS_EVENT_POLL)
00751   , mmap_ (0)
00752 #else
00753   , dp_fds_ (0)
00754 #endif  /* ACE_HAS_EVENT_POLL */
00755   , start_pfds_ (0)
00756   , end_pfds_ (0)
00757   , deactivated_ (0)
00758   , lock_ ()
00759   , lock_adapter_ (lock_)
00760   , timer_queue_ (0)
00761   , delete_timer_queue_ (0)
00762   , signal_handler_ (0)
00763   , delete_signal_handler_ (0)
00764   , notify_handler_ (0)
00765   , delete_notify_handler_ (0)
00766   , mask_signals_ (mask_signals)
00767   , restart_ (0)
00768 {
00769   ACE_TRACE ("ACE_Dev_Poll_Reactor::ACE_Dev_Poll_Reactor");
00770 
00771   if (this->open (ACE::max_handles (),
00772                   0,
00773                   sh,
00774                   tq,
00775                   disable_notify_pipe,
00776                   notify) == -1)
00777     ACE_ERROR ((LM_ERROR,
00778                 ACE_LIB_TEXT ("%p\n"),
00779                 ACE_LIB_TEXT ("ACE_Dev_Poll_Reactor::open ")
00780                 ACE_LIB_TEXT ("failed inside ")
00781                 ACE_LIB_TEXT ("ACE_Dev_Poll_Reactor::CTOR")));
00782 }

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
 

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, then the process maximum will be decreased in order to prevent potential access violations.

Definition at line 784 of file Dev_Poll_Reactor.cpp.

References ACE_ERROR, ACE_LIB_TEXT, LM_ERROR, open, and size.

00791   : initialized_ (0)
00792   , poll_fd_ (ACE_INVALID_HANDLE)
00793   , size_ (0)
00794   // , ready_set_ ()
00795 #if defined (ACE_HAS_EVENT_POLL)
00796   , mmap_ (0)
00797 #else
00798   , dp_fds_ (0)
00799 #endif  /* ACE_HAS_EVENT_POLL */
00800   , start_pfds_ (0)
00801   , end_pfds_ (0)
00802   , deactivated_ (0)
00803   , lock_ ()
00804   , lock_adapter_ (lock_)
00805   , timer_queue_ (0)
00806   , delete_timer_queue_ (0)
00807   , signal_handler_ (0)
00808   , delete_signal_handler_ (0)
00809   , notify_handler_ (0)
00810   , delete_notify_handler_ (0)
00811   , mask_signals_ (mask_signals)
00812   , restart_ (0)
00813 {
00814   if (this->open (size,
00815                   rs,
00816                   sh,
00817                   tq,
00818                   disable_notify_pipe,
00819                   notify) == -1)
00820     ACE_ERROR ((LM_ERROR,
00821                 ACE_LIB_TEXT ("%p\n"),
00822                 ACE_LIB_TEXT ("ACE_Dev_Poll_Reactor::open ")
00823                 ACE_LIB_TEXT ("failed inside ACE_Dev_Poll_Reactor::CTOR")));
00824 }

ACE_Dev_Poll_Reactor::~ACE_Dev_Poll_Reactor void    [virtual]
 

Close down and release all resources.

Definition at line 826 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and close.

00827 {
00828   ACE_TRACE ("ACE_Dev_Poll_Reactor::~ACE_Dev_Poll_Reactor");
00829 
00830   (void) this->close ();
00831 }


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

References ACE_TRACE, and handle_events.

01464 {
01465   ACE_TRACE ("ACE_Dev_Poll_Reactor::alertable_handle_events");
01466 
01467   return this->handle_events (max_wait_time);
01468 }

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

Implements ACE_Reactor_Impl.

Definition at line 1447 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, and handle_events.

01448 {
01449   ACE_TRACE ("ACE_Dev_Poll_Reactor::alertable_handle_events");
01450 
01451   return this->handle_events (max_wait_time);
01452 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Timer_Queue_T< ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall< ACE_SYNCH_RECURSIVE_MUTEX >, ACE_SYNCH_RECURSIVE_MUTEX >::cancel, and timer_queue_.

01992 {
01993   ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_timer");
01994 
01995   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01996 
01997   return (this->timer_queue_ == 0
01998           ? 0
01999           : this->timer_queue_->cancel (timer_id,
02000                                         arg,
02001                                         dont_call_handle_close));
02002 }

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 <event_handler>. Returns number of handlers cancelled.

Implements ACE_Reactor_Impl.

Definition at line 1975 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Timer_Queue_T< ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall< ACE_SYNCH_RECURSIVE_MUTEX >, ACE_SYNCH_RECURSIVE_MUTEX >::cancel, and timer_queue_.

01977 {
01978   ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_timer");
01979 
01980   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01981 
01982   return (this->timer_queue_ == 0
01983           ? 0
01984           : this->timer_queue_->cancel (event_handler,
01985                                         dont_call_handle_close));
01986 }

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

Clear <masks_to_be_cleared> from the <handle>'s entry.

Implements ACE_Reactor_Impl.

Definition at line 2032 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, ACE_Reactor::CLR_MASK, and mask_ops.

02034 {
02035   ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_wakeup");
02036 
02037   return this->mask_ops (handle, mask, ACE_Reactor::CLR_MASK);
02038 }

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

Clear <masks_to_be_cleared> from the <event_handler>'s entry.

Implements ACE_Reactor_Impl.

Definition at line 2023 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, ACE_Reactor::CLR_MASK, ACE_Event_Handler::get_handle, and mask_ops.

02025 {
02026   ACE_TRACE ("ACE_Dev_Poll_Reactor::cancel_wakeup");
02027 
02028   return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::CLR_MASK);
02029 }

int ACE_Dev_Poll_Reactor::close void    [virtual]
 

Close down and release all resources.

Implements ACE_Reactor_Impl.

Definition at line 1007 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, 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_pfds_, handler_rep_, initialized_, ACE_OS::ioctl, mmap_, ACE_OS::munmap, notify_handler_, poll_fd_, signal_handler_, start_pfds_, and timer_queue_.

Referenced by open, and ~ACE_Dev_Poll_Reactor.

01008 {
01009   ACE_TRACE ("ACE_Dev_Poll_Reactor::close");
01010 
01011   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01012 
01013   int result = 0;
01014 
01015 #if defined (ACE_HAS_EVENT_POLL)
01016   if (this->mmap_ != 0)
01017     {
01018       (void) ACE_OS::munmap (this->mmap_, EP_MAP_SIZE (this->size_));
01019       this->mmap_ = 0;
01020     }
01021 #else
01022   delete [] this->dp_fds_;
01023   this->dp_fds_ = 0;
01024 #endif  /* ACE_HAS_EVENT_POLL */
01025 
01026   if (this->poll_fd_ != ACE_INVALID_HANDLE)
01027     {
01028 #if defined (ACE_HAS_EVENT_POLL)
01029       (void) ACE_OS::ioctl (this->poll_fd_, EP_FREE, 0);
01030 #endif  /* ACE_HAS_EVENT_POLL */
01031       result = ACE_OS::close (this->poll_fd_);
01032     }
01033 
01034   if (this->delete_signal_handler_)
01035     {
01036       delete this->signal_handler_;
01037       this->signal_handler_ = 0;
01038       this->delete_signal_handler_ = 0;
01039     }
01040 
01041   (void) this->handler_rep_.close ();
01042 
01043   if (this->delete_timer_queue_)
01044     {
01045       delete this->timer_queue_;
01046       this->timer_queue_ = 0;
01047       this->delete_timer_queue_ = 0;
01048     }
01049 
01050   if (this->notify_handler_ != 0)
01051     this->notify_handler_->close ();
01052 
01053   if (this->delete_notify_handler_)
01054     {
01055       delete this->notify_handler_;
01056       this->notify_handler_ = 0;
01057       this->delete_notify_handler_ = 0;
01058     }
01059 
01060   this->poll_fd_ = ACE_INVALID_HANDLE;
01061   this->start_pfds_ = 0;
01062   this->end_pfds_ = 0;
01063   this->initialized_ = 0;
01064 
01065   return result;
01066 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 961 of file Dev_Poll_Reactor.cpp.

00962 {
00963   ACE_NOTSUP_RETURN (-1);
00964 }

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

References deactivated_, and wakeup_all_threads.

01478 {
01479   this->deactivated_ = do_stop;
01480   this->wakeup_all_threads ();
01481 }

int ACE_Dev_Poll_Reactor::deactivated void    [virtual]
 

Return 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 1471 of file Dev_Poll_Reactor.cpp.

References deactivated_.

01472 {
01473   return this->deactivated_;
01474 }

int ACE_Dev_Poll_Reactor::dispatch void    [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 1208 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, dispatch_io_events, dispatch_timer_handlers, and ACE_Sig_Handler::sig_pending.

Referenced by handle_events_i.

01209 {
01210   ACE_TRACE ("ACE_Dev_Poll_Reactor::dispatch");
01211 
01212   int io_handlers_dispatched = 0;
01213   int other_handlers_dispatched = 0;
01214   int signal_occurred = 0;
01215 
01216   // The following do/while loop keeps dispatching as long as there
01217   // are still active handles.  Note that the only way we should ever
01218   // iterate more than once through this loop is if signals occur
01219   // while we're dispatching other handlers.
01220 
01221   do
01222     {
01223       // Note that we keep track of changes to our state.  If any of
01224       // the dispatch_*() methods below return -1 it means that the
01225       // "interest set" state has changed as the result of an
01226       // ACE_Event_Handler being dispatched.  This means that we
01227       // need to bail out and rerun the poll loop since our existing
01228       // notion of handles in dispatch set may no longer be correct.
01229       //
01230       // In the beginning, our state starts out unchanged.  After
01231       // every iteration (i.e., due to signals), our state starts out
01232       // unchanged again.
01233 
01234       // this->state_changed_ = 0;
01235 
01236       // Perform the Template Method for dispatching all the handlers.
01237 
01238       // First check for interrupts.
01239       if (0 /* active_handle_count == -1 */)
01240         {
01241           // Bail out -- we got here since the poll (i.e. ioctl()) was
01242           // interrupted.
01243           if (ACE_Sig_Handler::sig_pending () != 0)
01244             {
01245               ACE_Sig_Handler::sig_pending (0);
01246 
01247 #if 0
01248               // If any HANDLES in the <ready_set_> are activated as a
01249               // result of signals they should be dispatched since
01250               // they may be time critical...
01251               pfds = this->ready_set_.pfds;
01252               active_handle_count = this->ready_set_.nfds;
01253 #endif  /* 0 */
01254 
01255               // Record the fact that the Reactor has dispatched a
01256               // handle_signal() method.  We need this to return the
01257               // appropriate count below.
01258               signal_occurred = 1;
01259             }
01260           else
01261             return -1;
01262         }
01263 
01264       // Handle timers early since they may have higher latency
01265       // constraints than I/O handlers.  Ideally, the order of
01266       // dispatching should be a strategy...
01267       else if (this->dispatch_timer_handlers (other_handlers_dispatched) == -1)
01268         // State has changed or timer queue has failed, exit loop.
01269         break;
01270 
01271       // Check to see if there are no more I/O handles left to
01272       // dispatch AFTER we've handled the timers.
01273       else if (0 /* active_handle_count == 0 */)
01274         return io_handlers_dispatched
01275           + other_handlers_dispatched
01276           + signal_occurred;
01277 
01278 #if 0
01279       // Next dispatch the notification handlers (if there are any to
01280       // dispatch).  These are required to handle multiple threads
01281       // that are trying to update the Reactor.
01282       else if (this->dispatch_notification_handlers (
01283                  dispatch_set,
01284                  active_handle_count,
01285                  other_handlers_dispatched) == -1)
01286         // State has changed or a serious failure has occured, so exit
01287         // loop.
01288         break;
01289 #endif  /* 0 */
01290 
01291       // Finally, dispatch the I/O handlers.
01292       else if (this->dispatch_io_events (io_handlers_dispatched) == -1)
01293         // State has changed, so exit loop.
01294         break;
01295     }
01296   while (0 /* active_handle_count > 0 */);
01297 
01298   return io_handlers_dispatched + other_handlers_dispatched + signal_occurred;
01299 }

int ACE_Dev_Poll_Reactor::dispatch_io_events int &    io_handlers_dispatched [protected]
 

Dispatch all IO related events to their corresponding event handlers.

Definition at line 1345 of file Dev_Poll_Reactor.cpp.

References ACE_BIT_ENABLED, ACE_GUARD_RETURN, end_pfds_, ACE_Event_Handler::EXCEPT_MASK, ACE_Dev_Poll_Reactor_Handler_Repository::find, ACE_Event_Handler::handle_exception, ACE_Event_Handler::handle_input, ACE_Event_Handler::handle_output, handler_rep_, ACE_Event_Handler::READ_MASK, remove_handler, start_pfds_, upcall, and ACE_Event_Handler::WRITE_MASK.

Referenced by dispatch.

01346 {
01347   // Since the underlying event demultiplexing mechansim (`/dev/poll'
01348   // or '/dev/epoll') is stateful, and since only one result buffer is
01349   // used, all pending events (i.e. those retrieved from a previous
01350   // poll) must be dispatched before any additional event can be
01351   // polled.  As such, the Dev_Poll_Reactor keeps track of the
01352   // progress of events that have been dispatched.
01353 
01354   // Dispatch the events.
01355   //
01356   // The semantics of this loop in the presence of multiple threads is
01357   // non-trivial.  this->start_pfds_ will be incremented each time an
01358   // event handler is dispatched, which may be done across multiple
01359   // threads.  Multiple threads may change the loop variables.  Care
01360   // must be taken to only change those variables with the reactor
01361   // lock held.
01362   //
01363   // Notice that pfds only contains file descriptors that have
01364   // received events.
01365   for (struct pollfd *& pfds = this->start_pfds_;
01366        pfds < this->end_pfds_;
01367        /* Nothing to do before next loop iteration */)
01368     {
01369       const ACE_HANDLE handle = pfds->fd;
01370       const short revents     = pfds->revents;
01371 
01372       // Increment the pointer to the next pollfd element before we
01373       // release the lock.  Otherwise event handlers end up being
01374       // dispatched multiple times for the same poll.
01375       ++pfds;
01376 
01377       ACE_Event_Handler *eh = this->handler_rep_.find (handle);
01378 
01379       {
01380         // Modify the reference count in an exception-safe way.
01381         ACE_Dev_Poll_Handler_Guard (this->handler_rep_, handle);
01382 
01383         // Release the lock during the upcall.
01384         ACE_Reverse_Lock<ACE_SYNCH_MUTEX> reverse_lock (this->lock_);
01385         ACE_GUARD_RETURN (ACE_Reverse_Lock<ACE_SYNCH_MUTEX>,
01386                           reverse_guard,
01387                           reverse_lock,
01388                           -1);
01389 
01390         // Dispatch all output events.
01391         if (ACE_BIT_ENABLED (revents, POLLOUT))
01392           {
01393             int status =
01394               this->upcall (eh, &ACE_Event_Handler::handle_output, handle);
01395 
01396             if (status < 0)
01397               {
01398                 // Note that the lock is reacquired in
01399                 // remove_handler().
01400                 return this->remove_handler (handle,
01401                                              ACE_Event_Handler::WRITE_MASK);
01402               }
01403 
01404             io_handlers_dispatched++;
01405           }
01406 
01407         // Dispatch all "high priority" (e.g. out-of-band data) events.
01408         if (ACE_BIT_ENABLED (revents, POLLPRI))
01409           {
01410             int status =
01411               this->upcall (eh, &ACE_Event_Handler::handle_exception, handle);
01412 
01413             if (status < 0)
01414               {
01415                 // Note that the lock is reacquired in
01416                 // remove_handler().
01417                 return this->remove_handler (handle,
01418                                              ACE_Event_Handler::EXCEPT_MASK);
01419               }
01420 
01421             io_handlers_dispatched++;
01422           }
01423 
01424         // Dispatch all input events.
01425         if (ACE_BIT_ENABLED (revents, POLLIN))
01426           {
01427             int status =
01428               this->upcall (eh, &ACE_Event_Handler::handle_input, handle);
01429 
01430             if (status < 0)
01431               {
01432                 // Note that the lock is reacquired in
01433                 // remove_handler().
01434                 return this->remove_handler (handle,
01435                                              ACE_Event_Handler::READ_MASK);
01436               }
01437 
01438             io_handlers_dispatched++;
01439           }
01440       } // The reactor lock is reacquired upon leaving this scope.
01441     }
01442 
01443   return 0;
01444 }

int ACE_Dev_Poll_Reactor::dispatch_timer_handlers int &    number_of_handlers_dispatched [protected]
 

Definition at line 1302 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_Timer_Queue_T< ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall< ACE_SYNCH_RECURSIVE_MUTEX >, ACE_SYNCH_RECURSIVE_MUTEX >::expire, and timer_queue_.

Referenced by dispatch.

01304 {
01305   // Release the lock during the upcall.
01306   ACE_Reverse_Lock<ACE_SYNCH_MUTEX> reverse_lock (this->lock_);
01307   ACE_GUARD_RETURN (ACE_Reverse_Lock<ACE_SYNCH_MUTEX>,
01308                     reverse_guard,
01309                     reverse_lock,
01310                     -1);
01311 
01312   number_of_timers_cancelled += this->timer_queue_->expire ();
01313 
01314   return 0;
01315 }

void ACE_Dev_Poll_Reactor::dump void    const [virtual]
 

Dump the state of an object.

Implements ACE_Reactor_Impl.

Definition at line 2367 of file Dev_Poll_Reactor.cpp.

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

02368 {
02369   ACE_TRACE ("ACE_Dev_Poll_Reactor::dump");
02370 
02371   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
02372   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("restart_ = %d\n"), this->restart_));
02373   ACE_DEBUG ((LM_DEBUG,
02374               ACE_LIB_TEXT ("initialized_ = %d"),
02375               this->initialized_));
02376   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("poll_fd_ = %d"), this->poll_fd_));
02377   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("size_ = %u"), this->size_));
02378   ACE_DEBUG ((LM_DEBUG,
02379               ACE_LIB_TEXT ("deactivated_ = %d"),
02380               this->deactivated_));
02381   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
02382 }

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

References ACE_TRACE, and handle_events.

01456 {
01457   ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events");
01458 
01459   return this->handle_events (&max_wait_time);
01460 }

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.

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.

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.

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

Implements ACE_Reactor_Impl.

Definition at line 1158 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, deactivated_, and handle_events_i.

Referenced by alertable_handle_events, and handle_events.

01159 {
01160   ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events");
01161 
01162   // Stash the current time
01163   //
01164   // The destructor of this object will automatically compute how much
01165   // time elapsed since this method was called.
01166   ACE_MT (ACE_Countdown_Time countdown (max_wait_time));
01167 
01168   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01169 
01170   if (this->deactivated_)
01171     return -1;
01172 
01173   // Update the countdown to reflect time waiting for the mutex.
01174   ACE_MT (countdown.update ());
01175 
01176   return this->handle_events_i (max_wait_time);
01177 }

int ACE_Dev_Poll_Reactor::handle_events_i ACE_Time_Value   max_wait_time [protected]
 

Poll for events and return the number of event handlers that were dispatched.

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

Definition at line 1180 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, dispatch, ETIME, restart_, and work_pending_i.

Referenced by handle_events.

01181 {
01182   ACE_TRACE ("ACE_Dev_Poll_Reactor::handle_events_i");
01183 
01184   int result = 0;
01185   // int active_handle_count = 0;
01186 
01187   // Poll for events
01188   //
01189   // If the underlying ioctl() call was interrupted via the interrupt
01190   // signal (i.e. returned -1 with errno == EINTR) then the loop will
01191   // be restarted if so desired.
01192   do
01193     {
01194       result = this->work_pending_i (max_wait_time);
01195     }
01196   while (result == -1 && this->restart_ != 0 && errno == EINTR);
01197 
01198   if (result == 0 || (result == -1 && errno == ETIME))
01199     return 0;
01200   else if (result == -1)
01201     return -1;
01202 
01203   // Dispatch the events, if any.
01204   return this->dispatch ();
01205 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 2114 of file Dev_Poll_Reactor.cpp.

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

02116 {
02117   ACE_TRACE ("ACE_Dev_Poll_Reactor::handler");
02118 
02119   ACE_Event_Handler *handler = this->signal_handler_->handler (signum);
02120 
02121   if (handler == 0)
02122     return -1;
02123   else if (eh != 0)
02124     *eh = handler;
02125 
02126   return 0;
02127 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 2089 of file Dev_Poll_Reactor.cpp.

References ACE_BIT_CMP_MASK, ACE_GUARD_RETURN, ACE_MT, ACE_Reactor_Mask, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Dev_Poll_Reactor_Handler_Repository::find, and handler_rep_.

Referenced by handler.

02092 {
02093   ACE_TRACE ("ACE_Dev_Poll_Reactor::handler");
02094 
02095   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02096 
02097   ACE_Event_Handler *h = this->handler_rep_.find (handle);
02098 
02099   if (h != 0
02100       && ACE_BIT_CMP_MASK (this->handler_rep_.mask (handle),
02101                            mask,  // Compare all bits in the mask
02102                            mask))
02103     {
02104       if (event_handler != 0)
02105         *event_handler = h;
02106 
02107       return 0;
02108     }
02109 
02110   return -1;
02111 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, and initialized_.

02131 {
02132   ACE_TRACE ("ACE_Dev_Poll_Reactor::initialized");
02133 
02134   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02135 
02136   return this->initialized_;
02137 }

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

References ACE_TRACE, and lock_adapter_.

02147 {
02148   ACE_TRACE ("ACE_Dev_Poll_Reactor::lock");
02149 
02150   return this->lock_adapter_;
02151 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 2239 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_Reactor_Mask, ACE_SYNCH_MUTEX, ACE_TRACE, and mask_ops_i.

02242 {
02243   ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops");
02244 
02245   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02246 
02247   return this->mask_ops_i (handle, mask, ops);
02248 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 2227 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_Reactor_Mask, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Event_Handler::get_handle, and mask_ops_i.

Referenced by cancel_wakeup, and schedule_wakeup.

02230 {
02231   ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops");
02232 
02233   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02234 
02235   return this->mask_ops_i (event_handler->get_handle (), mask, ops);
02236 }

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

GET/SET/ADD/CLR the dispatch MASK "bit" bound with the handle and mask. This internal helper method acquires no lock.

Definition at line 2251 of file Dev_Poll_Reactor.cpp.

References ACE_CLR_BITS, ACE_Reactor_Mask, ACE_SET_BITS, ACE_TRACE, ACE_Reactor::ADD_MASK, ACE_Reactor::CLR_MASK, ACE_Reactor::GET_MASK, ACE_Dev_Poll_Reactor_Handler_Repository::handle_in_range, handler_rep_, ACE_Dev_Poll_Reactor_Handler_Repository::mask, reactor_mask_to_poll_event, ACE_Reactor::SET_MASK, ACE_Dev_Poll_Reactor_Handler_Repository::suspended, and ACE_OS::write.

Referenced by mask_ops, and remove_handler_i.

02254 {
02255   ACE_TRACE ("ACE_Dev_Poll_Reactor::mask_ops_i");
02256 
02257   if (this->handler_rep_.handle_in_range (handle) == 0)
02258     return -1;
02259 
02260   // Block out all signals until method returns.
02261   ACE_Sig_Guard sb;
02262 
02263   ACE_Reactor_Mask old_mask = this->handler_rep_.mask (handle);
02264   ACE_Reactor_Mask new_mask = old_mask;
02265 
02266   // Perform GET, CLR, SET, and ADD operations on the interest/wait
02267   // set and the suspend set (if necessary).
02268   //
02269   // GET = 1, Retrieve current value
02270   // SET = 2, Set value of bits to new mask (changes the entire mask)
02271   // ADD = 3, Bitwise "or" the value into the mask (only changes
02272   //          enabled bits)
02273   // CLR = 4  Bitwise "and" the negation of the value out of the mask
02274   //          (only changes enabled bits)
02275   //
02276   // Returns the original mask.
02277 
02278   switch (ops)
02279     {
02280     case ACE_Reactor::GET_MASK:
02281       // The work for this operation is done in all cases at the
02282       // begining of the function.
02283       return old_mask;
02284 
02285     case ACE_Reactor::CLR_MASK:
02286       ACE_CLR_BITS (new_mask, mask);
02287       break;
02288 
02289     case ACE_Reactor::SET_MASK:
02290       new_mask = mask;
02291       break;
02292 
02293     case ACE_Reactor::ADD_MASK:
02294       ACE_SET_BITS (new_mask, mask);
02295       break;
02296 
02297     default:
02298       return -1;
02299     }
02300 
02301   /// Reset the mask for the given handle.
02302   this->handler_rep_.mask (handle, new_mask);
02303 
02304   if (this->handler_rep_.suspended (handle) == 0)
02305     {
02306       // Only attempt to alter events for the handle from the
02307       // "interest set" if it hasn't been suspended.
02308 
02309       short events = this->reactor_mask_to_poll_event (new_mask);
02310 
02311 #if defined (sun)
02312       // Apparently events cannot be updated on-the-fly on Solaris so
02313       // remove the existing events, and then add the new ones.
02314       struct pollfd pfd[2];
02315 
02316       pfd[0].fd      = handle;
02317       pfd[0].events  = POLLREMOVE;
02318       pfd[0].revents = 0;
02319       pfd[1].fd      = (events == POLLREMOVE ? ACE_INVALID_HANDLE : handle);
02320       pfd[1].events  = events;
02321       pfd[1].revents = 0;
02322 #else
02323       pollfd pfd[1];
02324 
02325       pfd[0].fd      = handle;
02326       pfd[0].events  = events;
02327       pfd[0].revents = 0;
02328 #endif  /* sun */
02329 
02330       // Change the events associated with the given file descriptor.
02331       if (ACE_OS::write (this->poll_fd_,
02332                          pfd,
02333                          sizeof (pfd)) != sizeof (pfd))
02334         return -1;
02335     }
02336 
02337   return old_mask;
02338 }

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 <ACE_Event_Handlers> 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 2069 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Reactor_Notify::max_notify_iterations, and notify_handler_.

02070 {
02071   ACE_TRACE ("ACE_Dev_Poll_Reactor::max_notify_iterations");
02072 
02073   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02074 
02075   return this->notify_handler_->max_notify_iterations ();
02076 }

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

Implements ACE_Reactor_Impl.

Definition at line 2059 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Reactor_Notify::max_notify_iterations, and notify_handler_.

02060 {
02061   ACE_TRACE ("ACE_Dev_Poll_Reactor::max_notify_iterations");
02062 
02063   ACE_MT (ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->lock_));
02064 
02065   this->notify_handler_->max_notify_iterations (iterations);
02066 }

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 <event_handler> of <mask> event. The <ACE_Time_Value> indicates how long to blocking trying to notify. If <timeout> == 0, the caller will block until action is possible, else will wait until the relative time specified in <timeout> elapses).

Implements ACE_Reactor_Impl.

Definition at line 2041 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.

02044 {
02045   ACE_TRACE ("ACE_Dev_Poll_Reactor::notify");
02046 
02047   ssize_t n = 0;
02048 
02049   // Pass over both the Event_Handler *and* the mask to allow the
02050   // caller to dictate which Event_Handler method the receiver
02051   // invokes.  Note that this call can timeout.
02052 
02053   n = this->notify_handler_->notify (eh, mask, timeout);
02054 
02055   return n == -1 ? -1 : 0;
02056 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_NEW_RETURN, ACE_SYNCH_MUTEX, ACE_TRACE, close, delete_notify_handler_, delete_signal_handler_, delete_timer_queue_, handler_rep_, initialized_, ACE_OS::ioctl, MAP_FAILED, MAP_PRIVATE, ACE_OS::mmap, mmap_, notify_handler_, ACE_Reactor_Notify::open, ACE_Dev_Poll_Reactor_Handler_Repository::open, ACE_OS::open, poll_fd_, PROT_READ, PROT_WRITE, ACE_Event_Handler::READ_MASK, register_handler_i, restart, restart_, signal_handler_, size, size_, and timer_queue_.

Referenced by ACE_Dev_Poll_Reactor.

00840 {
00841   ACE_TRACE ("ACE_Dev_Poll_Reactor::open");
00842 
00843   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
00844 
00845   // Can't initialize ourselves more than once.
00846   if (this->initialized_ > 0)
00847     return -1;
00848 
00849   this->restart_ = restart;
00850   this->signal_handler_ = sh;
00851   this->timer_queue_ = tq;
00852   this->notify_handler_ = notify;
00853 
00854   int result = 0;
00855 
00856   // Allows the signal handler to be overridden.
00857   if (this->signal_handler_ == 0)
00858     {
00859       ACE_NEW_RETURN (this->signal_handler_,
00860                       ACE_Sig_Handler,
00861                       -1);
00862 
00863       if (this->signal_handler_ == 0)
00864         result = -1;
00865       else
00866         this->delete_signal_handler_ = 1;
00867     }
00868 
00869   // Allows the timer queue to be overridden.
00870   if (result != -1 && this->timer_queue_ == 0)
00871     {
00872       ACE_NEW_RETURN (this->timer_queue_,
00873                       ACE_Timer_Heap,
00874                       -1);
00875 
00876       if (this->timer_queue_ == 0)
00877         result = -1;
00878       else
00879         this->delete_timer_queue_ = 1;
00880     }
00881 
00882   // Allows the Notify_Handler to be overridden.
00883   if (result != -1 && this->notify_handler_ == 0)
00884     {
00885       ACE_NEW_RETURN (this->notify_handler_,
00886                       ACE_Dev_Poll_Reactor_Notify,
00887                       -1);
00888 
00889       if (this->notify_handler_ == 0)
00890         result = -1;
00891       else
00892         this->delete_notify_handler_ = 1;
00893     }
00894 
00895 #if defined (ACE_HAS_EVENT_POLL)
00896 
00897   // Open the `/dev/epoll' character device.
00898   this->poll_fd_ = ACE_OS::open ("/dev/epoll", O_RDWR);
00899   if (this->poll_fd_ == ACE_INVALID_HANDLE)
00900     result = -1;
00901 
00902   // Set the maximum number of file descriptors to expect.
00903   if (result != -1
00904       && ACE_OS::ioctl (this->poll_fd_, EP_ALLOC, (void *) size) == 0)
00905     {
00906       // Map an area of memory to which results will be fed.
00907       void *mm = ACE_OS::mmap (0,
00908                                EP_MAP_SIZE (size),
00909                                PROT_READ | PROT_WRITE,
00910                                MAP_PRIVATE,
00911                                this->poll_fd_,
00912                                0);
00913 
00914       if (mm == (void *) MAP_FAILED)
00915         result = -1;
00916       else
00917         this->mmap_ = ACE_static_cast (char *, mm);
00918     }
00919 #else
00920 
00921   // Allocate the array before opening the device to avoid a potential
00922   // resource leak if allocation fails.
00923   ACE_NEW_RETURN (this->dp_fds_,
00924                   pollfd[size],
00925                   -1);
00926 
00927   // Open the `/dev/poll' character device.
00928   this->poll_fd_ = ACE_OS::open ("/dev/poll", O_RDWR);
00929   if (this->poll_fd_ == ACE_INVALID_HANDLE)
00930     result = -1;
00931 
00932 #endif  /* ACE_HAS_EVENT_POLL */
00933 
00934   if (result != -1 && this->handler_rep_.open (size) == -1)
00935     result = -1;
00936 
00937   // Registration of the notification handler must be done after the
00938   // /dev/poll device has been fully initialized.
00939   else if (this->notify_handler_->open (this,
00940                                         0,
00941                                         disable_notify_pipe) == -1
00942            || this->register_handler_i (
00943                        this->notify_handler_->notify_handle (),
00944                        this->notify_handler_,
00945                        ACE_Event_Handler::READ_MASK) == -1)
00946     result = -1;
00947 
00948   this->size_ = size;
00949 
00950   if (result != -1)
00951     // We're all set to go.
00952     this->initialized_ = 1;
00953   else
00954     // This will close down all the allocated resources properly.
00955     (void) this->close ();
00956 
00957   return result;
00958 }

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

References ACE_thread_t, and ACE_TRACE.

02181 {
02182   ACE_TRACE ("ACE_Dev_Poll_Reactor::owner");
02183 
02184   // There is no need to set the owner of the event loop.  Multiple
02185   // threads may invoke the event loop simulataneously.
02186 
02187   return 0;
02188 }

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

References ACE_thread_t, and ACE_TRACE.

02170 {
02171   ACE_TRACE ("ACE_Dev_Poll_Reactor::owner");
02172 
02173   // There is no need to set the owner of the event loop.  Multiple
02174   // threads may invoke the event loop simulataneously.
02175 
02176   return 0;
02177 }

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

References ACE_Reactor_Mask, notify_handler_, and ACE_Reactor_Notify::purge_pending_notifications.

02081 {
02082   if (this->notify_handler_ == 0)
02083     return 0;
02084 
02085   return this->notify_handler_->purge_pending_notifications (eh, mask);
02086 }

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

References ACE_Event_Handler::ACCEPT_MASK, ACE_BIT_ENABLED, ACE_Reactor_Mask, ACE_SET_BITS, ACE_TRACE, ACE_Event_Handler::CONNECT_MASK, ACE_Event_Handler::EXCEPT_MASK, ACE_Event_Handler::NULL_MASK, ACE_Event_Handler::READ_MASK, and ACE_Event_Handler::WRITE_MASK.

Referenced by mask_ops_i, register_handler_i, and resume_handler_i.

02386 {
02387   ACE_TRACE ("ACE_Dev_Poll_Reactor::reactor_mask_to_poll_event");
02388 
02389   if (mask == ACE_Event_Handler::NULL_MASK)
02390     return POLLREMOVE;  // No event.  Remove from interest set.
02391 
02392   short events = 0;
02393 
02394   // READ, ACCEPT, and CONNECT flag will place the handle in the
02395   // read set.
02396   if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::READ_MASK)
02397       || ACE_BIT_ENABLED (mask, ACE_Event_Handler::ACCEPT_MASK)
02398       || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK))
02399     {
02400       ACE_SET_BITS (events, POLLIN);
02401     }
02402 
02403   // WRITE and CONNECT flag will place the handle in the write set.
02404   if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::WRITE_MASK)
02405       || ACE_BIT_ENABLED (mask, ACE_Event_Handler::CONNECT_MASK))
02406     {
02407       ACE_SET_BITS (events, POLLOUT);
02408     }
02409 
02410   // EXCEPT flag will place the handle in the except set.
02411   if (ACE_BIT_ENABLED (mask, ACE_Event_Handler::EXCEPT_MASK))
02412     {
02413       ACE_SET_BITS (events, POLLPRI);
02414     }
02415 
02416   return events;
02417 }

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

References ACE_Reactor_Mask, and ACE_TRACE.

02357 {
02358   ACE_TRACE ("ACE_Dev_Poll_Reactor::ready_ops");
02359 
02360   // Since the Dev_Poll_Reactor uses the poll result buffer, the
02361   // ready_set cannot be directly manipulated outside of the event
02362   // loop.
02363   ACE_NOTSUP_RETURN (-1);
02364 }

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

References ACE_Reactor_Mask, and ACE_TRACE.

02344 {
02345   ACE_TRACE ("ACE_Dev_Poll_Reactor::ready_ops");
02346 
02347   // Since the Dev_Poll_Reactor uses the poll result buffer, the
02348   // ready_set cannot be directly manipulated outside of the event
02349   // loop.
02350   ACE_NOTSUP_RETURN (-1);
02351 }

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 <new_sh> to handle a set of signals <sigset> using the <new_disp>.

Implements ACE_Reactor_Impl.

Definition at line 1603 of file Dev_Poll_Reactor.cpp.

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

01606 {
01607   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
01608 
01609   int result = 0;
01610 
01611 #if (ACE_NSIG > 0)  &&  !defined (CHORUS)
01612 
01613   for (int s = 1; s < ACE_NSIG; ++s)
01614     if (sigset.is_member (s)
01615         && this->signal_handler_->register_handler (s,
01616                                                     new_sh,
01617                                                     new_disp) == -1)
01618       result = -1;
01619 
01620 #else  /* ACE_NSIG <= 0  ||  CHORUS */
01621 
01622   ACE_UNUSED_ARG (sigset);
01623   ACE_UNUSED_ARG (new_sh);
01624   ACE_UNUSED_ARG (new_disp);
01625 
01626 #endif /* ACE_NSIG <= 0  ||  CHORUS */
01627 
01628   return result;
01629 }

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

References ACE_TRACE, ACE_Sig_Handler::register_handler, and signal_handler_.

01592 {
01593   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
01594 
01595   return this->signal_handler_->register_handler (signum,
01596                                                   new_sh,
01597                                                   new_disp,
01598                                                   old_sh,
01599                                                   old_disp);
01600 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_Reactor_Mask, ACE_SYNCH_MUTEX, ACE_TRACE, and register_handler_i.

01565 {
01566   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
01567 
01568   ACE_Handle_Set_Iterator handle_iter (handle_set);
01569 
01570   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01571 
01572   // @@ It might be more efficient to construct a pollfd array and
01573   //    pass it to the write() call in register_handler_i() only once,
01574   //    instead of calling write() (a system call) once for each file
01575   //    descriptor.
01576 
01577   for (ACE_HANDLE h = handle_iter ();
01578        h != ACE_INVALID_HANDLE;
01579        h = handle_iter ())
01580     if (this->register_handler_i (h, event_handler, mask) == -1)
01581       return -1;
01582 
01583   return 0;
01584 }

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

References ACE_Reactor_Mask.

01557 {
01558   ACE_NOTSUP_RETURN (-1);
01559 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_Reactor_Mask, ACE_SYNCH_MUTEX, ACE_TRACE, and register_handler_i.

01500 {
01501   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
01502 
01503   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01504 
01505   return this->register_handler_i (handle,
01506                                    event_handler,
01507                                    mask);
01508 };

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

References ACE_GUARD_RETURN, ACE_MT, ACE_Reactor_Mask, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Event_Handler::get_handle, and register_handler_i.

01486 {
01487   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler");
01488 
01489   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01490 
01491   return this->register_handler_i (handler->get_handle (),
01492                                    handler,
01493                                    mask);
01494 }

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

References ACE_Reactor_Mask, ACE_TRACE, ACE_Dev_Poll_Reactor_Handler_Repository::bind, ACE_Dev_Poll_Reactor_Handler_Repository::find, handler_rep_, ACE_Event_Handler::NULL_MASK, reactor_mask_to_poll_event, ACE_Dev_Poll_Reactor_Handler_Repository::unbind, and ACE_OS::write.

Referenced by open, and register_handler.

01514 {
01515   ACE_TRACE ("ACE_Dev_Poll_Reactor::register_handler_i");
01516 
01517   if (handle == ACE_INVALID_HANDLE
01518       || mask == ACE_Event_Handler::NULL_MASK
01519       || this->handler_rep_.find (handle) != 0)
01520     {
01521       errno = EINVAL;
01522       return -1;
01523     }
01524 
01525   // Add the event handler to the repository.
01526   if (this->handler_rep_.bind (handle, event_handler, mask) != 0)
01527     return -1;
01528 
01529   struct pollfd pfd;
01530 
01531   pfd.fd      = handle;
01532   pfd.events  = this->reactor_mask_to_poll_event (mask);
01533   pfd.revents = 0;
01534 
01535   // Add file descriptor to the "interest set."
01536   if (ACE_OS::write (this->poll_fd_, &pfd, sizeof (pfd)) != sizeof (pfd))
01537     {
01538       (void) this->handler_rep_.unbind (handle);
01539 
01540       return -1;
01541     }
01542 
01543   // Note the fact that we've changed the state of the wait_set_,
01544   // which is used by the dispatching loop to determine whether it can
01545   // keep going or if it needs to reconsult select().
01546   // this->state_changed_ = 1;
01547 
01548   return 0;
01549 }

int ACE_Dev_Poll_Reactor::remove_handler const ACE_Sig_Set   sigset [virtual]
 

Calls <remove_handler> for every signal in <sigset>.

Implements ACE_Reactor_Impl.

Definition at line 1723 of file Dev_Poll_Reactor.cpp.

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

01724 {
01725   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
01726 
01727   int result = 0;
01728 
01729 #if (ACE_NSIG > 0)  &&  !defined (CHORUS)
01730 
01731   for (int s = 1; s < ACE_NSIG; ++s)
01732     if (sigset.is_member (s)
01733         && this->signal_handler_->remove_handler (s) == -1)
01734       result = -1;
01735 
01736 #else  /* ACE_NSIG <= 0  ||  CHORUS */
01737 
01738   ACE_UNUSED_ARG (sigset);
01739 
01740 #endif /* ACE_NSIG <= 0  ||  CHORUS */
01741 
01742   return result;
01743 }

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

Implements ACE_Reactor_Impl.

Definition at line 1709 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Sig_Handler::remove_handler, and signal_handler_.

01713 {
01714   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
01715 
01716   return this->signal_handler_->remove_handler (signum,
01717                                                 new_disp,
01718                                                 old_disp,
01719                                                 sigkey);
01720 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 1685 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_Reactor_Mask, ACE_SYNCH_MUTEX, ACE_TRACE, and remove_handler_i.

01687 {
01688   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
01689 
01690   ACE_Handle_Set_Iterator handle_iter (handle_set);
01691 
01692   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01693 
01694   // @@ It might be more efficient to construct a pollfd array and
01695   //    pass it to the write() call in register_handler_i() only once,
01696   //    instead of calling write() (a system call) once for each file
01697   //    descriptor.
01698 
01699   for (ACE_HANDLE h = handle_iter ();
01700        h != ACE_INVALID_HANDLE;
01701        h = handle_iter ())
01702     if (this->remove_handler_i (h, mask) == -1)
01703       return -1;
01704 
01705   return 0;
01706 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 1643 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_Reactor_Mask, ACE_SYNCH_MUTEX, ACE_TRACE, and remove_handler_i.

01645 {
01646   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
01647 
01648   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01649 
01650   return this->remove_handler_i (handle, mask);
01651 }

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

Removes <event_handler>. Note that 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 1632 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_Reactor_Mask, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Event_Handler::get_handle, and remove_handler_i.

Referenced by dispatch_io_events.

01634 {
01635   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler");
01636 
01637   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01638 
01639   return this->remove_handler_i (handler->get_handle (), mask);
01640 }

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

References ACE_BIT_DISABLED, ACE_Reactor_Mask, ACE_TRACE, ACE_Reactor::CLR_MASK, ACE_Event_Handler::DONT_CALL, 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::NULL_MASK, and ACE_Dev_Poll_Reactor_Handler_Repository::unbind.

Referenced by remove_handler.

01656 {
01657   ACE_TRACE ("ACE_Dev_Poll_Reactor::remove_handler_i");
01658 
01659 
01660   ACE_Event_Handler *eh = this->handler_rep_.find (handle);
01661 
01662   if (eh == 0
01663       || this->mask_ops_i (handle, mask, ACE_Reactor::CLR_MASK) != 0)
01664     return -1;
01665 
01666   // If there are no longer any outstanding events on the given handle
01667   // then remove it from the handler repository.
01668   if (this->handler_rep_.mask (handle) == ACE_Event_Handler::NULL_MASK
01669       && this->handler_rep_.unbind (handle) != 0)
01670     return -1;
01671 
01672   if (ACE_BIT_DISABLED (mask, ACE_Event_Handler::DONT_CALL))
01673     (void) eh->handle_close (handle, mask);
01674 
01675   // Note the fact that we've changed the state of the wait_set,
01676   // i.e. the "interest set," which is used by the dispatching loop to
01677   // determine whether it can keep going or if it needs to reconsult
01678   // /dev/poll or /dev/epoll.
01679   // this->state_changed_ = 1;
01680 
01681   return 0;
01682 }

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

References ACE_TRACE.

02220 {
02221   ACE_TRACE ("ACE_Dev_Poll_Reactor::requeue_position");
02222 
02223   ACE_NOTSUP_RETURN (-1);
02224 }

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

References ACE_TRACE.

02214 {
02215   ACE_TRACE ("ACE_Dev_Poll_Reactor::requeue_position");
02216 }

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 <timer_id> to <interval>, which is specified in relative time to the current <gettimeofday>. If <interval> is equal to <ACE_Time_Value::zero>, the timer will become a non-rescheduling timer. Returns 0 if successful, -1 if not.

Implements ACE_Reactor_Impl.

Definition at line 1964 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Timer_Queue_T< ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall< ACE_SYNCH_RECURSIVE_MUTEX >, ACE_SYNCH_RECURSIVE_MUTEX >::reset_interval, and timer_queue_.

01966 {
01967   ACE_TRACE ("ACE_Dev_Poll_Reactor::reset_timer_interval");
01968 
01969   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01970 
01971   return this->timer_queue_->reset_interval (timer_id, interval);
01972 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, and restart_.

02202 {
02203   ACE_TRACE ("ACE_Dev_Poll_Reactor::restart");
02204 
02205   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02206 
02207   int current_value = this->restart_;
02208   this->restart_ = r;
02209   return current_value;
02210 }

int ACE_Dev_Poll_Reactor::restart void    [virtual]
 

Get the existing restart value.

Implements ACE_Reactor_Impl.

Definition at line 2191 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, and restart_.

Referenced by open.

02192 {
02193   ACE_TRACE ("ACE_Dev_Poll_Reactor::restart");
02194 
02195   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
02196 
02197   return this->restart_;
02198 }

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

01932 {
01933   // @@ Is this correct?
01934 
01935   return 0;
01936 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, and resume_handler_i.

01867 {
01868   ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler");
01869 
01870   ACE_Handle_Set_Iterator handle_iter (handles);
01871   ACE_HANDLE h;
01872 
01873   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01874 
01875   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
01876     if (this->resume_handler_i (h) == -1)
01877       return -1;
01878 
01879   return 0;
01880 }

int ACE_Dev_Poll_Reactor::resume_handler ACE_HANDLE    handle [virtual]
 

Resume handle.

Implements ACE_Reactor_Impl.

Definition at line 1856 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, and resume_handler_i.

01857 {
01858   ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler");
01859 
01860   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01861 
01862   return this->resume_handler_i (handle);
01863 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Event_Handler::get_handle, and resume_handler_i.

01839 {
01840   ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler");
01841 
01842   if (event_handler == 0)
01843     {
01844       errno = EINVAL;
01845       return -1;
01846     }
01847 
01848   ACE_HANDLE handle = event_handler->get_handle ();
01849 
01850   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01851 
01852   return this->resume_handler_i (handle);
01853 }

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 1900 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_Event_Handler::NULL_MASK, 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.

01901 {
01902   ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handler_i");
01903 
01904   if (this->handler_rep_.find (handle) == 0
01905       && this->handler_rep_.suspended (handle) == 0)
01906     return -1;
01907 
01908   ACE_Reactor_Mask mask = this->handler_rep_.mask (handle);
01909 
01910   if (mask == ACE_Event_Handler::NULL_MASK)
01911     return -1;
01912 
01913   struct pollfd pfd[1];
01914 
01915   pfd[0].fd      = handle;
01916   pfd[0].events  = this->reactor_mask_to_poll_event (mask);
01917   pfd[0].revents = 0;
01918 
01919   // Place the handle back in to the "interest set."
01920   //
01921   // Events for the given handle will once again be polled.
01922   if (ACE_OS::write (this->poll_fd_, pfd, sizeof (pfd)) != sizeof (pfd))
01923     return -1;
01924 
01925   this->handler_rep_.resume (handle);
01926 
01927   return 0;
01928 }

int ACE_Dev_Poll_Reactor::resume_handlers void    [virtual]
 

Resume all handles.

Implements ACE_Reactor_Impl.

Definition at line 1883 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, handler_rep_, resume_handler_i, ACE_Dev_Poll_Reactor_Handler_Repository::size, and ACE_Dev_Poll_Reactor_Handler_Repository::suspended.

01884 {
01885   ACE_TRACE ("ACE_Dev_Poll_Reactor::resume_handlers");
01886 
01887   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01888 
01889   size_t len = this->handler_rep_.size ();
01890 
01891   for (size_t i = 0; i < len; ++i)
01892     if (this->handler_rep_.suspended (i)
01893         && this->resume_handler_i (i) != 0)
01894       return -1;
01895 
01896   return 0;
01897 }

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

Implements ACE_Reactor_Impl.

Definition at line 1947 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Timer_Queue_T< ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall< ACE_SYNCH_RECURSIVE_MUTEX >, ACE_SYNCH_RECURSIVE_MUTEX >::schedule, and timer_queue_.

01951 {
01952   ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_timer");
01953 
01954   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01955 
01956   return this->timer_queue_->schedule (
01957            event_handler,
01958            arg,
01959            this->timer_queue_->gettimeofday () + delay,
01960            interval);
01961 }

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

Add <masks_to_be_added> to the <handle>'s entry. <event_handler> associated with <handle> must already have been registered.

Implements ACE_Reactor_Impl.

Definition at line 2014 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, ACE_Reactor::ADD_MASK, and mask_ops.

02016 {
02017   ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_wakeup");
02018 
02019   return this->mask_ops (handle, mask, ACE_Reactor::ADD_MASK);
02020 }

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

Add <masks_to_be_added> to the <event_handler>'s entry. <event_handler> must already have been registered.

Implements ACE_Reactor_Impl.

Definition at line 2005 of file Dev_Poll_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, ACE_Reactor::ADD_MASK, ACE_Event_Handler::get_handle, and mask_ops.

02007 {
02008   ACE_TRACE ("ACE_Dev_Poll_Reactor::schedule_wakeup");
02009 
02010   return this->mask_ops (eh->get_handle (), mask, ACE_Reactor::ADD_MASK);
02011 }

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

References delete_signal_handler_, and signal_handler_.

00969 {
00970   if (this->delete_signal_handler_ && this->signal_handler_)
00971     delete this->signal_handler_;
00972 
00973   this->signal_handler_ = signal_handler;
00974   this->delete_signal_handler_ = 0;
00975 
00976   return 0;
00977 }

int ACE_Dev_Poll_Reactor::set_timer_queue ACE_Timer_Queue   tq [virtual]
 

Set a user specified timer queue.

Note:
This method is deprecated.
See also:
timer_queue

Implements ACE_Reactor_Impl.

Definition at line 980 of file Dev_Poll_Reactor.cpp.

References timer_queue.

00981 {
00982   // @note This method is deprecated.
00983 
00984   return this->timer_queue (tq);
00985 }

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

References size_.

Referenced by ACE_Dev_Poll_Reactor, and open.

02141 {
02142   return this->size_;
02143 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, and suspend_handler_i.

01775 {
01776   ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler");
01777 
01778   ACE_Handle_Set_Iterator handle_iter (handles);
01779   ACE_HANDLE h;
01780 
01781   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01782 
01783   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
01784     if (this->suspend_handler_i (h) == -1)
01785       return -1;
01786 
01787   return 0;
01788 }

int ACE_Dev_Poll_Reactor::suspend_handler ACE_HANDLE    handle [virtual]
 

Suspend handle temporarily.

Implements ACE_Reactor_Impl.

Definition at line 1764 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, and suspend_handler_i.

01765 {
01766   ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler");
01767 
01768   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01769 
01770   return this->suspend_handler_i (handle);
01771 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, ACE_Event_Handler::get_handle, and suspend_handler_i.

01747 {
01748   ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler");
01749 
01750   if (event_handler == 0)
01751     {
01752       errno = EINVAL;
01753       return -1;
01754     }
01755 
01756   ACE_HANDLE handle = event_handler->get_handle ();
01757 
01758   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01759 
01760   return this->suspend_handler_i (handle);
01761 }

int ACE_Dev_Poll_Reactor::suspend_handler_i ACE_HANDLE    handle [protected]
 

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

Definition at line 1808 of file Dev_Poll_Reactor.cpp.

References ACE_TRACE, ACE_Dev_Poll_Reactor_Handler_Repository::find, handler_rep_, 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.

01809 {
01810   ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handler_i");
01811 
01812   if (this->handler_rep_.find (handle) == 0)
01813     return -1;
01814 
01815   if (this->handler_rep_.suspended (handle))
01816     return 0;  // Already suspended.  @@ Should this be an error?
01817 
01818   struct pollfd pfd[1];
01819 
01820   pfd[0].fd      = handle;
01821   pfd[0].events  = POLLREMOVE;
01822   pfd[0].revents = 0;
01823 
01824   // Remove the handle from the "interest set."
01825   //
01826   // Note that the associated event handler is still in the handler
01827   // repository, but no events will be polled on the given handle thus
01828   // no event will be dispatched to the event handler.
01829   if (ACE_OS::write (this->poll_fd_, pfd, sizeof (pfd)) != sizeof (pfd))
01830     return -1;
01831 
01832   this->handler_rep_.suspend (handle);
01833 
01834   return 0;
01835 }

int ACE_Dev_Poll_Reactor::suspend_handlers void    [virtual]
 

Suspend all handles temporarily.

Implements ACE_Reactor_Impl.

Definition at line 1791 of file Dev_Poll_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, handler_rep_, ACE_Dev_Poll_Reactor_Handler_Repository::size, suspend_handler_i, and ACE_Dev_Poll_Reactor_Handler_Repository::suspended.

01792 {
01793   ACE_TRACE ("ACE_Dev_Poll_Reactor::suspend_handlers");
01794 
01795   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01796 
01797   size_t len = this->handler_rep_.size ();
01798 
01799   for (size_t i = 0; i < len; ++i)
01800     if (this->handler_rep_.suspended (i) == 0
01801         && this->suspend_handler_i (i) != 0)
01802       return -1;
01803 
01804   return 0;
01805 }

ACE_Timer_Queue * ACE_Dev_Poll_Reactor::timer_queue void    const [virtual]
 

Return the current ACE_Timer_Queue.

Implements ACE_Reactor_Impl.

Definition at line 1001 of file Dev_Poll_Reactor.cpp.

References timer_queue_.

Referenced by set_timer_queue.

01002 {
01003   return this->timer_queue_;
01004 }

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

References delete_timer_queue_, and timer_queue_.

00989 {
00990   if (this->delete_timer_queue_ && this->timer_queue_)
00991     delete this->timer_queue_;
00992 
00993   this->timer_queue_ = tq;
00994   this->delete_timer_queue_ = 0;
00995 
00996   return 0;
00997 
00998 }

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.

Todo:
Resume the handler so that other threads will be allowed to dispatch the handler.

Definition at line 185 of file Dev_Poll_Reactor.inl.

Referenced by dispatch_io_events.

00188 {
00189   // If the handler returns positive value (requesting a reactor
00190   // callback) just call back as many times as the handler requests
00191   // it.  Other threads are off handling other things.
00192   int status = 0;
00193 
00194   do
00195     {
00196       status = (event_handler->*callback) (handle);
00197     }
00198   while (status > 0);
00199 
00200   return status;
00201 }

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

01940 {
01941   // Since the Dev_Poll_Reactor does not do any event associations,
01942   // this method always return zero.
01943   return 0;
01944 }

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

References ACE_TRACE, notify, ACE_Event_Handler::NULL_MASK, and ACE_Time_Value::zero.

Referenced by deactivate.

02155 {
02156   ACE_TRACE ("ACE_Dev_Poll_Reactor::wakeup_all_threads");
02157 
02158 #if 0
02159   // Send a notification, but don't block if there's no one to receive
02160   // it.
02161   this->notify (0,
02162                 ACE_Event_Handler::NULL_MASK,
02163                 (ACE_Time_Value *) &ACE_Time_Value::zero);
02164 #endif  /* 0 */
02165 }

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

References ACE_GUARD_RETURN, ACE_MT, ACE_SYNCH_MUTEX, ACE_TRACE, and work_pending_i.

01070 {
01071   ACE_TRACE ("ACE_Dev_Poll_Reactor::work_pending");
01072 
01073   // Stash the current time
01074   //
01075   // The destructor of this object will automatically compute how much
01076   // time elapsed since this method was called.
01077   ACE_Time_Value mwt (max_wait_time);
01078   ACE_MT (ACE_Countdown_Time countdown (&mwt));
01079 
01080   ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1));
01081 
01082   // Update the countdown to reflect time waiting for the mutex.
01083   ACE_MT (countdown.update ());
01084 
01085   return this->work_pending_i (&mwt);
01086 }

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

References ACE_TRACE, ACE_Timer_Queue_T< ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall< ACE_SYNCH_RECURSIVE_MUTEX >, ACE_SYNCH_RECURSIVE_MUTEX >::calculate_timeout, deactivated_, end_pfds_, ACE_OS::ioctl, ACE_Time_Value::msec, size_, start_pfds_, and timer_queue_.

Referenced by handle_events_i, and work_pending.

01090 {
01091   ACE_TRACE ("ACE_Dev_Poll_Reactor::work_pending_i");
01092 
01093   if (this->deactivated_)
01094     return 0;
01095 
01096   if (this->start_pfds_ != this->end_pfds_)
01097     return 1;  // We still have work_pending() do not poll for
01098                // additional events.
01099 
01100   ACE_Time_Value timer_buf (0);
01101   ACE_Time_Value *this_timeout = 0;
01102 
01103   this_timeout = this->timer_queue_->calculate_timeout (max_wait_time,
01104                                                         &timer_buf);
01105 
01106   // Check if we have timers to fire.
01107   int timers_pending =
01108     ((this_timeout != 0 && max_wait_time == 0)
01109      || (this_timeout != 0 && max_wait_time != 0
01110          && *this_timeout != *max_wait_time) ? 1 : 0);
01111 
01112   long timeout =
01113     (this_timeout == 0 ? -1 /* Infinity */ : this_timeout->msec ());
01114 
01115 #if defined (ACE_HAS_EVENT_POLL)
01116 
01117   struct evpoll evp;
01118 
01119   evp.ep_timeout = timeout;  // Milliseconds
01120   evp.ep_resoff = 0;
01121 
01122   // Poll for events
01123   int nfds = ACE_OS::ioctl (this->poll_fd_, EP_POLL, &evp);
01124 
01125   // Retrieve the results from the memory map.
01126   this->start_pfds_ =
01127     ACE_reinterpret_cast (struct pollfd *,
01128                           this->mmap_ + evp.ep_resoff);
01129 
01130 #else
01131 
01132   struct dvpoll dvp;
01133 
01134   dvp.dp_fds = this->dp_fds_;
01135   dvp.dp_nfds = this->size_;
01136   dvp.dp_timeout = timeout;  // Milliseconds
01137 
01138   // Poll for events
01139   int nfds = ACE_OS::ioctl (this->poll_fd_, DP_POLL, &dvp);
01140 
01141   // Retrieve the results from the pollfd array.
01142   this->start_pfds_ = dvp.dp_fds;
01143 
01144 #endif  /* ACE_HAS_EVENT_POLL */
01145 
01146   // If nfds == 0 then end_pfds_ == start_pfds_ meaning that there is
01147   // no work pending.  If nfds > 0 then there is work pending.
01148   // Otherwise an error occurred.
01149   if (nfds > -1)
01150     this->end_pfds_ = this->start_pfds_ + nfds;
01151 
01152   // If timers are pending, override any timeout from the poll.
01153   return (nfds == 0 && timers_pending != 0 ? 1 : nfds);
01154 }


Member Data Documentation

ACE_Dev_Poll_Reactor::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Reactor_Impl.

Definition at line 964 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 1073 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 1104 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 1096 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 1089 of file Dev_Poll_Reactor.h.

Referenced by close, open, and timer_queue.

struct pollfd* ACE_Dev_Poll_Reactor::end_pfds_ [protected]
 

The last element in the pollfd array plus one.

The loop that dispatches IO events stops when this->start_pfds == this->end_pfds_.

Definition at line 1069 of file Dev_Poll_Reactor.h.

Referenced by close, dispatch_io_events, 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 1082 of file Dev_Poll_Reactor.h.

Referenced by close, dispatch_io_events, handler, mask_ops_i, open, register_handler_i, remove_handler_i, resume_handler_i, resume_handlers, suspend_handler_i, and suspend_handlers.

char ACE_Dev_Poll_Reactor::initialized_ [protected]
 

Has the reactor been initialized.

Definition at line 1034 of file Dev_Poll_Reactor.h.

Referenced by close, initialized, and open.

ACE_SYNCH_MUTEX ACE_Dev_Poll_Reactor::lock_ [protected]
 

Lock used for synchronization of reactor state.

Definition at line 1076 of file Dev_Poll_Reactor.h.

ACE_Lock_Adapter<ACE_SYNCH_MUTEX> ACE_Dev_Poll_Reactor::lock_adapter_ [protected]
 

Adapter used to return internal lock to outside world.

Definition at line 1079 of file Dev_Poll_Reactor.h.

Referenced by lock.

int ACE_Dev_Poll_Reactor::mask_signals_ [protected]
 

Flag that determines if signals are masked during event dispatching.

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 1114 of file Dev_Poll_Reactor.h.

char* ACE_Dev_Poll_Reactor::mmap_ [protected]
 

Track HANDLES we are interested in for various events that must be dispatched *without* polling. ACE_Dev_Poll_Ready_Set ready_set_; The memory map that `/dev/epoll' will feed its results to.

Definition at line 1054 of file Dev_Poll_Reactor.h.

Referenced by close, and open.

ACE_Reactor_Notify* ACE_Dev_Poll_Reactor::notify_handler_ [protected]
 

Callback object that unblocks the <ACE_Select_Reactor> if it's sleeping.

Definition at line 1100 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]
 

The file descriptor associated with the open `/dev/poll' or `/dev/epoll' device.

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

Definition at line 1042 of file Dev_Poll_Reactor.h.

Referenced by close, and open.

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 1119 of file Dev_Poll_Reactor.h.

Referenced by handle_events_i, open, and restart.

ACE_Sig_Handler* ACE_Dev_Poll_Reactor::signal_handler_ [protected]
 

Handle signals without requiring global/static variables.

Definition at line 1092 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 1046 of file Dev_Poll_Reactor.h.

Referenced by open, size, and work_pending_i.

struct pollfd* ACE_Dev_Poll_Reactor::start_pfds_ [protected]
 

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

Definition at line 1062 of file Dev_Poll_Reactor.h.

Referenced by close, dispatch_io_events, 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 1085 of file Dev_Poll_Reactor.h.

Referenced by cancel_timer, close, dispatch_timer_handlers, open, reset_timer_interval, schedule_timer, timer_queue, and work_pending_i.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:47:10 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002