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

ACE_WFMO_Reactor Class Reference

An object oriented event demultiplexor and event handler. ACE_WFMO_Reactor is a Windows-only implementation of the ACE_Reactor interface that uses the WaitForMultipleObjects() event demultiplexer. More...

#include <WFMO_Reactor.h>

Inheritance diagram for ACE_WFMO_Reactor:

Inheritance graph
[legend]
Collaboration diagram for ACE_WFMO_Reactor:

Collaboration graph
[legend]
List of all members.

Public Types

enum  { DEFAULT_SIZE = MAXIMUM_WAIT_OBJECTS - 2 }

Public Methods

 ACE_WFMO_Reactor (ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, ACE_Reactor_Notify *=0)
 Initialize ACE_WFMO_Reactor with the default size. More...

 ACE_WFMO_Reactor (size_t size, int unused=0, ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, ACE_Reactor_Notify *=0)
virtual int open (size_t size=ACE_WFMO_Reactor::DEFAULT_SIZE, int restart=0, ACE_Sig_Handler *=0, ACE_Timer_Queue *=0, int disable_notify_pipe=0, ACE_Reactor_Notify *=0)
virtual int current_info (ACE_HANDLE, size_t &)
 Returns -1 (not used in this implementation);. More...

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)
 
Deprecated:
The following method is deprecated. Instead, either specify a timer queue when creating/opening the object or use the timer_queue() method.
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 the ACE_WFMO_Reactor and release all of its resources. More...

virtual ~ACE_WFMO_Reactor (void)
 Close down the ACE_WFMO_Reactor and release all of its 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_HANDLE event_handle=ACE_INVALID_HANDLE)
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 (ACE_HANDLE io_handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask)
virtual int register_handler (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)
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 ie. can it pass on the control of handle resumption to the application. A positive value indicates that the handlers are application resumable. A value of 0 indicates otherwise. More...

virtual int uses_event_associations (void)
virtual long schedule_timer (ACE_Event_Handler *event_handler, const void *arg, const ACE_Time_Value &delay, const ACE_Time_Value &interval=ACE_Time_Value::zero)
virtual int reset_timer_interval (long timer_id, const ACE_Time_Value &interval)
virtual int cancel_timer (ACE_Event_Handler *event_handler, int dont_call_handle_close=1)
 Cancel all Event_Handlers that match the address of <event_handler>. Returns number of handler's 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)
virtual int schedule_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask masks_to_be_added)
virtual int cancel_wakeup (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks_to_be_deleted)
virtual int cancel_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask masks_to_be_deleted)
virtual int notify (ACE_Event_Handler *=0, ACE_Reactor_Mask=ACE_Event_Handler::EXCEPT_MASK, ACE_Time_Value *=0)
virtual void max_notify_iterations (int)
virtual int max_notify_iterations (void)
virtual 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 WFMO_Reactor has been successfully initialized, else false. More...

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

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

virtual void wakeup_all_threads (void)
 Wake up all threads in WaitForMultipleObjects so that they can reconsult the handle set. More...

virtual int owner (ACE_thread_t new_owner, ACE_thread_t *old_owner=0)
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)
 Not implemented. More...

virtual int requeue_position (void)
 Not implemented. More...

virtual int mask_ops (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks, int operation)
virtual int mask_ops (ACE_HANDLE handle, ACE_Reactor_Mask masks, int ops)
virtual int ready_ops (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask, int ops)
 Not implemented. More...

virtual int ready_ops (ACE_HANDLE handle, ACE_Reactor_Mask, int ops)
 Not implemented. More...

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Methods

virtual int register_handler_i (ACE_HANDLE event_handle, ACE_HANDLE io_handle, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask)
 Registration workhorse. More...

virtual int event_handling (ACE_Time_Value *max_wait_time=0, int alertable=0)
 Event handling workhorse. More...

virtual int mask_ops_i (ACE_HANDLE io_handle, ACE_Reactor_Mask masks, int operation)
 Bit masking workhorse. More...

virtual ACE_thread_t owner_i (void)
 Return the ID of the "owner" thread. Does not do any locking. More...

virtual int ok_to_wait (ACE_Time_Value *max_wait_time, int alertable)
 Check to see if it is ok to enter <WaitForMultipleObjects>. More...

virtual DWORD wait_for_multiple_events (int timeout, int alertable)
 Wait for timer and I/O events to occur. More...

virtual DWORD poll_remaining_handles (DWORD slot)
 Check for activity on remaining handles. More...

virtual int expire_timers (void)
 Expire timers. Only the owner thread does useful stuff in this function. More...

virtual int dispatch (DWORD wait_status)
 Dispatches the timers and I/O handlers. More...

virtual int safe_dispatch (DWORD wait_status)
 Protect against structured exceptions caused by user code when dispatching handles. More...

virtual int dispatch_handles (DWORD slot)
virtual int dispatch_handler (DWORD slot, DWORD max_handlep1)
 Dispatches a single handler. Returns 0 on success, -1 if the handler was removed. More...

virtual int simple_dispatch_handler (DWORD slot, ACE_HANDLE event_handle)
 Dispatches a single handler. Returns 0 on success, -1 if the handler was removed. More...

virtual int complex_dispatch_handler (DWORD slot, ACE_HANDLE event_handle)
 Dispatches a single handler. Returns 0 on success, -1 if the handler was removed. More...

virtual int dispatch_window_messages (void)
 Dispatches window messages. Noop for WFMO_Reactor. More...

virtual ACE_Reactor_Mask upcall (ACE_Event_Handler *event_handler, ACE_HANDLE io_handle, WSANETWORKEVENTS &events)
virtual int calculate_timeout (ACE_Time_Value *time)
 Used to caluculate the next timeout. More...

virtual int update_state (void)
 Update the state of the handler repository. More...

virtual int new_owner (void)
 Check to see if we have a new owner. More...

virtual int change_owner (void)
 Set owner to new owner. More...


Protected Attributes

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

int delete_handler_rep_
 Keeps track of whether we should delete the handler repository. More...

ACE_Reactor_Notifynotify_handler_
 Used when <notify> is called. More...

int delete_notify_handler_
 Keeps track of whether we should delete the notify handler. More...

ACE_Process_Mutex lock_
ACE_Lock_Adapter< ACE_Process_Mutexlock_adapter_
 Adapter used to return internal lock to outside world. More...

ACE_WFMO_Reactor_Handler_Repository handler_rep_
 Table that maps <ACE_HANDLEs> to <ACE_Event_Handler *>'s. More...

ACE_Manual_Event ok_to_wait_
 A manual event used to block threads from proceeding into WaitForMultipleObjects. More...

ACE_Manual_Event wakeup_all_threads_
ACE_Wakeup_All_Threads_Handler wakeup_all_threads_handler_
 Used when <wakeup_all_threads_> is signaled. More...

ACE_Auto_Event waiting_to_change_state_
 The changing thread waits on this event, till all threads are not active anymore. More...

size_t active_threads_
 Count of currently active threads. More...

ACE_thread_t owner_
ACE_thread_t new_owner_
 The owner to be of the WFMO_Reactor. More...

ACE_thread_t change_state_thread_
 This is the thread which is responsible for the changing the state of the <WFMO_Reactor> handle set. More...

ACE_HANDLE atomic_wait_array_ [2]
 This is an array of ACE_HANDLEs which keep track of the <lock_> and <ok_to_wait_> handles. More...

int open_for_business_
 This flag is used to keep track of whether we are already closed. More...

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


Private Methods

 ACE_WFMO_Reactor (const ACE_WFMO_Reactor &)
 Deny access since member-wise won't work... More...

ACE_WFMO_Reactor & operator= (const ACE_WFMO_Reactor &)

Friends

class ACE_WFMO_Reactor_Handler_Repository
class ACE_WFMO_Reactor_Test

Detailed Description

An object oriented event demultiplexor and event handler. ACE_WFMO_Reactor is a Windows-only implementation of the ACE_Reactor interface that uses the WaitForMultipleObjects() event demultiplexer.

Like the other ACE Reactors, ACE_WFMO_Reactor can schedule timers. It also reacts to signalable handles, such as events (see the documentation for WaitForMultipleObjects() for a complete list of signalable handle types). Therefore, I/O handles are not directly usable for registering for input, output, and exception notification. The exception to this is ACE_SOCK-based handles, which can be registered for input, output, and exception notification just as with other platforms. See Chapter 4 in C++NPv2 for complete details.

Note that changes to the state of ACE_WFMO_Reactor are not instantaneous. Most changes (registration, removal, suspension, and resumption of handles, and changes in ownership) are made when the ACE_WFMO_Reactor reaches a stable state. Users should be careful, especially when removing handlers. This is because the ACE_WFMO_Reactor will call handle_close() on the handler when it is finally removed and not when remove_handler() is called. If the registered handler's pointer is not valid when ACE_WFMO_Reactor calls ACE_Event_Handler::handle_close(), use the DONT_CALL flag with remove_handler(). Preferably, use dynamically allocated event handlers and call "delete this" inside the handle_close() hook method.

Definition at line 622 of file WFMO_Reactor.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
DEFAULT_SIZE  Default size of the WFMO_Reactor's handle table.

Two slots will be added to the size parameter in the constructor and open methods which will store handles used for internal management purposes.

Definition at line 628 of file WFMO_Reactor.h.

00629   {
00630     /// Default size of the WFMO_Reactor's handle table.
00631     /**
00632      * Two slots will be added to the @a size parameter in the
00633      * constructor and open methods which will store handles used for
00634      * internal management purposes.
00635      */
00636     DEFAULT_SIZE = MAXIMUM_WAIT_OBJECTS - 2
00637   };


Constructor & Destructor Documentation

ACE_WFMO_Reactor::ACE_WFMO_Reactor ACE_Sig_Handler   = 0,
ACE_Timer_Queue   = 0,
ACE_Reactor_Notify   = 0
 

Initialize ACE_WFMO_Reactor with the default size.

Definition at line 1005 of file WFMO_Reactor.cpp.

References ACE_ERROR, ACE_LIB_TEXT, DEFAULT_SIZE, LM_ERROR, notify, and open.

01008   : signal_handler_ (0),
01009     delete_signal_handler_ (0),
01010     timer_queue_ (0),
01011     delete_timer_queue_ (0),
01012     delete_handler_rep_ (0),
01013     delete_notify_handler_ (0),
01014     lock_adapter_ (lock_),
01015     handler_rep_ (*this),
01016     // this event is initially signaled
01017     ok_to_wait_ (1),
01018     // this event is initially unsignaled
01019     wakeup_all_threads_ (0),
01020     // this event is initially unsignaled
01021     waiting_to_change_state_ (0),
01022     active_threads_ (0),
01023     owner_ (ACE_Thread::self ()),
01024     new_owner_ (0),
01025     change_state_thread_ (0),
01026     open_for_business_ (0),
01027     deactivated_ (0)
01028 {
01029   if (this->open (ACE_WFMO_Reactor::DEFAULT_SIZE, 0, sh, tq, 0, notify) == -1)
01030     ACE_ERROR ((LM_ERROR,
01031                 ACE_LIB_TEXT ("%p\n"),
01032                 ACE_LIB_TEXT ("WFMO_Reactor")));
01033 }

ACE_WFMO_Reactor::ACE_WFMO_Reactor size_t    size,
int    unused = 0,
ACE_Sig_Handler   = 0,
ACE_Timer_Queue   = 0,
ACE_Reactor_Notify   = 0
 

Initialize ACE_WFMO_Reactor with the specified size.

Parameters:
size  The maximum number of handles the reactor can register. The value should not exceed ACE_WFMO_Reactor::DEFAULT_SIZE. Two slots will be added to the size parameter which will store handles used for internal management purposes.

Definition at line 1035 of file WFMO_Reactor.cpp.

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

01040   : signal_handler_ (0),
01041     delete_signal_handler_ (0),
01042     timer_queue_ (0),
01043     delete_timer_queue_ (0),
01044     delete_handler_rep_ (0),
01045     delete_notify_handler_ (0),
01046     lock_adapter_ (lock_),
01047     handler_rep_ (*this),
01048     // this event is initially signaled
01049     ok_to_wait_ (1),
01050     // this event is initially unsignaled
01051     wakeup_all_threads_ (0),
01052     // this event is initially unsignaled
01053     waiting_to_change_state_ (0),
01054     active_threads_ (0),
01055     owner_ (ACE_Thread::self ()),
01056     new_owner_ (0),
01057     change_state_thread_ (0),
01058     open_for_business_ (0),
01059     deactivated_ (0)
01060 {
01061   ACE_UNUSED_ARG (unused);
01062 
01063   if (this->open (size, 0, sh, tq, 0, notify) == -1)
01064     ACE_ERROR ((LM_ERROR,
01065                 ACE_LIB_TEXT ("%p\n"),
01066                 ACE_LIB_TEXT ("WFMO_Reactor")));
01067 }

ACE_WFMO_Reactor::~ACE_WFMO_Reactor void    [virtual]
 

Close down the ACE_WFMO_Reactor and release all of its resources.

Definition at line 1243 of file WFMO_Reactor.cpp.

References close, delete_notify_handler_, delete_signal_handler_, delete_timer_queue_, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::make_changes, notify_handler_, signal_handler_, and timer_queue_.

01244 {
01245   // Assumption: No threads are left in the Reactor when this method
01246   // is called (i.e., active_threads_ == 0)
01247 
01248   // Close down
01249   this->close ();
01250 
01251   // Make necessary changes to the handler repository that we caused
01252   // by <close>.
01253   this->handler_rep_.make_changes ();
01254 
01255   if (this->delete_timer_queue_)
01256     {
01257       delete this->timer_queue_;
01258       this->timer_queue_ = 0;
01259       this->delete_timer_queue_ = 0;
01260     }
01261 
01262   if (this->delete_signal_handler_)
01263     {
01264       delete this->signal_handler_;
01265       this->signal_handler_ = 0;
01266       this->delete_signal_handler_ = 0;
01267     }
01268 
01269   if (this->delete_notify_handler_)
01270     {
01271       delete this->notify_handler_;
01272       this->notify_handler_ = 0;
01273       this->delete_notify_handler_ = 0;
01274     }
01275 }

ACE_WFMO_Reactor::ACE_WFMO_Reactor const ACE_WFMO_Reactor &    [private]
 

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


Member Function Documentation

ACE_INLINE int ACE_WFMO_Reactor::alertable_handle_events ACE_Time_Value   max_wait_time [virtual]
 

Implements ACE_Reactor_Impl.

Reimplemented in ACE_Msg_WFMO_Reactor.

Definition at line 826 of file WFMO_Reactor.i.

References event_handling.

00827 {
00828   return this->event_handling (&how_long, TRUE);
00829 }

ACE_INLINE int ACE_WFMO_Reactor::alertable_handle_events ACE_Time_Value   max_wait_time = 0 [virtual]
 

Implements ACE_Reactor_Impl.

Reimplemented in ACE_Msg_WFMO_Reactor.

Definition at line 838 of file WFMO_Reactor.i.

References event_handling.

00839 {
00840   return this->event_handling (how_long, TRUE);
00841 }

int ACE_WFMO_Reactor::calculate_timeout ACE_Time_Value   time [protected, virtual]
 

Used to caluculate the next timeout.

Definition at line 1740 of file WFMO_Reactor.cpp.

References ACE_Timer_Queue_T< ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall< ACE_SYNCH_RECURSIVE_MUTEX >, ACE_SYNCH_RECURSIVE_MUTEX >::calculate_timeout, ACE_Time_Value::msec, owner_, ACE_Thread::self, and timer_queue_.

Referenced by event_handling.

01741 {
01742   ACE_Time_Value *time = 0;
01743   if (this->owner_ == ACE_Thread::self ())
01744     time = this->timer_queue_->calculate_timeout (max_wait_time);
01745   else
01746     time = max_wait_time;
01747 
01748   if (time == 0)
01749     return INFINITE;
01750   else
01751     return time->msec ();
01752 }

ACE_INLINE int ACE_WFMO_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 480 of file WFMO_Reactor.i.

References 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_.

00483 {
00484   ACE_TRACE ("ACE_WFMO_Reactor::cancel_timer");
00485   return this->timer_queue_->cancel (timer_id, arg, dont_call_handle_close);
00486 }

ACE_INLINE int ACE_WFMO_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 handler's cancelled.

Implements ACE_Reactor_Impl.

Definition at line 472 of file WFMO_Reactor.i.

References 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_.

00474 {
00475   ACE_TRACE ("ACE_WFMO_Reactor::cancel_timer");
00476   return this->timer_queue_->cancel (handler, dont_call_handle_close);
00477 }

ACE_INLINE int ACE_WFMO_Reactor::cancel_wakeup ACE_HANDLE    handle,
ACE_Reactor_Mask    masks_to_be_deleted
[virtual]
 

Remove <masks_to_be_deleted> to the <handle>'s entry in WFMO_Reactor. The Event_Handler associated with <handle> must already have been registered with WFMO_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 591 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_Reactor::CLR_MASK, and mask_ops_i.

00593 {
00594   // This GUARD is necessary since we are updating shared state.
00595   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00596 
00597   return this->mask_ops_i (io_handle,
00598                            masks_to_be_removed,
00599                            ACE_Reactor::CLR_MASK);
00600 }

ACE_INLINE int ACE_WFMO_Reactor::cancel_wakeup ACE_Event_Handler   event_handler,
ACE_Reactor_Mask    masks_to_be_deleted
[virtual]
 

Remove <masks_to_be_deleted> to the <handle>'s entry in WFMO_Reactor. The Event_Handler associated with <handle> must already have been registered with WFMO_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 603 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_Reactor::CLR_MASK, ACE_Event_Handler::get_handle, and mask_ops_i.

00605 {
00606   // This GUARD is necessary since we are updating shared state.
00607   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00608 
00609   return this->mask_ops_i (event_handler->get_handle (),
00610                            masks_to_be_removed,
00611                            ACE_Reactor::CLR_MASK);
00612 }

ACE_INLINE int ACE_WFMO_Reactor::change_owner void    [protected, virtual]
 

Set owner to new owner.

Definition at line 893 of file WFMO_Reactor.i.

References ACE_thread_t, new_owner_, and owner_.

Referenced by update_state.

00894 {
00895   this->owner_ = this->new_owner_;
00896   this->new_owner_ = ACE_thread_t (0);
00897   return 0;
00898 }

int ACE_WFMO_Reactor::close void    [virtual]
 

Close down the ACE_WFMO_Reactor and release all of its resources.

Implements ACE_Reactor_Impl.

Definition at line 1226 of file WFMO_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_WFMO_Reactor_Handler_Repository::close, handler_rep_, and open_for_business_.

Referenced by ~ACE_WFMO_Reactor.

01227 {
01228   // This GUARD is necessary since we are updating shared state.
01229   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
01230 
01231   // If we are already closed, return error
01232   if (!this->open_for_business_)
01233     return -1;
01234 
01235   // We are now closed
01236   this->open_for_business_ = 0;
01237   // This will unregister all handles
01238   this->handler_rep_.close ();
01239 
01240   return 0;
01241 }

int ACE_WFMO_Reactor::complex_dispatch_handler DWORD    slot,
ACE_HANDLE    event_handle
[protected, virtual]
 

Dispatches a single handler. Returns 0 on success, -1 if the handler was removed.

Definition at line 1915 of file WFMO_Reactor.cpp.

References ACE_Reactor_Mask, ACE_Event_Handler::ALL_EVENTS_MASK, ACE_WFMO_Reactor_Handler_Repository::current_info, current_info, ACE_WFMO_Reactor_Handler_Repository::Common_Info::event_handler_, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_handle_, _WSANETWORKEVENTS::lNetworkEvents, ACE_WFMO_Reactor_Handler_Repository::Common_Info::network_events_, ACE_Event_Handler::NULL_MASK, ACE_WFMO_Reactor_Handler_Repository::scheduled_for_deletion, ACE_WFMO_Reactor_Handler_Repository::unbind, and upcall.

Referenced by dispatch_handler.

01917 {
01918   // This dispatch is used for I/O entires.
01919 
01920   ACE_WFMO_Reactor_Handler_Repository::Current_Info &current_info =
01921     this->handler_rep_.current_info ()[slot];
01922 
01923   WSANETWORKEVENTS events;
01924   ACE_Reactor_Mask problems = ACE_Event_Handler::NULL_MASK;
01925   if (::WSAEnumNetworkEvents ((SOCKET) current_info.io_handle_,
01926                               event_handle,
01927                               &events) == SOCKET_ERROR)
01928     problems = ACE_Event_Handler::ALL_EVENTS_MASK;
01929   else
01930     {
01931       // Prepare for upcalls. Clear the bits from <events> representing
01932       // events the handler is not interested in. If there are any left,
01933       // do the upcall(s). upcall will replace events.lNetworkEvents
01934       // with bits representing any functions that requested a repeat
01935       // callback before checking handles again. In this case, continue
01936       // to call back unless the handler is unregistered as a result of
01937       // one of the upcalls. The way this is written, the upcalls will
01938       // keep being done even if one or more upcalls reported problems.
01939       // In practice this may turn out not so good, but let's see. If any
01940       // problems, please notify Steve Huston <shuston@riverace.com>
01941       // before or after you change this code.
01942       events.lNetworkEvents &= current_info.network_events_;
01943       while (events.lNetworkEvents != 0)
01944         {
01945           // Upcall
01946           problems |= this->upcall (current_info.event_handler_,
01947                                     current_info.io_handle_,
01948                                     events);
01949           if (this->handler_rep_.scheduled_for_deletion (slot))
01950             break;
01951         }
01952     }
01953 
01954   if (problems != ACE_Event_Handler::NULL_MASK
01955       && !this->handler_rep_.scheduled_for_deletion (slot)  )
01956     this->handler_rep_.unbind (event_handle, problems);
01957 
01958   return 0;
01959 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 1070 of file WFMO_Reactor.cpp.

Referenced by complex_dispatch_handler.

01071 {
01072   return -1;
01073 }

ACE_INLINE void ACE_WFMO_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 wish.

Implements ACE_Reactor_Impl.

Definition at line 850 of file WFMO_Reactor.i.

References deactivated_, and wakeup_all_threads.

00851 {
00852   this->deactivated_ = do_stop;
00853   this->wakeup_all_threads ();
00854 }

ACE_INLINE int ACE_WFMO_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, <handling_events> and <handle_alertable_events> return -1 immediately.

Implements ACE_Reactor_Impl.

Definition at line 844 of file WFMO_Reactor.i.

References deactivated_.

00845 {
00846   return this->deactivated_;
00847 }

int ACE_WFMO_Reactor::dispatch DWORD    wait_status [protected, virtual]
 

Dispatches the timers and I/O handlers.

Definition at line 1769 of file WFMO_Reactor.cpp.

References dispatch_handles, ETIME, expire_timers, and ACE_OS::set_errno_to_last_error.

Referenced by safe_dispatch.

01770 {
01771   int handlers_dispatched = 0;
01772 
01773   // Expire timers
01774   handlers_dispatched += this->expire_timers ();
01775 
01776   switch (wait_status)
01777     {
01778     case WAIT_FAILED: // Failure.
01779       ACE_OS::set_errno_to_last_error ();
01780       return -1;
01781 
01782     case WAIT_TIMEOUT: // Timeout.
01783       errno = ETIME;
01784       return handlers_dispatched;
01785 
01786 #ifndef ACE_HAS_WINCE
01787     case WAIT_IO_COMPLETION: // APC.
01788       return handlers_dispatched;
01789 #endif  // ACE_HAS_WINCE
01790 
01791     default:  // Dispatch.
01792       // We'll let dispatch worry about abandoned mutes.
01793       handlers_dispatched += this->dispatch_handles (wait_status);
01794       return handlers_dispatched;
01795     }
01796 }

int ACE_WFMO_Reactor::dispatch_handler DWORD    slot,
DWORD    max_handlep1
[protected, virtual]
 

Dispatches a single handler. Returns 0 on success, -1 if the handler was removed.

Definition at line 1864 of file WFMO_Reactor.cpp.

References complex_dispatch_handler, ACE_WFMO_Reactor_Handler_Repository::current_info, dispatch_window_messages, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::handles, ACE_WFMO_Reactor_Handler_Repository::scheduled_for_deletion, and simple_dispatch_handler.

Referenced by dispatch_handles.

01866 {
01867   // Check if there are window messages that need to be dispatched
01868   if (slot == max_handlep1)
01869     return this->dispatch_window_messages ();
01870 
01871   // Dispatch the handler if it has not been scheduled for deletion.
01872   // Note that this is a very week test if there are multiple threads
01873   // dispatching this slot as no locks are held here. Generally, you
01874   // do not want to do something like deleting the this pointer in
01875   // handle_close() if you have registered multiple times and there is
01876   // more than one thread in WFMO_Reactor->handle_events().
01877   else if (!this->handler_rep_.scheduled_for_deletion (slot))
01878     {
01879       ACE_HANDLE event_handle = *(this->handler_rep_.handles () + slot);
01880 
01881       if (this->handler_rep_.current_info ()[slot].io_entry_)
01882         return this->complex_dispatch_handler (slot,
01883                                                event_handle);
01884       else
01885         return this->simple_dispatch_handler (slot,
01886                                               event_handle);
01887     }
01888   else
01889     // The handle was scheduled for deletion, so we will skip it.
01890     return 0;
01891 }

int ACE_WFMO_Reactor::dispatch_handles DWORD    slot [protected, virtual]
 

Dispatches any active handles from handles_[<slot>] to handles_[active_handles_] using <WaitForMultipleObjects> to poll through our handle set looking for active handles.

Definition at line 1802 of file WFMO_Reactor.cpp.

References dispatch_handler, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::max_handlep1, poll_remaining_handles, and ACE_OS::set_errno_to_last_error.

Referenced by dispatch.

01803 {
01804   // dispatch_slot is the absolute slot.  Only += is used to
01805   // increment it.
01806   DWORD dispatch_slot = 0;
01807 
01808   // Cache this value, this is the absolute value.
01809   DWORD max_handlep1 = this->handler_rep_.max_handlep1 ();
01810 
01811   // nCount starts off at <max_handlep1>, this is a transient count of
01812   // handles last waited on.
01813   DWORD nCount = max_handlep1;
01814 
01815   for (int number_of_handlers_dispatched = 1;
01816        ;
01817        number_of_handlers_dispatched++)
01818     {
01819       int ok = (
01820 #if ! (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0530)) \
01821     && !defined (ghs) \
01822     && !defined (__MINGW32__)
01823                  // wait_status is unsigned in Borland, Green Hills
01824                  // and mingw32;
01825                  // This >= is always true, with a warning.
01826                  wait_status >= WAIT_OBJECT_0 &&
01827 #endif
01828                  wait_status <= (WAIT_OBJECT_0 + nCount));
01829       if (ok)
01830         dispatch_slot += wait_status - WAIT_OBJECT_0;
01831       else
01832         // Otherwise, a handle was abandoned.
01833         dispatch_slot += wait_status - WAIT_ABANDONED_0;
01834 
01835       // Dispatch handler
01836       if (this->dispatch_handler (dispatch_slot, max_handlep1) == -1)
01837         return -1;
01838 
01839       // Increment slot
01840       dispatch_slot++;
01841 
01842       // We're done.
01843       if (dispatch_slot >= max_handlep1)
01844         return number_of_handlers_dispatched;
01845 
01846       // Readjust nCount
01847       nCount = max_handlep1 - dispatch_slot;
01848 
01849       // Check the remaining handles
01850       wait_status = this->poll_remaining_handles (dispatch_slot);
01851       switch (wait_status)
01852         {
01853         case WAIT_FAILED: // Failure.
01854           ACE_OS::set_errno_to_last_error ();
01855           /* FALLTHRU */
01856         case WAIT_TIMEOUT:
01857           // There are no more handles ready, we can return.
01858           return number_of_handlers_dispatched;
01859         }
01860     }
01861 }

ACE_INLINE int ACE_WFMO_Reactor::dispatch_window_messages void    [protected, virtual]
 

Dispatches window messages. Noop for WFMO_Reactor.

Reimplemented in ACE_Msg_WFMO_Reactor.

Definition at line 917 of file WFMO_Reactor.i.

Referenced by dispatch_handler.

00918 {
00919   return 0;
00920 }

void ACE_WFMO_Reactor::dump void    const [virtual]
 

Dump the state of an object.

Implements ACE_Reactor_Impl.

Definition at line 2154 of file WFMO_Reactor.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_Timer_Queue_T< ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall< ACE_SYNCH_RECURSIVE_MUTEX >, ACE_SYNCH_RECURSIVE_MUTEX >::dump, ACE_Sig_Handler::dump, ACE_WFMO_Reactor_Handler_Repository::dump, handler_rep_, LM_DEBUG, signal_handler_, and timer_queue_.

02155 {
02156   ACE_TRACE ("ACE_WFMO_Reactor::dump");
02157 
02158   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
02159 
02160   ACE_DEBUG ((LM_DEBUG,
02161               ACE_LIB_TEXT ("Count of currently active threads = %d\n"),
02162               this->active_threads_));
02163 
02164   ACE_DEBUG ((LM_DEBUG,
02165               ACE_LIB_TEXT ("ID of owner thread = %d\n"),
02166               this->owner_));
02167 
02168   this->handler_rep_.dump ();
02169   this->signal_handler_->dump ();
02170   this->timer_queue_->dump ();
02171 
02172   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
02173 }

int ACE_WFMO_Reactor::event_handling ACE_Time_Value   max_wait_time = 0,
int    alertable = 0
[protected, virtual]
 

Event handling workhorse.

Definition at line 1580 of file WFMO_Reactor.cpp.

References ACE_TRACE, active_threads_, calculate_timeout, deactivated_, lock_, ok_to_wait, open_for_business_, ACE_Process_Mutex::release, safe_dispatch, ACE_Countdown_Time::update, ACE_Time_Value::usec, and wait_for_multiple_events.

Referenced by alertable_handle_events, and handle_events.

01582 {
01583   ACE_TRACE ("ACE_WFMO_Reactor::event_handling");
01584 
01585   // Make sure we are not closed
01586   if (!this->open_for_business_ || this->deactivated_)
01587     return -1;
01588 
01589   // Stash the current time -- the destructor of this object will
01590   // automatically compute how much time elapsed since this method was
01591   // called.
01592   ACE_Countdown_Time countdown (max_wait_time);
01593 
01594   int result;
01595   do
01596     {
01597       // Check to see if it is ok to enter ::WaitForMultipleObjects
01598       // This will acquire <this->lock_> on success On failure, the
01599       // lock will not be acquired
01600       result = this->ok_to_wait (max_wait_time, alertable);
01601       if (result != 1)
01602         return result;
01603 
01604       // Increment the number of active threads
01605       this->active_threads_++;
01606 
01607       // Release the <lock_>
01608       this->lock_.release ();
01609 
01610       // Update the countdown to reflect time waiting to play with the
01611       // mut and event.
01612       countdown.update ();
01613 
01614       // Calculate timeout
01615       int timeout = this->calculate_timeout (max_wait_time);
01616 
01617       // Wait for event to happen
01618       DWORD wait_status = this->wait_for_multiple_events (timeout,
01619                                                           alertable);
01620 
01621       // Upcall
01622       result = this->safe_dispatch (wait_status);
01623       if (0 == result)
01624         {
01625           // wait_for_multiple_events timed out without dispatching
01626           // anything.  Because of rounding and conversion errors and
01627           // such, it could be that the wait loop timed out, but
01628           // the timer queue said it wasn't quite ready to expire a
01629           // timer. In this case, max_wait_time won't have quite been
01630           // reduced to 0, and we need to go around again. If max_wait_time
01631           // is all the way to 0, just return, as the entire time the
01632           // caller wanted to wait has been used up.
01633           countdown.update ();     // Reflect time waiting for events
01634           if (0 == max_wait_time || max_wait_time->usec () == 0)
01635             break;
01636         }
01637     }
01638   while (result == 0);
01639 
01640   return result;
01641 }

int ACE_WFMO_Reactor::expire_timers void    [protected, virtual]
 

Expire timers. Only the owner thread does useful stuff in this function.

Definition at line 1756 of file WFMO_Reactor.cpp.

References ACE_Timer_Queue_T< ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall< ACE_SYNCH_RECURSIVE_MUTEX >, ACE_SYNCH_RECURSIVE_MUTEX >::expire, owner_, ACE_Thread::self, and timer_queue_.

Referenced by dispatch.

01757 {
01758   // If "owner" thread
01759   if (ACE_Thread::self () == this->owner_)
01760     // expire all pending timers.
01761     return this->timer_queue_->expire ();
01762 
01763   else
01764     // Nothing to expire
01765     return 0;
01766 }

ACE_INLINE int ACE_WFMO_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.

The only difference between <alertable_handle_events> and <handle_events> is that in the alertable case, TRUE is passed to <WaitForMultipleObjects> for the <bAlertable> option.

Implements ACE_Reactor_Impl.

Reimplemented in ACE_Msg_WFMO_Reactor.

Definition at line 820 of file WFMO_Reactor.i.

References event_handling.

00821 {
00822   return this->event_handling (&how_long, FALSE);
00823 }

ACE_INLINE int ACE_WFMO_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 timer events, I/O events, or signal events occur. Note that <max_wait_time> can be 0, in which case this method blocks indefinitely until events occur.

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

<WaitForMultipleObjects> is used as the demultiplexing call

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

The only difference between <alertable_handle_events> and <handle_events> is that in the alertable case, TRUE is passed to <WaitForMultipleObjects> for the <bAlertable> option.

Implements ACE_Reactor_Impl.

Reimplemented in ACE_Msg_WFMO_Reactor.

Definition at line 832 of file WFMO_Reactor.i.

References event_handling.

00833 {
00834   return this->event_handling (how_long, FALSE);
00835 }

ACE_INLINE int ACE_WFMO_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 1001 of file WFMO_Reactor.i.

References ACE_Sig_Handler::handler, handler, and signal_handler_.

01002 {
01003   ACE_Event_Handler *handler =
01004     this->signal_handler_->handler (signum);
01005 
01006   if (handler == 0)
01007     return -1;
01008   else if (eh != 0)
01009     *eh = handler;
01010   return 0;
01011 }

ACE_INLINE int ACE_WFMO_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 1086 of file WFMO_Reactor.i.

References ACE_Reactor_Mask, ACE_WFMO_Reactor_Handler_Repository::handler, and handler_rep_.

Referenced by handler.

01089 {
01090   return this->handler_rep_.handler (handle,
01091                                      mask,
01092                                      event_handler);
01093 }

ACE_INLINE int ACE_WFMO_Reactor::initialized void    [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 1096 of file WFMO_Reactor.i.

References open_for_business_.

01097 {
01098   return this->open_for_business_;
01099 }

ACE_INLINE ACE_Lock & ACE_WFMO_Reactor::lock void    [virtual]
 

Returns a reference to the WFMO_Reactor's internal lock.

Implements ACE_Reactor_Impl.

Definition at line 1102 of file WFMO_Reactor.i.

References lock_adapter_.

01103 {
01104   return this->lock_adapter_;
01105 }

ACE_INLINE int ACE_WFMO_Reactor::mask_ops ACE_HANDLE    handle,
ACE_Reactor_Mask    masks,
int    ops
[virtual]
 

Modify <masks> of the <handle>'s entry in WFMO_Reactor depending upon <operation>. <handle> must already have been registered with WFMO_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 1026 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and mask_ops_i.

01029 {
01030   ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
01031 
01032   return this->mask_ops_i (io_handle,
01033                            mask,
01034                            operation);
01035 }

ACE_INLINE int ACE_WFMO_Reactor::mask_ops ACE_Event_Handler   event_handler,
ACE_Reactor_Mask    masks,
int    operation
[virtual]
 

Modify <masks> of the <event_handler>'s entry in WFMO_Reactor depending upon <operation>. <event_handler> must already have been registered with WFMO_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 1014 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_Event_Handler::get_handle, and mask_ops_i.

01017 {
01018   ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
01019 
01020   return this->mask_ops_i (event_handler->get_handle (),
01021                            mask,
01022                            operation);
01023 }

int ACE_WFMO_Reactor::mask_ops_i ACE_HANDLE    io_handle,
ACE_Reactor_Mask    masks,
int    operation
[protected, virtual]
 

Bit masking workhorse.

Definition at line 1369 of file WFMO_Reactor.cpp.

References ACE_Reactor_Mask, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::invalid_handle, and ACE_WFMO_Reactor_Handler_Repository::modify_network_events_i.

Referenced by cancel_wakeup, mask_ops, and schedule_wakeup.

01372 {
01373   // Make sure that the <handle> is valid
01374   if (this->handler_rep_.invalid_handle (io_handle))
01375     return -1;
01376 
01377   long new_network_events = 0;
01378   int delete_event = 0;
01379   ACE_HANDLE event_handle = ACE_INVALID_HANDLE;
01380 
01381   // Look up the repository to see if the <Event_Handler> is already
01382   // there.
01383   ACE_Reactor_Mask old_masks;
01384   int found = this->handler_rep_.modify_network_events_i (io_handle,
01385                                                           new_masks,
01386                                                           old_masks,
01387                                                           new_network_events,
01388                                                           event_handle,
01389                                                           delete_event,
01390                                                           operation);
01391   if (found)
01392     {
01393       int result = ::WSAEventSelect ((SOCKET) io_handle,
01394                                      event_handle,
01395                                      new_network_events);
01396       if (result == 0)
01397         return old_masks;
01398       else
01399         return result;
01400     }
01401   else
01402     return -1;
01403 }

int ACE_WFMO_Reactor::max_notify_iterations void    [virtual]
 

Get the maximum number of times that the <ACE_WFMO_Reactor_Notify::handle_input> method 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 2506 of file WFMO_Reactor.cpp.

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

02507 {
02508   ACE_TRACE ("ACE_WFMO_Reactor::max_notify_iterations");
02509   ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
02510 
02511   return this->notify_handler_->max_notify_iterations ();
02512 }

void ACE_WFMO_Reactor::max_notify_iterations int    [virtual]
 

Set the maximum number of times that the <ACE_WFMO_Reactor_Notify::handle_input> method 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 2496 of file WFMO_Reactor.cpp.

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

02497 {
02498   ACE_TRACE ("ACE_WFMO_Reactor::max_notify_iterations");
02499   ACE_GUARD (ACE_Process_Mutex, monitor, this->lock_);
02500 
02501   // Must always be > 0 or < 0 to optimize the loop exit condition.
02502   this->notify_handler_->max_notify_iterations (iterations);
02503 }

ACE_INLINE int ACE_WFMO_Reactor::new_owner void    [protected, virtual]
 

Check to see if we have a new owner.

Definition at line 887 of file WFMO_Reactor.i.

References ACE_thread_t, and new_owner_.

Referenced by owner, and update_state.

00888 {
00889   return this->new_owner_ != ACE_thread_t (0);
00890 }

ACE_INLINE int ACE_WFMO_Reactor::notify ACE_Event_Handler   = 0,
ACE_Reactor_Mask    = ACE_Event_Handler::EXCEPT_MASK,
ACE_Time_Value   = 0
[virtual]
 

Wakeup one <ACE_WFMO_Reactor> thread if it is currently blocked in <WaitForMultipleObjects>. The <ACE_Time_Value> indicates how long to blocking trying to notify the <WFMO_Reactor>. If <timeout> == 0, the caller will block until action is possible, else will wait until the relative time specified in <timeout> elapses).

Implements ACE_Reactor_Impl.

Definition at line 929 of file WFMO_Reactor.i.

References ACE_Reactor_Mask, ACE_Reactor_Notify::notify, and notify_handler_.

Referenced by ACE_WFMO_Reactor, and schedule_timer.

00932 {
00933   return this->notify_handler_->notify (event_handler, mask, timeout);
00934 }

int ACE_WFMO_Reactor::ok_to_wait ACE_Time_Value   max_wait_time,
int    alertable
[protected, virtual]
 

Check to see if it is ok to enter <WaitForMultipleObjects>.

Definition at line 1644 of file WFMO_Reactor.cpp.

References atomic_wait_array_, ETIME, ACE_Time_Value::msec, and ACE_OS::set_errno_to_last_error.

Referenced by event_handling.

01646 {
01647   // Calculate the max time we should spend here
01648   //
01649   // Note: There is really no need to involve the <timer_queue_> here
01650   // because even if a timeout in the <timer_queue_> does expire we
01651   // will not be able to dispatch it
01652   int timeout = max_wait_time == 0 ? INFINITE : max_wait_time->msec ();
01653 
01654   // Atomically wait for both the <lock_> and <ok_to_wait_> event
01655   DWORD result = 0;
01656   while (1)
01657     {
01658 #if defined (ACE_HAS_PHARLAP)
01659       // PharLap doesn't implement WaitForMultipleObjectsEx, and doesn't
01660       // do async I/O, so it's not needed in this case anyway.
01661       result = ::WaitForMultipleObjects (sizeof this->atomic_wait_array_ / sizeof (ACE_HANDLE),
01662                                          this->atomic_wait_array_,
01663                                          TRUE,
01664                                          timeout);
01665 
01666       if (result != WAIT_IO_COMPLETION)
01667         break;
01668 
01669 #elif defined (ACE_HAS_WINCE)
01670       result = ::WaitForMultipleObjects (sizeof this->atomic_wait_array_ / sizeof (ACE_HANDLE),
01671                                          this->atomic_wait_array_,
01672                                          TRUE,
01673                                          timeout);
01674       break;  // CE does not have WAIT_IO_COMPLETION defined.
01675 #else
01676       result = ::WaitForMultipleObjectsEx (sizeof this->atomic_wait_array_ / sizeof (ACE_HANDLE),
01677                                            this->atomic_wait_array_,
01678                                            TRUE,
01679                                            timeout,
01680                                            alertable);
01681 
01682       if (result != WAIT_IO_COMPLETION)
01683         break;
01684 
01685 #endif /* ACE_HAS_PHARLAP */
01686     }
01687 
01688   switch (result)
01689     {
01690     case WAIT_TIMEOUT:
01691       errno = ETIME;
01692       return 0;
01693     case WAIT_FAILED:
01694     case WAIT_ABANDONED_0:
01695       ACE_OS::set_errno_to_last_error ();
01696       return -1;
01697     default:
01698       break;
01699     }
01700 
01701   // It is ok to enter ::WaitForMultipleObjects
01702   return 1;
01703 }

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

Initialize ACE_WFMO_Reactor with the specified size.

Parameters:
size  The maximum number of handles the reactor can register. The value should not exceed ACE_WFMO_Reactor::DEFAULT_SIZE. Two slots will be added to the size parameter which will store handles used for internal management purposes.

Implements ACE_Reactor_Impl.

Definition at line 1076 of file WFMO_Reactor.cpp.

References ACE_ERROR_RETURN, ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_NEW_RETURN, atomic_wait_array_, ACE_WFMO_Reactor_Handler_Repository::changes_required, delete_handler_rep_, delete_notify_handler_, delete_signal_handler_, delete_timer_queue_, ACE_Event::handle, handler_rep_, LM_ERROR, ACE_Process_Mutex::lock, lock_, ACE_WFMO_Reactor_Handler_Repository::make_changes, notify_handler_, ok_to_wait_, ACE_Reactor_Notify::open, ACE_WFMO_Reactor_Handler_Repository::open, open_for_business_, register_handler, ACE_Event::reset, signal_handler_, size, timer_queue_, wakeup_all_threads_, and ACE_WFMO_Reactor_Handler_Repository::~ACE_WFMO_Reactor_Handler_Repository.

Referenced by ACE_WFMO_Reactor.

01082 {
01083   ACE_UNUSED_ARG (unused);
01084   ACE_UNUSED_ARG (disable_notify_pipe);
01085 
01086   // This GUARD is necessary since we are updating shared state.
01087   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
01088 
01089   // If we are already open, return -1
01090   if (this->open_for_business_)
01091     return -1;
01092 
01093   // Timer Queue
01094   if (this->delete_timer_queue_)
01095     delete this->timer_queue_;
01096 
01097   if (tq == 0)
01098     {
01099       ACE_NEW_RETURN (this->timer_queue_,
01100                       ACE_Timer_Heap,
01101                       -1);
01102       this->delete_timer_queue_ = 1;
01103     }
01104   else
01105     {
01106       this->timer_queue_ = tq;
01107       this->delete_timer_queue_ = 0;
01108     }
01109 
01110   // Signal Handler
01111   if (this->delete_signal_handler_)
01112     delete this->signal_handler_;
01113 
01114   if (sh == 0)
01115     {
01116       ACE_NEW_RETURN (this->signal_handler_,
01117                       ACE_Sig_Handler,
01118                       -1);
01119       this->delete_signal_handler_ = 1;
01120     }
01121   else
01122     {
01123       this->signal_handler_ = sh;
01124       this->delete_signal_handler_ = 0;
01125     }
01126 
01127   // Setup the atomic wait array (used later in <handle_events>)
01128   this->atomic_wait_array_[0] = this->lock_.lock ().proc_mutex_;
01129   this->atomic_wait_array_[1] = this->ok_to_wait_.handle ();
01130 
01131   // This is to guard against reopens of WFMO_Reactor
01132   if (this->delete_handler_rep_)
01133     this->handler_rep_.~ACE_WFMO_Reactor_Handler_Repository ();
01134 
01135   // Open the handle repository.  Two additional handles for internal
01136   // purposes
01137   if (this->handler_rep_.open (size + 2) == -1)
01138     ACE_ERROR_RETURN ((LM_ERROR, ACE_LIB_TEXT ("%p\n"),
01139                        ACE_LIB_TEXT ("opening handler repository")),
01140                       -1);
01141   else
01142     this->delete_handler_rep_ = 1;
01143 
01144   this->notify_handler_ = notify;
01145 
01146   if (this->notify_handler_ == 0)
01147     {
01148       ACE_NEW_RETURN (this->notify_handler_,
01149                       ACE_WFMO_Reactor_Notify,
01150                       -1);
01151 
01152       if (this->notify_handler_ == 0)
01153         return -1;
01154       else
01155         this->delete_notify_handler_ = 1;
01156     }
01157 
01158   /* NOTE */
01159   // The order of the following two registrations is very important
01160 
01161   // Open the notification handler
01162   if (this->notify_handler_->open (this, this->timer_queue_) == -1)
01163     ACE_ERROR_RETURN ((LM_ERROR,
01164                        ACE_LIB_TEXT ("%p\n"),
01165                        ACE_LIB_TEXT ("opening notify handler ")),
01166                       -1);
01167 
01168   // Register for <wakeup_all_threads> event
01169   if (this->register_handler (&this->wakeup_all_threads_handler_,
01170                               this->wakeup_all_threads_.handle ()) == -1)
01171     ACE_ERROR_RETURN ((LM_ERROR,
01172                        ACE_LIB_TEXT ("%p\n"),
01173                        ACE_LIB_TEXT ("registering thread wakeup handler")),
01174                       -1);
01175 
01176   // Since we have added two handles into the handler repository,
01177   // update the <handler_repository_>
01178   if (this->handler_rep_.changes_required ())
01179     {
01180       // Make necessary changes to the handler repository
01181       this->handler_rep_.make_changes ();
01182       // Turn off <wakeup_all_threads_> since all necessary changes
01183       // have completed
01184       this->wakeup_all_threads_.reset ();
01185     }
01186 
01187   // We are open for business
01188   this->open_for_business_ = 1;
01189 
01190   return 0;
01191 }

ACE_WFMO_Reactor& ACE_WFMO_Reactor::operator= const ACE_WFMO_Reactor &    [private]
 

ACE_INLINE int ACE_WFMO_Reactor::owner ACE_thread_t   owner [virtual]
 

Return the ID of the "owner" thread.

Implements ACE_Reactor_Impl.

Definition at line 857 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_thread_t, and owner_i.

00858 {
00859   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00860   *t = this->owner_i ();
00861   return 0;
00862 }

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

Transfers ownership of the WFMO_Reactor to the <new_owner>. The transfer will not complete until all threads are ready (just like the handle set).

Implements ACE_Reactor_Impl.

Definition at line 871 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_thread_t, new_owner, new_owner_, owner_i, and wakeup_all_threads.

00872 {
00873   ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
00874   this->new_owner_ = new_owner;
00875 
00876   if (old_owner != 0)
00877     *old_owner = this->owner_i ();
00878 
00879   // Wake up all threads in WaitForMultipleObjects so that they can
00880   // reconsult the new owner responsibilities
00881   this->wakeup_all_threads ();
00882 
00883   return 0;
00884 }

ACE_INLINE ACE_thread_t ACE_WFMO_Reactor::owner_i void    [protected, virtual]
 

Return the ID of the "owner" thread. Does not do any locking.

Definition at line 865 of file WFMO_Reactor.i.

References owner_.

Referenced by ACE_WFMO_Reactor_Handler_Repository::current_info, ACE_WFMO_Reactor_Handler_Repository::handles, ACE_WFMO_Reactor_Handler_Repository::max_handlep1, owner, and ACE_WFMO_Reactor_Handler_Repository::scheduled_for_deletion.

00866 {
00867   return this->owner_;
00868 }

DWORD ACE_WFMO_Reactor::poll_remaining_handles DWORD    slot [protected, virtual]
 

Check for activity on remaining handles.

Reimplemented in ACE_Msg_WFMO_Reactor.

Definition at line 1731 of file WFMO_Reactor.cpp.

References handler_rep_, and ACE_WFMO_Reactor_Handler_Repository::handles.

Referenced by dispatch_handles.

01732 {
01733   return ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 () - slot,
01734                                    this->handler_rep_.handles () + slot,
01735                                    FALSE,
01736                                    0);
01737 }

int ACE_WFMO_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 2515 of file WFMO_Reactor.cpp.

References ACE_Reactor_Mask, ACE_TRACE, notify_handler_, and ACE_Reactor_Notify::purge_pending_notifications.

02517 {
02518   ACE_TRACE ("ACE_WFMO_Reactor::purge_pending_notifications");
02519   if (this->notify_handler_ == 0)
02520     return 0;
02521   else
02522     return this->notify_handler_->purge_pending_notifications (eh, mask);
02523 }

ACE_INLINE int ACE_WFMO_Reactor::ready_ops ACE_HANDLE    handle,
ACE_Reactor_Mask   ,
int    ops
[virtual]
 

Not implemented.

Implements ACE_Reactor_Impl.

Definition at line 1075 of file WFMO_Reactor.i.

References ACE_Reactor_Mask.

01078 {
01079   // Don't have an implementation for this yet...
01080   ACE_UNUSED_ARG (handle);
01081   ACE_UNUSED_ARG (ops);
01082   ACE_NOTSUP_RETURN (-1);
01083 }

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

Not implemented.

Implements ACE_Reactor_Impl.

Definition at line 1063 of file WFMO_Reactor.i.

References ACE_Reactor_Mask.

01066 {
01067   // Don't have an implementation for this yet...
01068   ACE_UNUSED_ARG (event_handler);
01069   ACE_UNUSED_ARG (mask);
01070   ACE_UNUSED_ARG (ops);
01071   ACE_NOTSUP_RETURN (-1);
01072 }

ACE_INLINE int ACE_WFMO_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 949 of file WFMO_Reactor.i.

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

00952 {
00953   int result = 0;
00954 
00955 #if (ACE_NSIG > 0)
00956   for (int s = 1; s < ACE_NSIG; s++)
00957     if (sigset.is_member (s)
00958         && this->signal_handler_->register_handler (s,
00959                                                     new_sh,
00960                                                     new_disp) == -1)
00961       result = -1;
00962 #else
00963   ACE_UNUSED_ARG (sigset);
00964   ACE_UNUSED_ARG (new_sh);
00965   ACE_UNUSED_ARG (new_disp);
00966 #endif /* ACE_NSIG */
00967 
00968   return result;
00969 }

ACE_INLINE int ACE_WFMO_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 937 of file WFMO_Reactor.i.

References ACE_Sig_Handler::register_handler, and signal_handler_.

00942 {
00943   return this->signal_handler_->register_handler (signum,
00944                                                   new_sh, new_disp,
00945                                                   old_sh, old_disp);
00946 }

ACE_INLINE int ACE_WFMO_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 546 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and register_handler_i.

00549 {
00550   // This GUARD is necessary since we are updating shared state.
00551   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00552 
00553   ACE_Handle_Set_Iterator handle_iter (handles);
00554   ACE_HANDLE h;
00555 
00556   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00557     if (this->register_handler_i (h,
00558                                   ACE_INVALID_HANDLE,
00559                                   handler,
00560                                   mask) == -1)
00561       return -1;
00562 
00563   return 0;
00564 }

ACE_INLINE int ACE_WFMO_Reactor::register_handler ACE_Event_Handler   event_handler,
ACE_Reactor_Mask    mask
[virtual]
 

This is a simple version of the above <register_handler> method where the I/O handle will always come from <get_handle> on the <Event_Handler> and the event handle will always be created by <WFMO_Reactor>

Implements ACE_Reactor_Impl.

Definition at line 504 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and register_handler_i.

00506 {
00507   // This GUARD is necessary since we are updating shared state.
00508   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00509 
00510   return this->register_handler_i (ACE_INVALID_HANDLE,
00511                                    ACE_INVALID_HANDLE,
00512                                    event_handler,
00513                                    mask);
00514 }

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

This is a simple version of the above <register_handler> method where the I/O handle is passed in and the event handle will always be created by <WFMO_Reactor>

Implements ACE_Reactor_Impl.

Definition at line 517 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and register_handler_i.

00520 {
00521   // This GUARD is necessary since we are updating shared state.
00522   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00523 
00524   return this->register_handler_i (ACE_INVALID_HANDLE,
00525                                    io_handle,
00526                                    event_handler,
00527                                    mask);
00528 }

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

Register an <ACE_Event_Handler> <event_handle>. <mask> specifies the network events that the <event_handler> is interested in. If <io_handle> == <ACE_INVALID_HANDLE> the <ACE_WFMO_Reactor> will call the <get_handle> method of <event_handler> to extract the underlying I/O handle. If the <event_handle> == <ACE_INVALID_HANDLE>, WFMO_Reactor will create an event for associating it with the I/O handle. When the <event_handle> is signalled, the appropriate <handle_*> callback will be invoked on the <Event_Handler>

Implements ACE_Reactor_Impl.

Definition at line 531 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and register_handler_i.

00535 {
00536   // This GUARD is necessary since we are updating shared state.
00537   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00538 
00539   return this->register_handler_i (event_handle,
00540                                    io_handle,
00541                                    event_handler,
00542                                    mask);
00543 }

ACE_INLINE int ACE_WFMO_Reactor::register_handler ACE_Event_Handler   event_handler,
ACE_HANDLE    event_handle = ACE_INVALID_HANDLE
[virtual]
 

Register an <ACE_Event_Handler> <event_handler>. Since no Event Mask is passed through this interface, it is assumed that the <handle> being passed in is an event handle and when the event becomes signaled, <WFMO_Reactor> will call handle_signal on <event_handler>. If <handle> == <ACE_INVALID_HANDLE> the <ACE_WFMO_Reactor> will call the <get_handle> method of <event_handler> to extract the underlying event handle.

Implements ACE_Reactor_Impl.

Definition at line 489 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_WFMO_Reactor_Handler_Repository::bind_i, and handler_rep_.

Referenced by open.

00491 {
00492   // This GUARD is necessary since we are updating shared state.
00493   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00494 
00495   return this->handler_rep_.bind_i (0,
00496                                     event_handler,
00497                                     0,
00498                                     ACE_INVALID_HANDLE,
00499                                     event_handle,
00500                                     0);
00501 }

int ACE_WFMO_Reactor::register_handler_i ACE_HANDLE    event_handle,
ACE_HANDLE    io_handle,
ACE_Event_Handler   event_handler,
ACE_Reactor_Mask    mask
[protected, virtual]
 

Registration workhorse.

Definition at line 1278 of file WFMO_Reactor.cpp.

References ACE_Reactor_Mask, ACE_Reactor::ADD_MASK, ACE_WFMO_Reactor_Handler_Repository::bind_i, ACE_Event_Handler::get_handle, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::invalid_handle, and ACE_WFMO_Reactor_Handler_Repository::modify_network_events_i.

Referenced by register_handler.

01282 {
01283   // If this is a Winsock 1 system, the underlying event assignment will
01284   // not work, so don't try. Winsock 1 must use ACE_Select_Reactor for
01285   // reacting to socket activity.
01286 #if !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0)
01287   ACE_UNUSED_ARG (event_handle);
01288   ACE_UNUSED_ARG (io_handle);
01289   ACE_UNUSED_ARG (event_handler);
01290   ACE_UNUSED_ARG (new_masks);
01291   ACE_NOTSUP_RETURN (-1);
01292 #else
01293 
01294   // Make sure that the <handle> is valid
01295   if (io_handle == ACE_INVALID_HANDLE)
01296     io_handle = event_handler->get_handle ();
01297 
01298   if (this->handler_rep_.invalid_handle (io_handle))
01299     {
01300       errno = ERROR_INVALID_HANDLE;
01301       return -1;
01302     }
01303 
01304   long new_network_events = 0;
01305   int delete_event = 0;
01306   auto_ptr <ACE_Auto_Event> event;
01307 
01308   // Look up the repository to see if the <event_handler> is already
01309   // there.
01310   ACE_Reactor_Mask old_masks;
01311   int found = this->handler_rep_.modify_network_events_i (io_handle,
01312                                                           new_masks,
01313                                                           old_masks,
01314                                                           new_network_events,
01315                                                           event_handle,
01316                                                           delete_event,
01317                                                           ACE_Reactor::ADD_MASK);
01318 
01319   // Check to see if the user passed us a valid event; If not then we
01320   // need to create one
01321   if (event_handle == ACE_INVALID_HANDLE)
01322     {
01323       // Note: don't change this since some C++ compilers have
01324       // <auto_ptr>s that don't work properly...
01325       auto_ptr<ACE_Auto_Event> tmp (new ACE_Auto_Event);
01326       event = tmp;
01327       event_handle = event->handle ();
01328       delete_event = 1;
01329     }
01330 
01331   int result = ::WSAEventSelect ((SOCKET) io_handle,
01332                                  event_handle,
01333                                  new_network_events);
01334   // If we had found the <Event_Handler> there is nothing more to do
01335   if (found)
01336     return result;
01337   else if (result != SOCKET_ERROR &&
01338            this->handler_rep_.bind_i (1,
01339                                       event_handler,
01340                                       new_network_events,
01341                                       io_handle,
01342                                       event_handle,
01343                                       delete_event) != -1)
01344     {
01345       // The <event_handler> was not found in the repository, add to
01346       // the repository.
01347       if (delete_event)
01348         {
01349           // Clear out the handle in the ACE_Auto_Event so that when
01350           // it is destroyed, the handle isn't closed out from under
01351           // the reactor. After setting it, running down the event
01352           // (via auto_ptr<> event, above) at function return will
01353           // cause an error because it'll try to close an invalid handle.
01354           // To avoid that smashing the errno value, save the errno
01355           // here, explicitly remove the event so the dtor won't do it
01356           // again, then restore errno.
01357           ACE_Errno_Guard guard (errno);
01358           event->handle (ACE_INVALID_HANDLE);
01359           event->remove ();
01360         }
01361       return 0;
01362     }
01363   else
01364     return -1;
01365 #endif /* ACE_HAS_PHARLAP */
01366 }

ACE_INLINE int ACE_WFMO_Reactor::remove_handler const ACE_Sig_Set   sigset [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 984 of file WFMO_Reactor.i.

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

00985 {
00986   int result = 0;
00987 
00988 #if (ACE_NSIG > 0)
00989   for (int s = 1; s < ACE_NSIG; s++)
00990     if (sigset.is_member (s)
00991         && this->signal_handler_->remove_handler (s) == -1)
00992       result = -1;
00993 #else
00994   ACE_UNUSED_ARG (sigset);
00995 #endif /* ACE_NSIG */
00996 
00997   return result;
00998 }

ACE_INLINE int ACE_WFMO_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>. <sigkey> is ignored in this implementation since there is only one instance of a signal handler. Install the new disposition (if given) and return the previous disposition (if desired by the caller). Returns 0 on success and -1 if <signum> is invalid.

Implements ACE_Reactor_Impl.

Definition at line 972 of file WFMO_Reactor.i.

References ACE_Sig_Handler::remove_handler, and signal_handler_.

00976 {
00977   return this->signal_handler_->remove_handler (signum,
00978                                                 new_disp,
00979                                                 old_disp,
00980                                                 sigkey);
00981 }

ACE_INLINE int ACE_WFMO_Reactor::remove_handler const ACE_Handle_Set   handle_set,
ACE_Reactor_Mask   
[virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 631 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::unbind_i, and wakeup_all_threads.

00633 {
00634   ACE_Handle_Set_Iterator handle_iter (handles);
00635   ACE_HANDLE h;
00636   int changes_required = 0;
00637 
00638   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00639 
00640   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00641     if (this->handler_rep_.unbind_i (h,
00642                                      mask,
00643                                      changes_required) == -1)
00644       return -1;
00645 
00646   // Wake up all threads in WaitForMultipleObjects so that they can
00647   // reconsult the handle set
00648   this->wakeup_all_threads ();
00649 
00650   return 0;
00651 }

ACE_INLINE int ACE_WFMO_Reactor::remove_handler ACE_HANDLE    handle,
ACE_Reactor_Mask    mask
[virtual]
 

Removes <handle> from the <ACE_WFMO_Reactor>. If <mask> == <ACE_Event_Handler::DONT_CALL> then the <handle_close> method of the <event_handler> is not invoked. Note that the <handle> can either be the <event_handle> or the <io_handle>

For the case of I/O entries, this removes the <mask> binding of <Event_Handler> whose handle is <handle> from <WFMO_Reactor>. If there are no more bindings for this <event_handler> then it is removed from the WFMO_Reactor. For simple event entries, mask is mostly ignored and the <Event_Handler> is always removed from <WFMO_Reactor>

Implements ACE_Reactor_Impl.

Definition at line 623 of file WFMO_Reactor.i.

References ACE_Reactor_Mask, handler_rep_, and ACE_WFMO_Reactor_Handler_Repository::unbind.

00625 {
00626   return this->handler_rep_.unbind (handle,
00627                                     mask);
00628 }

ACE_INLINE int ACE_WFMO_Reactor::remove_handler ACE_Event_Handler   event_handler,
ACE_Reactor_Mask    mask
[virtual]
 

Removes <event_handler> from the <ACE_WFMO_Reactor>. Note that the <ACE_WFMO_Reactor> will call the <get_handle> method of <event_handler> to extract the underlying handle. If <mask> == <ACE_Event_Handler::DONT_CALL> then the <handle_close> method of the <event_handler> is not invoked. Note that the <handle> can either be the <event_handle> or the <io_handle>

Implements ACE_Reactor_Impl.

Definition at line 615 of file WFMO_Reactor.i.

References ACE_Reactor_Mask, ACE_Event_Handler::get_handle, handler_rep_, and ACE_WFMO_Reactor_Handler_Repository::unbind.

00617 {
00618   return this->handler_rep_.unbind (event_handler->get_handle (),
00619                                     mask);
00620 }

ACE_INLINE int ACE_WFMO_Reactor::requeue_position void    [virtual]
 

Not implemented.

Implements ACE_Reactor_Impl.

Definition at line 1044 of file WFMO_Reactor.i.

01045 {
01046   // Don't have an implementation for this yet...
01047   ACE_NOTSUP_RETURN (-1);
01048 }

ACE_INLINE void ACE_WFMO_Reactor::requeue_position int    [virtual]
 

Not implemented.

Implements ACE_Reactor_Impl.

Definition at line 1038 of file WFMO_Reactor.i.

01039 {
01040   // Not implemented
01041 }

ACE_INLINE int ACE_WFMO_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 436 of file WFMO_Reactor.i.

References ACE_TRACE.

00438 {
00439   ACE_TRACE ("ACE_WFMO_Reactor::reset_timer_interval");
00440 
00441   long result = this->timer_queue_->reset_interval
00442     (timer_id,
00443      interval);
00444 
00445   // Wakeup the owner thread so that it gets the latest timer values
00446   this->notify ();
00447 
00448   return result;
00449 }

ACE_INLINE int ACE_WFMO_Reactor::restart int    r [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 1057 of file WFMO_Reactor.i.

01058 {
01059   return 0;
01060 }

ACE_INLINE int ACE_WFMO_Reactor::restart void    [virtual]
 

Get the existing restart value.

Implements ACE_Reactor_Impl.

Definition at line 1051 of file WFMO_Reactor.i.

01052 {
01053   return 0;
01054 }

int ACE_WFMO_Reactor::resumable_handler void    [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 2526 of file WFMO_Reactor.cpp.

References ACE_TRACE.

02527 {
02528   ACE_TRACE ("ACE_WFMO_Reactor::resumable_handler");
02529   return 0;
02530 }

ACE_INLINE int ACE_WFMO_Reactor::resume_handler const ACE_Handle_Set   handles [virtual]
 

Resume all <handles> in handle set.

Implements ACE_Reactor_Impl.

Definition at line 758 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::resume_handler_i, and wakeup_all_threads.

00759 {
00760   ACE_Handle_Set_Iterator handle_iter (handles);
00761   ACE_HANDLE h;
00762   int changes_required = 0;
00763 
00764   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00765 
00766   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00767     if (this->handler_rep_.resume_handler_i (h,
00768                                              changes_required) == -1)
00769       return -1;
00770 
00771   // Wake up all threads in WaitForMultipleObjects so that they can
00772   // reconsult the handle set
00773   this->wakeup_all_threads ();
00774 
00775   return 0;
00776 }

ACE_INLINE int ACE_WFMO_Reactor::resume_handler ACE_HANDLE    handle [virtual]
 

Resume <handle>.

Implements ACE_Reactor_Impl.

Definition at line 734 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::resume_handler_i, and wakeup_all_threads.

00735 {
00736   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00737 
00738   int changes_required = 0;
00739   int result =
00740     this->handler_rep_.resume_handler_i (handle,
00741                                          changes_required);
00742 
00743   if (changes_required)
00744     // Wake up all threads in WaitForMultipleObjects so that they can
00745     // reconsult the handle set
00746     this->wakeup_all_threads ();
00747 
00748   return result;
00749 }

ACE_INLINE int ACE_WFMO_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 752 of file WFMO_Reactor.i.

References ACE_Event_Handler::get_handle.

00753 {
00754   return this->resume_handler (event_handler->get_handle ());
00755 }

ACE_INLINE int ACE_WFMO_Reactor::resume_handlers void    [virtual]
 

Resume all <handles>.

Implements ACE_Reactor_Impl.

Definition at line 779 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::handles_to_be_added_, ACE_WFMO_Reactor_Handler_Repository::resume_handler_i, ACE_WFMO_Reactor_Handler_Repository::suspended_handles_, ACE_WFMO_Reactor_Handler_Repository::to_be_added_info_, and wakeup_all_threads.

00780 {
00781   int error = 0;
00782   int result = 0;
00783   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00784 
00785   int changes_required = 0;
00786   for (size_t i = 0;
00787        i < this->handler_rep_.suspended_handles_ && error == 0;
00788        i++)
00789     {
00790       result =
00791         this->handler_rep_.resume_handler_i (this->handler_rep_.current_suspended_info_[i].event_handle_,
00792                                              changes_required);
00793       if (result == -1)
00794         error = 1;
00795     }
00796 
00797   if (!error)
00798     // Then resume all to_be_added_handles
00799     for (size_t i = 0;
00800          i < this->handler_rep_.handles_to_be_added_;
00801          i++)
00802       this->handler_rep_.to_be_added_info_[i].suspend_entry_ = 0;
00803 
00804   // Wake up all threads in WaitForMultipleObjects so that they can
00805   // reconsult the handle set
00806   this->wakeup_all_threads ();
00807 
00808   return error ? -1 : 0;
00809 }

ACE_INLINE int ACE_WFMO_Reactor::safe_dispatch DWORD    wait_status [protected, virtual]
 

Protect against structured exceptions caused by user code when dispatching handles.

Definition at line 901 of file WFMO_Reactor.i.

References ACE_SEH_FINALLY, ACE_SEH_TRY, dispatch, and update_state.

Referenced by event_handling.

00902 {
00903   int result = -1;
00904   ACE_SEH_TRY
00905     {
00906       result = this->dispatch (wait_status);
00907     }
00908   ACE_SEH_FINALLY
00909     {
00910       this->update_state ();
00911     }
00912 
00913   return result;
00914 }

ACE_INLINE long ACE_WFMO_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 452 of file WFMO_Reactor.i.

References ACE_TRACE, ACE_Timer_Queue_T< ACE_Event_Handler *, ACE_Event_Handler_Handle_Timeout_Upcall< ACE_SYNCH_RECURSIVE_MUTEX >, ACE_SYNCH_RECURSIVE_MUTEX >::gettimeofday, notify, 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_.

00456 {
00457   ACE_TRACE ("ACE_WFMO_Reactor::schedule_timer");
00458 
00459   long result = this->timer_queue_->schedule
00460     (handler,
00461      arg,
00462      timer_queue_->gettimeofday () + delay_time,
00463      interval);
00464 
00465   // Wakeup the owner thread so that it gets the latest timer values
00466   this->notify ();
00467 
00468   return result;
00469 }

ACE_INLINE int ACE_WFMO_Reactor::schedule_wakeup ACE_HANDLE    handle,
ACE_Reactor_Mask    masks_to_be_added
[virtual]
 

Add <masks_to_be_added> to the <handle>'s entry in WFMO_Reactor. The Event_Handler associated with <handle> must already have been registered with WFMO_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 567 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_Reactor::ADD_MASK, and mask_ops_i.

00569 {
00570   // This GUARD is necessary since we are updating shared state.
00571   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00572 
00573   return this->mask_ops_i (io_handle,
00574                            masks_to_be_added,
00575                            ACE_Reactor::ADD_MASK);
00576 }

ACE_INLINE int ACE_WFMO_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 in WFMO_Reactor. <event_handler> must already have been registered with WFMO_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 579 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_Reactor::ADD_MASK, ACE_Event_Handler::get_handle, and mask_ops_i.

00581 {
00582   // This GUARD is necessary since we are updating shared state.
00583   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00584 
00585   return this->mask_ops_i (event_handler->get_handle (),
00586                            masks_to_be_added,
00587                            ACE_Reactor::ADD_MASK);
00588 }

int ACE_WFMO_Reactor::set_sig_handler ACE_Sig_Handler   signal_handler [virtual]
 

Use a user specified signal handler instead.

Implements ACE_Reactor_Impl.

Definition at line 1194 of file WFMO_Reactor.cpp.

References delete_signal_handler_, and signal_handler_.

01195 {
01196   if (this->signal_handler_ != 0 && this->delete_signal_handler_ != 0)
01197     delete this->signal_handler_;
01198   this->signal_handler_ = signal_handler;
01199   this->delete_signal_handler_ = 0;
01200   return 0;
01201 }

int ACE_WFMO_Reactor::set_timer_queue ACE_Timer_Queue   tq [virtual]
 

Deprecated:
The following method is deprecated. Instead, either specify a timer queue when creating/opening the object or use the timer_queue() method.

Implements ACE_Reactor_Impl.

Definition at line 1220 of file WFMO_Reactor.cpp.

References timer_queue.

01221 {
01222   return this->timer_queue (tq);
01223 }

int ACE_WFMO_Reactor::simple_dispatch_handler DWORD    slot,
ACE_HANDLE    event_handle
[protected, virtual]
 

Dispatches a single handler. Returns 0 on success, -1 if the handler was removed.

Definition at line 1894 of file WFMO_Reactor.cpp.

References ACE_WFMO_Reactor_Handler_Repository::current_info, ACE_Event_Handler::handle_signal, handler_rep_, ACE_Event_Handler::NULL_MASK, and ACE_WFMO_Reactor_Handler_Repository::unbind.

Referenced by dispatch_handler.

01896 {
01897   // This dispatch is used for non-I/O entires
01898 
01899   // Assign the ``signaled'' HANDLE so that callers can get it.
01900   // siginfo_t is an ACE - specific fabrication. Constructor exists.
01901   siginfo_t sig (event_handle);
01902 
01903   ACE_Event_Handler *eh =
01904     this->handler_rep_.current_info ()[slot].event_handler_;
01905 
01906   // Upcall
01907   if (eh->handle_signal (0, &sig) == -1)
01908     this->handler_rep_.unbind (event_handle,
01909                                ACE_Event_Handler::NULL_MASK);
01910 
01911   return 0;
01912 }

ACE_INLINE size_t ACE_WFMO_Reactor::size void    const [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 1108 of file WFMO_Reactor.i.

References handler_rep_, and ACE_WFMO_Reactor_Handler_Repository::max_size_.

Referenced by ACE_WFMO_Reactor, and open.

01109 {
01110   // Size of repository minus the 2 used for internal purposes
01111   return this->handler_rep_.max_size_ - 2;
01112 }

ACE_INLINE int ACE_WFMO_Reactor::suspend_handler const ACE_Handle_Set   handles [virtual]
 

Suspend all <handles> in handle set temporarily.

Implements ACE_Reactor_Impl.

Definition at line 678 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i, and wakeup_all_threads.

00679 {
00680   ACE_Handle_Set_Iterator handle_iter (handles);
00681   ACE_HANDLE h;
00682   int changes_required = 0;
00683 
00684   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00685 
00686   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00687     if (this->handler_rep_.suspend_handler_i (h,
00688                                               changes_required) == -1)
00689       return -1;
00690 
00691   // Wake up all threads in WaitForMultipleObjects so that they can
00692   // reconsult the handle set
00693   this->wakeup_all_threads ();
00694 
00695   return 0;
00696 }

ACE_INLINE int ACE_WFMO_Reactor::suspend_handler ACE_HANDLE    handle [virtual]
 

Suspend <handle> temporarily.

Implements ACE_Reactor_Impl.

Definition at line 654 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i, and wakeup_all_threads.

00655 {
00656   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00657 
00658   int changes_required = 0;
00659   int result =
00660     this->handler_rep_.suspend_handler_i (handle,
00661                                           changes_required);
00662 
00663   if (changes_required)
00664     // Wake up all threads in WaitForMultipleObjects so that they can
00665     // reconsult the handle set
00666     this->wakeup_all_threads ();
00667 
00668   return result;
00669 }

ACE_INLINE int ACE_WFMO_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 672 of file WFMO_Reactor.i.

References ACE_Event_Handler::get_handle.

00673 {
00674   return this->suspend_handler (event_handler->get_handle ());
00675 }

ACE_INLINE int ACE_WFMO_Reactor::suspend_handlers void    [virtual]
 

Suspend all <handles> temporarily.

Implements ACE_Reactor_Impl.

Definition at line 699 of file WFMO_Reactor.i.

References ACE_GUARD_RETURN, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::handles_to_be_added_, ACE_WFMO_Reactor_Handler_Repository::max_handlep1_, ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i, ACE_WFMO_Reactor_Handler_Repository::to_be_added_info_, and wakeup_all_threads.

00700 {
00701   int error = 0;
00702   int result = 0;
00703   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00704 
00705   // First suspend all current handles
00706   int changes_required = 0;
00707 
00708   for (size_t i = 0;
00709        i < this->handler_rep_.max_handlep1_ && error == 0;
00710        i++)
00711     {
00712       result =
00713         this->handler_rep_.suspend_handler_i (this->handler_rep_.current_handles_[i],
00714                                               changes_required);
00715       if (result == -1)
00716         error = 1;
00717     }
00718 
00719   if (!error)
00720     // Then suspend all to_be_added_handles
00721     for (size_t i = 0;
00722          i < this->handler_rep_.handles_to_be_added_;
00723          i++)
00724       this->handler_rep_.to_be_added_info_[i].suspend_entry_ = 1;
00725 
00726   // Wake up all threads in WaitForMultipleObjects so that they can
00727   // reconsult the handle set
00728   this->wakeup_all_threads ();
00729 
00730   return error ? -1 : 0;
00731 }

ACE_Timer_Queue * ACE_WFMO_Reactor::timer_queue void    const [virtual]
 

Return the current ACE_Timer_Queue.

Implements ACE_Reactor_Impl.

Definition at line 1204 of file WFMO_Reactor.cpp.

References timer_queue_.

Referenced by set_timer_queue.

01205 {
01206   return this->timer_queue_;
01207 }

int ACE_WFMO_Reactor::timer_queue ACE_Timer_Queue   tq [virtual]
 

Set a user-specified timer queue.

Implements ACE_Reactor_Impl.

Definition at line 1210 of file WFMO_Reactor.cpp.

References delete_timer_queue_, and timer_queue_.

01211 {
01212   if (this->timer_queue_ != 0 && this->delete_timer_queue_ != 0)
01213     delete this->timer_queue_;
01214   this->timer_queue_ = tq;
01215   this->delete_timer_queue_ = 0;
01216   return 0;
01217 }

ACE_Reactor_Mask ACE_WFMO_Reactor::upcall ACE_Event_Handler   event_handler,
ACE_HANDLE    io_handle,
WSANETWORKEVENTS   events
[protected, virtual]
 

Definition at line 1962 of file WFMO_Reactor.cpp.

References ACE_Event_Handler::ACCEPT_MASK, ACE_BIT_DISABLED, ACE_BIT_ENABLED, ACE_CLR_BITS, ACE_Reactor_Mask, ACE_SET_BITS, ACE_Event_Handler::CONNECT_MASK, ACE_Event_Handler::EXCEPT_MASK, FD_CONNECT_BIT, FD_GROUP_QOS, FD_QOS, ACE_Event_Handler::GROUP_QOS_MASK, ACE_Event_Handler::handle_exception, ACE_Event_Handler::handle_group_qos, ACE_Event_Handler::handle_input, ACE_Event_Handler::handle_output, ACE_Event_Handler::handle_qos, _WSANETWORKEVENTS::iErrorCode, _WSANETWORKEVENTS::lNetworkEvents, ACE_Event_Handler::NULL_MASK, ACE_Event_Handler::QOS_MASK, ACE_Event_Handler::READ_MASK, and ACE_Event_Handler::WRITE_MASK.

Referenced by complex_dispatch_handler.

01965 {
01966   // This method figures out what exactly has happened to the socket
01967   // and then calls appropriate methods.
01968   ACE_Reactor_Mask problems = ACE_Event_Handler::NULL_MASK;
01969 
01970   // Go through the events and do the indicated upcalls. If the handler
01971   // doesn't want to be called back, clear the bit for that event.
01972   // At the end, set the bits back to <events> to request a repeat call.
01973 
01974   long actual_events = events.lNetworkEvents;
01975   int action;
01976 
01977   if (ACE_BIT_ENABLED (actual_events, FD_WRITE))
01978     {
01979       action = event_handler->handle_output (io_handle);
01980       if (action <= 0)
01981         {
01982           ACE_CLR_BITS (actual_events, FD_WRITE);
01983           if (action == -1)
01984             ACE_SET_BITS (problems, ACE_Event_Handler::WRITE_MASK);
01985         }
01986     }
01987 
01988   if (ACE_BIT_ENABLED (actual_events, FD_CONNECT))
01989     {
01990       if (events.iErrorCode[FD_CONNECT_BIT] == 0)
01991         {
01992           // Successful connect
01993           action = event_handler->handle_output (io_handle);
01994           if (action <= 0)
01995             {
01996               ACE_CLR_BITS (actual_events, FD_CONNECT);
01997               if (action == -1)
01998                 ACE_SET_BITS (problems,
01999                               ACE_Event_Handler::CONNECT_MASK);
02000             }
02001         }
02002       // Unsuccessful connect
02003       else
02004         {
02005           action = event_handler->handle_input (io_handle);
02006           if (action <= 0)
02007             {
02008               ACE_CLR_BITS (actual_events, FD_CONNECT);
02009               if (action == -1)
02010                 ACE_SET_BITS (problems,
02011                               ACE_Event_Handler::CONNECT_MASK);
02012             }
02013         }
02014     }
02015 
02016   if (ACE_BIT_ENABLED (actual_events, FD_OOB))
02017     {
02018       action = event_handler->handle_exception (io_handle);
02019       if (action <= 0)
02020         {
02021           ACE_CLR_BITS (actual_events, FD_OOB);
02022           if (action == -1)
02023             ACE_SET_BITS (problems, ACE_Event_Handler::EXCEPT_MASK);
02024         }
02025     }
02026 
02027   if (ACE_BIT_ENABLED (actual_events, FD_READ))
02028     {
02029       action = event_handler->handle_input (io_handle);
02030       if (action <= 0)
02031         {
02032           ACE_CLR_BITS (actual_events, FD_READ);
02033           if (action == -1)
02034             ACE_SET_BITS (problems, ACE_Event_Handler::READ_MASK);
02035         }
02036     }
02037 
02038   if (ACE_BIT_ENABLED (actual_events, FD_CLOSE)
02039       && ACE_BIT_DISABLED (problems, ACE_Event_Handler::READ_MASK))
02040     {
02041       action = event_handler->handle_input (io_handle);
02042       if (action <= 0)
02043         {
02044           ACE_CLR_BITS (actual_events, FD_CLOSE);
02045           if (action == -1)
02046             ACE_SET_BITS (problems, ACE_Event_Handler::READ_MASK);
02047         }
02048     }
02049 
02050   if (ACE_BIT_ENABLED (actual_events, FD_ACCEPT))
02051     {
02052       action = event_handler->handle_input (io_handle);
02053       if (action <= 0)
02054         {
02055           ACE_CLR_BITS (actual_events, FD_ACCEPT);
02056           if (action == -1)
02057             ACE_SET_BITS (problems, ACE_Event_Handler::ACCEPT_MASK);
02058         }
02059     }
02060 
02061   if (ACE_BIT_ENABLED (actual_events, FD_QOS))
02062     {
02063       action = event_handler->handle_qos (io_handle);
02064       if (action <= 0)
02065         {
02066           ACE_CLR_BITS (actual_events, FD_QOS);
02067           if (action == -1)
02068             ACE_SET_BITS (problems, ACE_Event_Handler::QOS_MASK);
02069         }
02070     }
02071 
02072   if (ACE_BIT_ENABLED (actual_events, FD_GROUP_QOS))
02073     {
02074       action = event_handler->handle_group_qos (io_handle);
02075       if (action <= 0)
02076         {
02077           ACE_CLR_BITS (actual_events, FD_GROUP_QOS);
02078           if (action == -1)
02079             ACE_SET_BITS (problems, ACE_Event_Handler::GROUP_QOS_MASK);
02080         }
02081     }
02082 
02083   events.lNetworkEvents = actual_events;
02084   return problems;
02085 }

int ACE_WFMO_Reactor::update_state void    [protected, virtual]
 

Update the state of the handler repository.

Definition at line 2089 of file WFMO_Reactor.cpp.

References ACE_GUARD_RETURN, active_threads_, change_owner, change_state_thread_, ACE_WFMO_Reactor_Handler_Repository::changes_required, handler_rep_, ACE_WFMO_Reactor_Handler_Repository::make_changes, new_owner, ok_to_wait_, ACE_Event::reset, ACE_Thread::self, ACE_Event::signal, ACE_Event::wait, waiting_to_change_state_, and wakeup_all_threads_.

Referenced by safe_dispatch.

02090 {
02091   // This GUARD is necessary since we are updating shared state.
02092   ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
02093 
02094   // Decrement active threads
02095   this->active_threads_--;
02096 
02097   // Check if the state of the handler repository has changed or new
02098   // owner has to be set
02099   if (this->handler_rep_.changes_required () || this->new_owner ())
02100     {
02101       if (this->change_state_thread_ == 0)
02102         // Try to become the thread which will be responsible for the
02103         // changes
02104         {
02105           this->change_state_thread_ = ACE_Thread::self ();
02106           // Make sure no new threads are allowed to enter
02107           this->ok_to_wait_.reset ();
02108 
02109           if (this->active_threads_ > 0)
02110             // Check for other active threads
02111             {
02112               // Wake up all other threads
02113               this->wakeup_all_threads_.signal ();
02114               // Release <lock_>
02115               monitor.release ();
02116               // Go to sleep waiting for all other threads to get done
02117               this->waiting_to_change_state_.wait ();
02118               // Re-acquire <lock_> again
02119               monitor.acquire ();
02120             }
02121 
02122           // Note that make_changes() calls into user code which can
02123           // request other changes.  So keep looping until all
02124           // requested changes are completed.
02125           while (this->handler_rep_.changes_required ())
02126             // Make necessary changes to the handler repository
02127             this->handler_rep_.make_changes ();
02128           if (this->new_owner ())
02129             // Update the owner
02130             this->change_owner ();
02131           // Turn off <wakeup_all_threads_>
02132           this->wakeup_all_threads_.reset ();
02133           // Let everyone know that it is ok to go ahead
02134           this->ok_to_wait_.signal ();
02135           // Reset this flag
02136           this->change_state_thread_ = 0;
02137         }
02138       else if (this->active_threads_ == 0)
02139         // This thread did not get a chance to become the change
02140         // thread. If it is the last one out, it will wakeup the
02141         // change thread
02142         this->waiting_to_change_state_.signal ();
02143     }
02144   // This is if we were woken up explicitily by the user and there are
02145   // no state changes required.
02146   else if (this->active_threads_ == 0)
02147     // Turn off <wakeup_all_threads_>
02148     this->wakeup_all_threads_.reset ();
02149 
02150   return 0;
02151 }

ACE_INLINE int ACE_WFMO_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. Since the WFMO_Reactor does use event associations, this function always return 1.

Implements ACE_Reactor_Impl.

Definition at line 812 of file WFMO_Reactor.i.

00813 {
00814   // Since the WFMO_Reactor does use event associations, this function
00815   // always return 1.
00816   return 1;
00817 }

DWORD ACE_WFMO_Reactor::wait_for_multiple_events int    timeout,
int    alertable
[protected, virtual]
 

Wait for timer and I/O events to occur.

Reimplemented in ACE_Msg_WFMO_Reactor.

Definition at line 1706 of file WFMO_Reactor.cpp.

References handler_rep_, and ACE_WFMO_Reactor_Handler_Repository::handles.

Referenced by event_handling.

01708 {
01709   // Wait for any of handles_ to be active, or until timeout expires.
01710   // If <alertable> is enabled allow asynchronous completion of
01711   // ReadFile and WriteFile operations.
01712 
01713 #if defined (ACE_HAS_PHARLAP) || defined (ACE_HAS_WINCE)
01714   // PharLap doesn't do async I/O and doesn't implement
01715   // WaitForMultipleObjectsEx, so use WaitForMultipleObjects.
01716   ACE_UNUSED_ARG (alertable);
01717   return ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 (),
01718                                    this->handler_rep_.handles (),
01719                                    FALSE,
01720                                    timeout);
01721 #else
01722   return ::WaitForMultipleObjectsEx (this->handler_rep_.max_handlep1 (),
01723                                      this->handler_rep_.handles (),
01724                                      FALSE,
01725                                      timeout,
01726                                      alertable);
01727 #endif /* ACE_HAS_PHARLAP */
01728 }

ACE_INLINE void ACE_WFMO_Reactor::wakeup_all_threads void    [virtual]
 

Wake up all threads in WaitForMultipleObjects so that they can reconsult the handle set.

Implements ACE_Reactor_Impl.

Definition at line 923 of file WFMO_Reactor.i.

References ACE_Event::signal, and wakeup_all_threads_.

Referenced by ACE_WFMO_Reactor_Handler_Repository::bind_i, deactivate, owner, remove_handler, resume_handler, resume_handlers, suspend_handler, suspend_handlers, ACE_WFMO_Reactor_Handler_Repository::unbind, and ACE_WFMO_Reactor_Handler_Repository::unbind_all.

00924 {
00925   this->wakeup_all_threads_.signal ();
00926 }

int ACE_WFMO_Reactor::work_pending const ACE_Time_Value   max_wait_time = ACE_Time_Value::zero [virtual]
 

This method is not currently implemented. We recommend that you use handle_events (ACE_Time_Value::zero) to get basically the same effect, i.e., it won't block the caller if there are no events.

Implements ACE_Reactor_Impl.

Definition at line 1000 of file WFMO_Reactor.cpp.

01001 {
01002   ACE_NOTSUP_RETURN (-1);
01003 }


Friends And Related Function Documentation

friend class ACE_WFMO_Reactor_Handler_Repository [friend]
 

Definition at line 625 of file WFMO_Reactor.h.

friend class ACE_WFMO_Reactor_Test [friend]
 

Definition at line 626 of file WFMO_Reactor.h.


Member Data Documentation

ACE_WFMO_Reactor::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Reactor_Impl.

Definition at line 1146 of file WFMO_Reactor.h.

size_t ACE_WFMO_Reactor::active_threads_ [protected]
 

Count of currently active threads.

Definition at line 1292 of file WFMO_Reactor.h.

Referenced by event_handling, and update_state.

ACE_HANDLE ACE_WFMO_Reactor::atomic_wait_array_[2] [protected]
 

This is an array of ACE_HANDLEs which keep track of the <lock_> and <ok_to_wait_> handles.

Definition at line 1313 of file WFMO_Reactor.h.

Referenced by ok_to_wait, and open.

ACE_thread_t ACE_WFMO_Reactor::change_state_thread_ [protected]
 

This is the thread which is responsible for the changing the state of the <WFMO_Reactor> handle set.

Definition at line 1309 of file WFMO_Reactor.h.

Referenced by update_state.

sig_atomic_t ACE_WFMO_Reactor::deactivated_ [protected]
 

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

Definition at line 1320 of file WFMO_Reactor.h.

Referenced by deactivate, deactivated, and event_handling.

int ACE_WFMO_Reactor::delete_handler_rep_ [protected]
 

Keeps track of whether we should delete the handler repository.

Definition at line 1248 of file WFMO_Reactor.h.

Referenced by open.

int ACE_WFMO_Reactor::delete_notify_handler_ [protected]
 

Keeps track of whether we should delete the notify handler.

Definition at line 1254 of file WFMO_Reactor.h.

Referenced by open, and ~ACE_WFMO_Reactor.

int ACE_WFMO_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 1238 of file WFMO_Reactor.h.

Referenced by open, set_sig_handler, and ~ACE_WFMO_Reactor.

int ACE_WFMO_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 1245 of file WFMO_Reactor.h.

Referenced by open, timer_queue, and ~ACE_WFMO_Reactor.

ACE_WFMO_Reactor_Handler_Repository ACE_WFMO_Reactor::handler_rep_ [protected]
 

Table that maps <ACE_HANDLEs> to <ACE_Event_Handler *>'s.

Definition at line 1271 of file WFMO_Reactor.h.

Referenced by close, complex_dispatch_handler, dispatch_handler, dispatch_handles, dump, handler, mask_ops_i, open, poll_remaining_handles, ACE_Msg_WFMO_Reactor::poll_remaining_handles, register_handler, register_handler_i, remove_handler, resume_handler, resume_handlers, simple_dispatch_handler, size, suspend_handler, suspend_handlers, update_state, wait_for_multiple_events, ACE_Msg_WFMO_Reactor::wait_for_multiple_events, and ~ACE_WFMO_Reactor.

ACE_Process_Mutex ACE_WFMO_Reactor::lock_ [protected]
 

Synchronization for the ACE_WFMO_Reactor.

A Process Mutex is used here because of two reasons: (a) The implementation of ACE_Thread_Mutex uses CriticalSections CriticalSections are not waitable using WaitForMultipleObjects (b) This is really not a process mutex because it is not named. No other process can use this mutex.

Definition at line 1265 of file WFMO_Reactor.h.

Referenced by event_handling, and open.

ACE_Lock_Adapter<ACE_Process_Mutex> ACE_WFMO_Reactor::lock_adapter_ [protected]
 

Adapter used to return internal lock to outside world.

Definition at line 1268 of file WFMO_Reactor.h.

Referenced by lock.

ACE_thread_t ACE_WFMO_Reactor::new_owner_ [protected]
 

The owner to be of the WFMO_Reactor.

Definition at line 1305 of file WFMO_Reactor.h.

Referenced by change_owner, new_owner, and owner.

ACE_Reactor_Notify* ACE_WFMO_Reactor::notify_handler_ [protected]
 

Used when <notify> is called.

Definition at line 1251 of file WFMO_Reactor.h.

Referenced by max_notify_iterations, notify, open, purge_pending_notifications, and ~ACE_WFMO_Reactor.

ACE_Manual_Event ACE_WFMO_Reactor::ok_to_wait_ [protected]
 

A manual event used to block threads from proceeding into WaitForMultipleObjects.

Definition at line 1275 of file WFMO_Reactor.h.

Referenced by open, and update_state.

int ACE_WFMO_Reactor::open_for_business_ [protected]
 

This flag is used to keep track of whether we are already closed.

Definition at line 1316 of file WFMO_Reactor.h.

Referenced by close, event_handling, initialized, and open.

ACE_thread_t ACE_WFMO_Reactor::owner_ [protected]
 

The thread which is "owner" of the WFMO_Reactor. The owner concept is used because we don't want multiple threads to try to expire timers. Therefore the "owner" thread is the only one allowed to expire timers. Also, the owner thread is the only thread which waits on the notify handle. Note that the ownership can be transferred.

Definition at line 1302 of file WFMO_Reactor.h.

Referenced by calculate_timeout, change_owner, expire_timers, and owner_i.

ACE_Sig_Handler* ACE_WFMO_Reactor::signal_handler_ [protected]
 

Handle signals without requiring global/static variables.

Definition at line 1234 of file WFMO_Reactor.h.

Referenced by dump, handler, open, register_handler, remove_handler, set_sig_handler, and ~ACE_WFMO_Reactor.

ACE_Timer_Queue* ACE_WFMO_Reactor::timer_queue_ [protected]
 

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

Definition at line 1241 of file WFMO_Reactor.h.

Referenced by calculate_timeout, cancel_timer, dump, expire_timers, open, schedule_timer, timer_queue, and ~ACE_WFMO_Reactor.

ACE_Auto_Event ACE_WFMO_Reactor::waiting_to_change_state_ [protected]
 

The changing thread waits on this event, till all threads are not active anymore.

Definition at line 1289 of file WFMO_Reactor.h.

Referenced by update_state.

ACE_Manual_Event ACE_WFMO_Reactor::wakeup_all_threads_ [protected]
 

A manual event is used so that we can wake everyone up (e.g., when <ACE_Event_Handlers> are bounded and unbound from the handler repository).

Definition at line 1282 of file WFMO_Reactor.h.

Referenced by open, update_state, and wakeup_all_threads.

ACE_Wakeup_All_Threads_Handler ACE_WFMO_Reactor::wakeup_all_threads_handler_ [protected]
 

Used when <wakeup_all_threads_> is signaled.

Definition at line 1285 of file WFMO_Reactor.h.


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