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 Member Functions

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

 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);.

virtual int set_sig_handler (ACE_Sig_Handler *signal_handler)
 Use a user specified signal handler instead.

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

virtual ACE_Timer_Queuetimer_queue (void) const
 Return the current ACE_Timer_Queue.

virtual int close (void)
 Close down the ACE_WFMO_Reactor and release all of its resources.

virtual ~ACE_WFMO_Reactor (void)
 Close down the ACE_WFMO_Reactor and release all of its resources.

virtual int work_pending (const ACE_Time_Value &max_wait_time=ACE_Time_Value::zero)
virtual int handle_events (ACE_Time_Value *max_wait_time=0)
virtual int alertable_handle_events (ACE_Time_Value *max_wait_time=0)
virtual int handle_events (ACE_Time_Value &max_wait_time)
virtual int alertable_handle_events (ACE_Time_Value &max_wait_time)
virtual int deactivated (void)
virtual void deactivate (int do_stop)
virtual int register_handler (ACE_Event_Handler *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)
virtual int register_handler (int signum, ACE_Event_Handler *new_sh, ACE_Sig_Action *new_disp=0, ACE_Event_Handler **old_sh=0, ACE_Sig_Action *old_disp=0)
virtual int register_handler (const ACE_Sig_Set &sigset, ACE_Event_Handler *new_sh, ACE_Sig_Action *new_disp=0)
virtual int remove_handler (ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask)
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 for every signal in .

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

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

virtual int suspend_handlers (void)
 Suspend all temporarily.

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

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

virtual int resume_handlers (void)
 Resume all .

virtual int resumable_handler (void)
virtual int uses_event_associations (void)
virtual long schedule_timer (ACE_Event_Handler *event_handler, const void *arg, const ACE_Time_Value &delay, const ACE_Time_Value &interval=ACE_Time_Value::zero)
virtual int reset_timer_interval (long timer_id, const ACE_Time_Value &interval)
virtual int cancel_timer (ACE_Event_Handler *event_handler, int dont_call_handle_close=1)
virtual int cancel_timer (long timer_id, const void **arg=0, int dont_call_handle_close=1)
virtual int schedule_wakeup (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks_to_be_added)
virtual int schedule_wakeup (ACE_HANDLE handle, ACE_Reactor_Mask masks_to_be_added)
virtual int cancel_wakeup (ACE_Event_Handler *event_handler, ACE_Reactor_Mask masks_to_be_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)
ACE_Event_Handlerfind_handler (ACE_HANDLE handle)
virtual int handler (ACE_HANDLE handle, ACE_Reactor_Mask mask, ACE_Event_Handler **event_handler=0)
virtual int handler (int signum, ACE_Event_Handler **=0)
virtual int initialized (void)
virtual size_t size (void) const
virtual ACE_Locklock (void)
 Returns a reference to the WFMO_Reactor's internal lock.

virtual void wakeup_all_threads (void)
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.

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

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

virtual void requeue_position (int)
 Not implemented.

virtual int requeue_position (void)
 Not implemented.

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.

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

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


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Member Functions

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

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

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

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

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

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

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

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

virtual int safe_dispatch (DWORD wait_status)
virtual int dispatch_handles (DWORD slot)
virtual int dispatch_handler (DWORD slot, DWORD max_handlep1)
virtual int simple_dispatch_handler (DWORD slot, ACE_HANDLE event_handle)
virtual int complex_dispatch_handler (DWORD slot, ACE_HANDLE event_handle)
virtual int dispatch_window_messages (void)
 Dispatches window messages. Noop for WFMO_Reactor.

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.

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

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

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


Protected Attributes

ACE_Sig_Handlersignal_handler_
 Handle signals without requiring global/static variables.

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

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

ACE_Reactor_Notifynotify_handler_
 Used when is called.

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

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

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

ACE_Manual_Event ok_to_wait_
ACE_Manual_Event wakeup_all_threads_
ACE_Wakeup_All_Threads_Handler wakeup_all_threads_handler_
 Used when is signaled.

ACE_Auto_Event waiting_to_change_state_
size_t active_threads_
 Count of currently active threads.

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

ACE_thread_t change_state_thread_
ACE_HANDLE atomic_wait_array_ [2]
int open_for_business_
 This flag is used to keep track of whether we are already closed.

sig_atomic_t deactivated_

Private Member Functions

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

ACE_WFMO_Reactoroperator= (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 642 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 648 of file WFMO_Reactor.h.

00649   {
00650     /// Default size of the WFMO_Reactor's handle table.
00651     /**
00652      * Two slots will be added to the @a size parameter in the
00653      * constructor and open methods which will store handles used for
00654      * internal management purposes.
00655      */
00656     DEFAULT_SIZE = MAXIMUM_WAIT_OBJECTS - 2
00657   };


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 1064 of file WFMO_Reactor.cpp.

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

01067   : signal_handler_ (0),
01068     delete_signal_handler_ (0),
01069     timer_queue_ (0),
01070     delete_timer_queue_ (0),
01071     delete_handler_rep_ (0),
01072     delete_notify_handler_ (0),
01073     lock_adapter_ (lock_),
01074     handler_rep_ (*this),
01075     // this event is initially signaled
01076     ok_to_wait_ (1),
01077     // this event is initially unsignaled
01078     wakeup_all_threads_ (0),
01079     // this event is initially unsignaled
01080     waiting_to_change_state_ (0),
01081     active_threads_ (0),
01082     owner_ (ACE_Thread::self ()),
01083     new_owner_ (0),
01084     change_state_thread_ (0),
01085     open_for_business_ (0),
01086     deactivated_ (0)
01087 {
01088   if (this->open (ACE_WFMO_Reactor::DEFAULT_SIZE, 0, sh, tq, 0, notify) == -1)
01089     ACE_ERROR ((LM_ERROR,
01090                 ACE_LIB_TEXT ("%p\n"),
01091                 ACE_LIB_TEXT ("WFMO_Reactor")));
01092 }

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 1094 of file WFMO_Reactor.cpp.

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

01099   : signal_handler_ (0),
01100     delete_signal_handler_ (0),
01101     timer_queue_ (0),
01102     delete_timer_queue_ (0),
01103     delete_handler_rep_ (0),
01104     delete_notify_handler_ (0),
01105     lock_adapter_ (lock_),
01106     handler_rep_ (*this),
01107     // this event is initially signaled
01108     ok_to_wait_ (1),
01109     // this event is initially unsignaled
01110     wakeup_all_threads_ (0),
01111     // this event is initially unsignaled
01112     waiting_to_change_state_ (0),
01113     active_threads_ (0),
01114     owner_ (ACE_Thread::self ()),
01115     new_owner_ (0),
01116     change_state_thread_ (0),
01117     open_for_business_ (0),
01118     deactivated_ (0)
01119 {
01120   ACE_UNUSED_ARG (unused);
01121 
01122   if (this->open (size, 0, sh, tq, 0, notify) == -1)
01123     ACE_ERROR ((LM_ERROR,
01124                 ACE_LIB_TEXT ("%p\n"),
01125                 ACE_LIB_TEXT ("WFMO_Reactor")));
01126 }

ACE_WFMO_Reactor::~ACE_WFMO_Reactor void   )  [virtual]
 

Close down the ACE_WFMO_Reactor and release all of its resources.

Definition at line 1300 of file WFMO_Reactor.cpp.

References close(), and ACE_WFMO_Reactor_Handler_Repository::make_changes().

01301 {
01302   // Assumption: No threads are left in the Reactor when this method
01303   // is called (i.e., active_threads_ == 0)
01304 
01305   // Close down
01306   this->close ();
01307 
01308   // Make necessary changes to the handler repository that we caused
01309   // by <close>.
01310   this->handler_rep_.make_changes ();
01311 
01312   if (this->delete_timer_queue_)
01313     {
01314       delete this->timer_queue_;
01315       this->timer_queue_ = 0;
01316       this->delete_timer_queue_ = 0;
01317     }
01318 
01319   if (this->delete_signal_handler_)
01320     {
01321       delete this->signal_handler_;
01322       this->signal_handler_ = 0;
01323       this->delete_signal_handler_ = 0;
01324     }
01325 
01326   if (this->delete_notify_handler_)
01327     {
01328       delete this->notify_handler_;
01329       this->notify_handler_ = 0;
01330       this->delete_notify_handler_ = 0;
01331     }
01332 }

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 855 of file WFMO_Reactor.inl.

References event_handling().

00856 {
00857   return this->event_handling (&how_long, TRUE);
00858 }

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 867 of file WFMO_Reactor.inl.

References event_handling().

00868 {
00869   return this->event_handling (how_long, TRUE);
00870 }

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

Used to caluculate the next timeout.

Definition at line 1829 of file WFMO_Reactor.cpp.

References ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::calculate_timeout(), and ACE_Thread::self().

Referenced by event_handling().

01830 {
01831   ACE_Time_Value *time = 0;
01832   if (this->owner_ == ACE_Thread::self ())
01833     time = this->timer_queue_->calculate_timeout (max_wait_time);
01834   else
01835     time = max_wait_time;
01836 
01837   if (time == 0)
01838     return INFINITE;
01839   else
01840     return time->msec ();
01841 }

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 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 wasn't found.

Implements ACE_Reactor_Impl.

Definition at line 507 of file WFMO_Reactor.inl.

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

00510 {
00511   ACE_TRACE ("ACE_WFMO_Reactor::cancel_timer");
00512   if (0 != this->timer_queue_)
00513     return this->timer_queue_->cancel (timer_id, arg, dont_call_handle_close);
00514   return 0;
00515 }

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 . Returns number of handler's cancelled.

Implements ACE_Reactor_Impl.

Definition at line 497 of file WFMO_Reactor.inl.

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

00499 {
00500   ACE_TRACE ("ACE_WFMO_Reactor::cancel_timer");
00501   if (0 != this->timer_queue_)
00502     return this->timer_queue_->cancel (handler, dont_call_handle_close);
00503   return 0;
00504 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 620 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and mask_ops_i().

00622 {
00623   // This GUARD is necessary since we are updating shared state.
00624   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00625 
00626   return this->mask_ops_i (io_handle,
00627                            masks_to_be_removed,
00628                            ACE_Reactor::CLR_MASK);
00629 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 632 of file WFMO_Reactor.inl.

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

00634 {
00635   // This GUARD is necessary since we are updating shared state.
00636   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00637 
00638   return this->mask_ops_i (event_handler->get_handle (),
00639                            masks_to_be_removed,
00640                            ACE_Reactor::CLR_MASK);
00641 }

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

Set owner to new owner.

Definition at line 922 of file WFMO_Reactor.inl.

References ACE_thread_t, and new_owner_.

Referenced by update_state().

00923 {
00924   this->owner_ = this->new_owner_;
00925   this->new_owner_ = ACE_thread_t (0);
00926   return 0;
00927 }

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 1283 of file WFMO_Reactor.cpp.

References ACE_GUARD_RETURN, ACE_WFMO_Reactor_Handler_Repository::close(), and open_for_business_.

Referenced by ~ACE_WFMO_Reactor().

01284 {
01285   // This GUARD is necessary since we are updating shared state.
01286   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
01287 
01288   // If we are already closed, return error
01289   if (!this->open_for_business_)
01290     return -1;
01291 
01292   // We are now closed
01293   this->open_for_business_ = 0;
01294   // This will unregister all handles
01295   this->handler_rep_.close ();
01296 
01297   return 0;
01298 }

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 2021 of file WFMO_Reactor.cpp.

References ACE_Reactor_Mask, ACE_Event_Handler::add_reference(), ACE_WFMO_Reactor_Handler_Repository::current_info(), ACE_WFMO_Reactor_Handler_Repository::Common_Info::event_handler_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_handle_, _WSANETWORKEVENTS::lNetworkEvents, ACE_WFMO_Reactor_Handler_Repository::Common_Info::network_events_, ACE_Event_Handler::reference_counting_policy(), ACE_Event_Handler::remove_reference(), ACE_WFMO_Reactor_Handler_Repository::scheduled_for_deletion(), ACE_WFMO_Reactor_Handler_Repository::unbind(), upcall(), and WSANETWORKEVENTS.

Referenced by dispatch_handler().

02023 {
02024   // This dispatch is used for I/O entires.
02025 
02026   ACE_WFMO_Reactor_Handler_Repository::Current_Info &current_info =
02027     this->handler_rep_.current_info ()[slot];
02028 
02029   WSANETWORKEVENTS events;
02030   ACE_Reactor_Mask problems = ACE_Event_Handler::NULL_MASK;
02031   if (::WSAEnumNetworkEvents ((SOCKET) current_info.io_handle_,
02032                               event_handle,
02033                               &events) == SOCKET_ERROR)
02034     problems = ACE_Event_Handler::ALL_EVENTS_MASK;
02035   else
02036     {
02037       // Prepare for upcalls. Clear the bits from <events> representing
02038       // events the handler is not interested in. If there are any left,
02039       // do the upcall(s). upcall will replace events.lNetworkEvents
02040       // with bits representing any functions that requested a repeat
02041       // callback before checking handles again. In this case, continue
02042       // to call back unless the handler is unregistered as a result of
02043       // one of the upcalls. The way this is written, the upcalls will
02044       // keep being done even if one or more upcalls reported problems.
02045       // In practice this may turn out not so good, but let's see. If any
02046       // problems, please notify Steve Huston <shuston@riverace.com>
02047       // before or after you change this code.
02048       events.lNetworkEvents &= current_info.network_events_;
02049       while (events.lNetworkEvents != 0)
02050         {
02051           ACE_Event_Handler *event_handler =
02052             current_info.event_handler_;
02053 
02054           int reference_counting_required =
02055             event_handler->reference_counting_policy ().value () ==
02056             ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
02057 
02058           // Call add_reference() if needed.
02059           if (reference_counting_required)
02060             {
02061               event_handler->add_reference ();
02062             }
02063 
02064           // Upcall
02065           problems |= this->upcall (current_info.event_handler_,
02066                                     current_info.io_handle_,
02067                                     events);
02068 
02069           // Call remove_reference() if needed.
02070           if (reference_counting_required)
02071             {
02072               event_handler->remove_reference ();
02073             }
02074 
02075           if (this->handler_rep_.scheduled_for_deletion (slot))
02076             break;
02077         }
02078     }
02079 
02080   if (problems != ACE_Event_Handler::NULL_MASK
02081       && !this->handler_rep_.scheduled_for_deletion (slot)  )
02082     this->handler_rep_.unbind (event_handle, problems);
02083 
02084   return 0;
02085 }

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 1129 of file WFMO_Reactor.cpp.

01130 {
01131   return -1;
01132 }

ACE_INLINE void ACE_WFMO_Reactor::deactivate int  do_stop  )  [virtual]
 

Control whether the Reactor will handle any more incoming events or not. If == 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 879 of file WFMO_Reactor.inl.

References wakeup_all_threads().

00880 {
00881   this->deactivated_ = do_stop;
00882   this->wakeup_all_threads ();
00883 }

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, and return -1 immediately.

Implements ACE_Reactor_Impl.

Definition at line 873 of file WFMO_Reactor.inl.

00874 {
00875   return this->deactivated_;
00876 }

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

Dispatches the timers and I/O handlers.

Definition at line 1858 of file WFMO_Reactor.cpp.

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

Referenced by safe_dispatch().

01859 {
01860   int handlers_dispatched = 0;
01861 
01862   // Expire timers
01863   handlers_dispatched += this->expire_timers ();
01864 
01865   switch (wait_status)
01866     {
01867     case WAIT_FAILED: // Failure.
01868       ACE_OS::set_errno_to_last_error ();
01869       return -1;
01870 
01871     case WAIT_TIMEOUT: // Timeout.
01872       errno = ETIME;
01873       return handlers_dispatched;
01874 
01875 #ifndef ACE_HAS_WINCE
01876     case WAIT_IO_COMPLETION: // APC.
01877       return handlers_dispatched;
01878 #endif  // ACE_HAS_WINCE
01879 
01880     default:  // Dispatch.
01881       // We'll let dispatch worry about abandoned mutes.
01882       handlers_dispatched += this->dispatch_handles (wait_status);
01883       return handlers_dispatched;
01884     }
01885 }

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 1955 of file WFMO_Reactor.cpp.

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

Referenced by dispatch_handles().

01957 {
01958   // Check if there are window messages that need to be dispatched
01959   if (slot == max_handlep1)
01960     return this->dispatch_window_messages ();
01961 
01962   // Dispatch the handler if it has not been scheduled for deletion.
01963   // Note that this is a very week test if there are multiple threads
01964   // dispatching this slot as no locks are held here. Generally, you
01965   // do not want to do something like deleting the this pointer in
01966   // handle_close() if you have registered multiple times and there is
01967   // more than one thread in WFMO_Reactor->handle_events().
01968   else if (!this->handler_rep_.scheduled_for_deletion (slot))
01969     {
01970       ACE_HANDLE event_handle = *(this->handler_rep_.handles () + slot);
01971 
01972       if (this->handler_rep_.current_info ()[slot].io_entry_)
01973         return this->complex_dispatch_handler (slot,
01974                                                event_handle);
01975       else
01976         return this->simple_dispatch_handler (slot,
01977                                               event_handle);
01978     }
01979   else
01980     // The handle was scheduled for deletion, so we will skip it.
01981     return 0;
01982 }

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

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

Definition at line 1891 of file WFMO_Reactor.cpp.

References dispatch_handler(), ACE_WFMO_Reactor_Handler_Repository::max_handlep1(), poll_remaining_handles(), and ACE_OS::set_errno_to_last_error().

Referenced by dispatch().

01892 {
01893   // dispatch_slot is the absolute slot.  Only += is used to
01894   // increment it.
01895   DWORD dispatch_slot = 0;
01896 
01897   // Cache this value, this is the absolute value.
01898   DWORD max_handlep1 = this->handler_rep_.max_handlep1 ();
01899 
01900   // nCount starts off at <max_handlep1>, this is a transient count of
01901   // handles last waited on.
01902   DWORD nCount = max_handlep1;
01903 
01904   for (int number_of_handlers_dispatched = 1;
01905        ;
01906        ++number_of_handlers_dispatched)
01907     {
01908       const bool ok = (
01909 #if ! (defined(__BORLANDC__) && (__BORLANDC__ >= 0x0530)) \
01910     && !defined (ghs) \
01911     && !defined (__MINGW32__) \
01912     && !(defined (_MSC_VER) && _MSC_VER >= 1300)
01913                  // wait_status is unsigned in Borland, Green Hills,
01914                  // mingw32 and MSVC++ >= 7.1.
01915                  // This >= is always true, with a warning.
01916                  wait_status >= WAIT_OBJECT_0 &&
01917 #endif
01918                  wait_status <= (WAIT_OBJECT_0 + nCount));
01919 
01920       if (ok)
01921         dispatch_slot += wait_status - WAIT_OBJECT_0;
01922       else
01923         // Otherwise, a handle was abandoned.
01924         dispatch_slot += wait_status - WAIT_ABANDONED_0;
01925 
01926       // Dispatch handler
01927       if (this->dispatch_handler (dispatch_slot, max_handlep1) == -1)
01928         return -1;
01929 
01930       // Increment slot
01931       ++dispatch_slot;
01932 
01933       // We're done.
01934       if (dispatch_slot >= max_handlep1)
01935         return number_of_handlers_dispatched;
01936 
01937       // Readjust nCount
01938       nCount = max_handlep1 - dispatch_slot;
01939 
01940       // Check the remaining handles
01941       wait_status = this->poll_remaining_handles (dispatch_slot);
01942       switch (wait_status)
01943         {
01944         case WAIT_FAILED: // Failure.
01945           ACE_OS::set_errno_to_last_error ();
01946           /* FALLTHRU */
01947         case WAIT_TIMEOUT:
01948           // There are no more handles ready, we can return.
01949           return number_of_handlers_dispatched;
01950         }
01951     }
01952 }

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 946 of file WFMO_Reactor.inl.

Referenced by dispatch_handler().

00947 {
00948   return 0;
00949 }

void ACE_WFMO_Reactor::dump void   )  const [virtual]
 

Dump the state of an object.

Implements ACE_Reactor_Impl.

Definition at line 2280 of file WFMO_Reactor.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::dump(), ACE_Sig_Handler::dump(), ACE_WFMO_Reactor_Handler_Repository::dump(), and LM_DEBUG.

02281 {
02282 #if defined (ACE_HAS_DUMP)
02283   ACE_TRACE ("ACE_WFMO_Reactor::dump");
02284 
02285   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
02286 
02287   ACE_DEBUG ((LM_DEBUG,
02288               ACE_LIB_TEXT ("Count of currently active threads = %d\n"),
02289               this->active_threads_));
02290 
02291   ACE_DEBUG ((LM_DEBUG,
02292               ACE_LIB_TEXT ("ID of owner thread = %d\n"),
02293               this->owner_));
02294 
02295   this->handler_rep_.dump ();
02296   this->signal_handler_->dump ();
02297   this->timer_queue_->dump ();
02298 
02299   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
02300 #endif /* ACE_HAS_DUMP */
02301 }

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

Event handling workhorse.

Definition at line 1669 of file WFMO_Reactor.cpp.

References ACE_TRACE, active_threads_, calculate_timeout(), 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().

01671 {
01672   ACE_TRACE ("ACE_WFMO_Reactor::event_handling");
01673 
01674   // Make sure we are not closed
01675   if (!this->open_for_business_ || this->deactivated_)
01676     return -1;
01677 
01678   // Stash the current time -- the destructor of this object will
01679   // automatically compute how much time elapsed since this method was
01680   // called.
01681   ACE_Countdown_Time countdown (max_wait_time);
01682 
01683   int result;
01684   do
01685     {
01686       // Check to see if it is ok to enter ::WaitForMultipleObjects
01687       // This will acquire <this->lock_> on success On failure, the
01688       // lock will not be acquired
01689       result = this->ok_to_wait (max_wait_time, alertable);
01690       if (result != 1)
01691         return result;
01692 
01693       // Increment the number of active threads
01694       ++this->active_threads_;
01695 
01696       // Release the <lock_>
01697       this->lock_.release ();
01698 
01699       // Update the countdown to reflect time waiting to play with the
01700       // mut and event.
01701       countdown.update ();
01702 
01703       // Calculate timeout
01704       int timeout = this->calculate_timeout (max_wait_time);
01705 
01706       // Wait for event to happen
01707       DWORD wait_status = this->wait_for_multiple_events (timeout,
01708                                                           alertable);
01709 
01710       // Upcall
01711       result = this->safe_dispatch (wait_status);
01712       if (0 == result)
01713         {
01714           // wait_for_multiple_events timed out without dispatching
01715           // anything.  Because of rounding and conversion errors and
01716           // such, it could be that the wait loop timed out, but
01717           // the timer queue said it wasn't quite ready to expire a
01718           // timer. In this case, max_wait_time won't have quite been
01719           // reduced to 0, and we need to go around again. If max_wait_time
01720           // is all the way to 0, just return, as the entire time the
01721           // caller wanted to wait has been used up.
01722           countdown.update ();     // Reflect time waiting for events
01723           if (0 == max_wait_time || max_wait_time->usec () == 0)
01724             break;
01725         }
01726     }
01727   while (result == 0);
01728 
01729   return result;
01730 }

int ACE_WFMO_Reactor::expire_timers void   )  [protected, virtual]
 

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

Definition at line 1845 of file WFMO_Reactor.cpp.

References ACE_Timer_Queue_T< TYPE, FUNCTOR, ACE_LOCK >::expire(), and ACE_Thread::self().

Referenced by dispatch().

01846 {
01847   // If "owner" thread
01848   if (ACE_Thread::self () == this->owner_)
01849     // expire all pending timers.
01850     return this->timer_queue_->expire ();
01851 
01852   else
01853     // Nothing to expire
01854     return 0;
01855 }

ACE_INLINE ACE_Event_Handler * ACE_WFMO_Reactor::find_handler ACE_HANDLE  handle  )  [virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 1115 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, and ACE_WFMO_Reactor_Handler_Repository::find_handler().

01116 {
01117   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, 0);
01118 
01119   return this->handler_rep_.find_handler (handle);
01120 }

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 value is a reference and can therefore never be NULL.

The only difference between and is that in the alertable case, TRUE is passed to for the option.

Implements ACE_Reactor_Impl.

Reimplemented in ACE_Msg_WFMO_Reactor.

Definition at line 849 of file WFMO_Reactor.inl.

References event_handling().

00850 {
00851   return this->event_handling (&how_long, FALSE);
00852 }

ACE_INLINE int ACE_WFMO_Reactor::handle_events ACE_Time_Value max_wait_time = 0  )  [virtual]
 

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

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, will equal 1 second. This can be used if an application wishes to handle events for some fixed amount of time.

is used as the demultiplexing call

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

The only difference between and is that in the alertable case, TRUE is passed to for the option.

Implements ACE_Reactor_Impl.

Reimplemented in ACE_Msg_WFMO_Reactor.

Definition at line 861 of file WFMO_Reactor.inl.

References event_handling().

00862 {
00863   return this->event_handling (how_long, FALSE);
00864 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 1030 of file WFMO_Reactor.inl.

References ACE_Sig_Handler::handler().

01031 {
01032   ACE_Event_Handler *handler =
01033     this->signal_handler_->handler (signum);
01034 
01035   if (handler == 0)
01036     return -1;
01037   else if (eh != 0)
01038     *eh = handler;
01039   return 0;
01040 }

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 is associated with a valid Event_Handler bound to . Return the associated with this if != 0.

Implements ACE_Reactor_Impl.

Definition at line 1123 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and ACE_WFMO_Reactor_Handler_Repository::handler().

01126 {
01127   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
01128 
01129   return this->handler_rep_.handler (handle,
01130                                      mask,
01131                                      event_handler);
01132 }

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 1135 of file WFMO_Reactor.inl.

References open_for_business_.

01136 {
01137   return this->open_for_business_;
01138 }

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 1141 of file WFMO_Reactor.inl.

01142 {
01143   return this->lock_adapter_;
01144 }

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

Modify of the 's entry in WFMO_Reactor depending upon . must already have been registered with WFMO_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 1055 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and mask_ops_i().

01058 {
01059   ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
01060 
01061   return this->mask_ops_i (io_handle,
01062                            mask,
01063                            operation);
01064 }

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

Modify of the 's entry in WFMO_Reactor depending upon . must already have been registered with WFMO_Reactor.

Implements ACE_Reactor_Impl.

Definition at line 1043 of file WFMO_Reactor.inl.

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

01046 {
01047   ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
01048 
01049   return this->mask_ops_i (event_handler->get_handle (),
01050                            mask,
01051                            operation);
01052 }

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 1431 of file WFMO_Reactor.cpp.

References ACE_Reactor_Mask, 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().

01434 {
01435   // Make sure that the <handle> is valid
01436   if (this->handler_rep_.invalid_handle (io_handle))
01437     return -1;
01438 
01439   long new_network_events = 0;
01440   int delete_event = 0;
01441   ACE_HANDLE event_handle = ACE_INVALID_HANDLE;
01442 
01443   // Look up the repository to see if the <Event_Handler> is already
01444   // there.
01445   ACE_Reactor_Mask old_masks;
01446   int found = this->handler_rep_.modify_network_events_i (io_handle,
01447                                                           new_masks,
01448                                                           old_masks,
01449                                                           new_network_events,
01450                                                           event_handle,
01451                                                           delete_event,
01452                                                           operation);
01453   if (found)
01454     {
01455       int result = ::WSAEventSelect ((SOCKET) io_handle,
01456                                      event_handle,
01457                                      new_network_events);
01458       if (result == 0)
01459         return old_masks;
01460       else
01461         return result;
01462     }
01463   else
01464     return -1;
01465 }

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 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 2655 of file WFMO_Reactor.cpp.

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

02656 {
02657   ACE_TRACE ("ACE_WFMO_Reactor::max_notify_iterations");
02658   ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
02659 
02660   return this->notify_handler_->max_notify_iterations ();
02661 }

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 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 2645 of file WFMO_Reactor.cpp.

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

02646 {
02647   ACE_TRACE ("ACE_WFMO_Reactor::max_notify_iterations");
02648   ACE_GUARD (ACE_Process_Mutex, monitor, this->lock_);
02649 
02650   // Must always be > 0 or < 0 to optimize the loop exit condition.
02651   this->notify_handler_->max_notify_iterations (iterations);
02652 }

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

Check to see if we have a new owner.

Definition at line 916 of file WFMO_Reactor.inl.

References ACE_thread_t, and new_owner_.

Referenced by update_state().

00917 {
00918   return this->new_owner_ != ACE_thread_t (0);
00919 }

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 thread if it is currently blocked in . The indicates how long to blocking trying to notify the . If == 0, the caller will block until action is possible, else will wait until the relative time specified in elapses).

Implements ACE_Reactor_Impl.

Definition at line 958 of file WFMO_Reactor.inl.

References ACE_Reactor_Mask, and ACE_Reactor_Notify::notify().

Referenced by schedule_timer().

00961 {
00962   return this->notify_handler_->notify (event_handler, mask, timeout);
00963 }

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 1733 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().

01735 {
01736   // Calculate the max time we should spend here
01737   //
01738   // Note: There is really no need to involve the <timer_queue_> here
01739   // because even if a timeout in the <timer_queue_> does expire we
01740   // will not be able to dispatch it
01741   int timeout = max_wait_time == 0 ? INFINITE : max_wait_time->msec ();
01742 
01743   // Atomically wait for both the <lock_> and <ok_to_wait_> event
01744   DWORD result = 0;
01745   while (1)
01746     {
01747 #if defined (ACE_HAS_PHARLAP)
01748       // PharLap doesn't implement WaitForMultipleObjectsEx, and doesn't
01749       // do async I/O, so it's not needed in this case anyway.
01750       result = ::WaitForMultipleObjects (sizeof this->atomic_wait_array_ / sizeof (ACE_HANDLE),
01751                                          this->atomic_wait_array_,
01752                                          TRUE,
01753                                          timeout);
01754 
01755       if (result != WAIT_IO_COMPLETION)
01756         break;
01757 
01758 #elif defined (ACE_HAS_WINCE)
01759       result = ::WaitForMultipleObjects (sizeof this->atomic_wait_array_ / sizeof (ACE_HANDLE),
01760                                          this->atomic_wait_array_,
01761                                          TRUE,
01762                                          timeout);
01763       break;  // CE does not have WAIT_IO_COMPLETION defined.
01764 #else
01765       result = ::WaitForMultipleObjectsEx (sizeof this->atomic_wait_array_ / sizeof (ACE_HANDLE),
01766                                            this->atomic_wait_array_,
01767                                            TRUE,
01768                                            timeout,
01769                                            alertable);
01770 
01771       if (result != WAIT_IO_COMPLETION)
01772         break;
01773 
01774 #endif /* ACE_HAS_PHARLAP */
01775     }
01776 
01777   switch (result)
01778     {
01779     case WAIT_TIMEOUT:
01780       errno = ETIME;
01781       return 0;
01782     case WAIT_FAILED:
01783     case WAIT_ABANDONED_0:
01784       ACE_OS::set_errno_to_last_error ();
01785       return -1;
01786     default:
01787       break;
01788     }
01789 
01790   // It is ok to enter ::WaitForMultipleObjects
01791   return 1;
01792 }

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 1135 of file WFMO_Reactor.cpp.

References ACE_ERROR_RETURN, ACE_GUARD_RETURN, ACE_LIB_TEXT, ACE_NEW_RETURN, ACE_Timer_Heap, ACE_Timer_Queue, atomic_wait_array_, ACE_WFMO_Reactor_Handler_Repository::changes_required(), delete_handler_rep_, ACE_Event::handle(), LM_ERROR, ACE_Process_Mutex::lock(), ACE_WFMO_Reactor_Handler_Repository::make_changes(), ok_to_wait_, ACE_Reactor_Notify::open(), ACE_WFMO_Reactor_Handler_Repository::open(), open_for_business_, register_handler(), ACE_Event::reset(), wakeup_all_threads_, and ACE_WFMO_Reactor_Handler_Repository::~ACE_WFMO_Reactor_Handler_Repository().

Referenced by ACE_WFMO_Reactor().

01141 {
01142   ACE_UNUSED_ARG (unused);
01143   ACE_UNUSED_ARG (disable_notify_pipe);
01144 
01145   // This GUARD is necessary since we are updating shared state.
01146   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
01147 
01148   // If we are already open, return -1
01149   if (this->open_for_business_)
01150     return -1;
01151 
01152   // Timer Queue
01153   if (this->delete_timer_queue_)
01154     delete this->timer_queue_;
01155 
01156   if (tq == 0)
01157     {
01158       ACE_NEW_RETURN (this->timer_queue_,
01159                       ACE_Timer_Heap,
01160                       -1);
01161       this->delete_timer_queue_ = 1;
01162     }
01163   else
01164     {
01165       this->timer_queue_ = tq;
01166       this->delete_timer_queue_ = 0;
01167     }
01168 
01169   // Signal Handler
01170   if (this->delete_signal_handler_)
01171     delete this->signal_handler_;
01172 
01173   if (sh == 0)
01174     {
01175       ACE_NEW_RETURN (this->signal_handler_,
01176                       ACE_Sig_Handler,
01177                       -1);
01178       this->delete_signal_handler_ = 1;
01179     }
01180   else
01181     {
01182       this->signal_handler_ = sh;
01183       this->delete_signal_handler_ = 0;
01184     }
01185 
01186   // Setup the atomic wait array (used later in <handle_events>)
01187   this->atomic_wait_array_[0] = this->lock_.lock ().proc_mutex_;
01188   this->atomic_wait_array_[1] = this->ok_to_wait_.handle ();
01189 
01190   // This is to guard against reopens of WFMO_Reactor
01191   if (this->delete_handler_rep_)
01192     this->handler_rep_.~ACE_WFMO_Reactor_Handler_Repository ();
01193 
01194   // Open the handle repository.  Two additional handles for internal
01195   // purposes
01196   if (this->handler_rep_.open (size + 2) == -1)
01197     ACE_ERROR_RETURN ((LM_ERROR, ACE_LIB_TEXT ("%p\n"),
01198                        ACE_LIB_TEXT ("opening handler repository")),
01199                       -1);
01200   else
01201     this->delete_handler_rep_ = 1;
01202 
01203   if (this->notify_handler_ != 0
01204       && this->delete_notify_handler_ != 0)
01205     delete this->notify_handler_;
01206 
01207   this->notify_handler_ = notify;
01208 
01209   if (this->notify_handler_ == 0)
01210     {
01211       ACE_NEW_RETURN (this->notify_handler_,
01212                       ACE_WFMO_Reactor_Notify,
01213                       -1);
01214 
01215       if (this->notify_handler_ == 0)
01216         return -1;
01217       else
01218         this->delete_notify_handler_ = 1;
01219     }
01220 
01221   /* NOTE */
01222   // The order of the following two registrations is very important
01223 
01224   // Open the notification handler
01225   if (this->notify_handler_->open (this, this->timer_queue_) == -1)
01226     ACE_ERROR_RETURN ((LM_ERROR,
01227                        ACE_LIB_TEXT ("%p\n"),
01228                        ACE_LIB_TEXT ("opening notify handler ")),
01229                       -1);
01230 
01231   // Register for <wakeup_all_threads> event
01232   if (this->register_handler (&this->wakeup_all_threads_handler_,
01233                               this->wakeup_all_threads_.handle ()) == -1)
01234     ACE_ERROR_RETURN ((LM_ERROR,
01235                        ACE_LIB_TEXT ("%p\n"),
01236                        ACE_LIB_TEXT ("registering thread wakeup handler")),
01237                       -1);
01238 
01239   // Since we have added two handles into the handler repository,
01240   // update the <handler_repository_>
01241   if (this->handler_rep_.changes_required ())
01242     {
01243       // Make necessary changes to the handler repository
01244       this->handler_rep_.make_changes ();
01245       // Turn off <wakeup_all_threads_> since all necessary changes
01246       // have completed
01247       this->wakeup_all_threads_.reset ();
01248     }
01249 
01250   // We are open for business
01251   this->open_for_business_ = 1;
01252 
01253   return 0;
01254 }

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 886 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, and owner_i().

00887 {
00888   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00889   *t = this->owner_i ();
00890   return 0;
00891 }

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 . The transfer will not complete until all threads are ready (just like the handle set).

Implements ACE_Reactor_Impl.

Definition at line 900 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, new_owner_, owner_i(), and wakeup_all_threads().

00901 {
00902   ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
00903   this->new_owner_ = new_owner;
00904 
00905   if (old_owner != 0)
00906     *old_owner = this->owner_i ();
00907 
00908   // Wake up all threads in WaitForMultipleObjects so that they can
00909   // reconsult the new owner responsibilities
00910   this->wakeup_all_threads ();
00911 
00912   return 0;
00913 }

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 894 of file WFMO_Reactor.inl.

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().

00895 {
00896   return this->owner_;
00897 }

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 1820 of file WFMO_Reactor.cpp.

References ACE_WFMO_Reactor_Handler_Repository::handles().

Referenced by dispatch_handles().

01821 {
01822   return ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 () - slot,
01823                                    this->handler_rep_.handles () + slot,
01824                                    FALSE,
01825                                    0);
01826 }

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 2664 of file WFMO_Reactor.cpp.

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

02666 {
02667   ACE_TRACE ("ACE_WFMO_Reactor::purge_pending_notifications");
02668   if (this->notify_handler_ == 0)
02669     return 0;
02670   else
02671     return this->notify_handler_->purge_pending_notifications (eh, mask);
02672 }

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 1104 of file WFMO_Reactor.inl.

References ACE_NOTSUP_RETURN, and ACE_Reactor_Mask.

01107 {
01108   // Don't have an implementation for this yet...
01109   ACE_UNUSED_ARG (handle);
01110   ACE_UNUSED_ARG (ops);
01111   ACE_NOTSUP_RETURN (-1);
01112 }

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 1092 of file WFMO_Reactor.inl.

References ACE_NOTSUP_RETURN, and ACE_Reactor_Mask.

01095 {
01096   // Don't have an implementation for this yet...
01097   ACE_UNUSED_ARG (event_handler);
01098   ACE_UNUSED_ARG (mask);
01099   ACE_UNUSED_ARG (ops);
01100   ACE_NOTSUP_RETURN (-1);
01101 }

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

Implements ACE_Reactor_Impl.

Definition at line 978 of file WFMO_Reactor.inl.

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

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

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 to handle the signal using the . Returns the that was previously registered (if any), along with the of the signal handler.

Implements ACE_Reactor_Impl.

Definition at line 966 of file WFMO_Reactor.inl.

References ACE_Sig_Handler::register_handler().

00971 {
00972   return this->signal_handler_->register_handler (signum,
00973                                                   new_sh, new_disp,
00974                                                   old_sh, old_disp);
00975 }

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

Register with all the in the .

Implements ACE_Reactor_Impl.

Definition at line 575 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and register_handler_i().

00578 {
00579   // This GUARD is necessary since we are updating shared state.
00580   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00581 
00582   ACE_Handle_Set_Iterator handle_iter (handles);
00583   ACE_HANDLE h;
00584 
00585   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00586     if (this->register_handler_i (h,
00587                                   ACE_INVALID_HANDLE,
00588                                   handler,
00589                                   mask) == -1)
00590       return -1;
00591 
00592   return 0;
00593 }

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 method where the I/O handle will always come from on the and the event handle will always be created by

Implements ACE_Reactor_Impl.

Definition at line 533 of file WFMO_Reactor.inl.

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 (ACE_INVALID_HANDLE,
00540                                    ACE_INVALID_HANDLE,
00541                                    event_handler,
00542                                    mask);
00543 }

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 method where the I/O handle is passed in and the event handle will always be created by

Implements ACE_Reactor_Impl.

Definition at line 546 of file WFMO_Reactor.inl.

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   return this->register_handler_i (ACE_INVALID_HANDLE,
00554                                    io_handle,
00555                                    event_handler,
00556                                    mask);
00557 }

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 . specifies the network events that the is interested in. If == the will call the method of to extract the underlying I/O handle. If the == , WFMO_Reactor will create an event for associating it with the I/O handle. When the is signalled, the appropriate <handle_*> callback will be invoked on the

Implements ACE_Reactor_Impl.

Definition at line 560 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and register_handler_i().

00564 {
00565   // This GUARD is necessary since we are updating shared state.
00566   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00567 
00568   return this->register_handler_i (event_handle,
00569                                    io_handle,
00570                                    event_handler,
00571                                    mask);
00572 }

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 . Since no Event Mask is passed through this interface, it is assumed that the being passed in is an event handle and when the event becomes signaled, will call handle_signal on . If == the will call the method of to extract the underlying event handle.

Implements ACE_Reactor_Impl.

Definition at line 518 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, and ACE_WFMO_Reactor_Handler_Repository::bind_i().

Referenced by open().

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->handler_rep_.bind_i (0,
00525                                     event_handler,
00526                                     0,
00527                                     ACE_INVALID_HANDLE,
00528                                     event_handle,
00529                                     0);
00530 }

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 1335 of file WFMO_Reactor.cpp.

References ACE_NOTSUP_RETURN, ACE_Reactor_Mask, ACE_WFMO_Reactor_Handler_Repository::bind_i(), ACE_Event_Handler::get_handle(), ACE_WFMO_Reactor_Handler_Repository::invalid_handle(), and ACE_WFMO_Reactor_Handler_Repository::modify_network_events_i().

Referenced by register_handler().

01339 {
01340   // If this is a Winsock 1 system, the underlying event assignment will
01341   // not work, so don't try. Winsock 1 must use ACE_Select_Reactor for
01342   // reacting to socket activity.
01343 
01344 #if !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0)
01345 
01346   ACE_UNUSED_ARG (event_handle);
01347   ACE_UNUSED_ARG (io_handle);
01348   ACE_UNUSED_ARG (event_handler);
01349   ACE_UNUSED_ARG (new_masks);
01350   ACE_NOTSUP_RETURN (-1);
01351 
01352 #else
01353 
01354   // Make sure that the <handle> is valid
01355   if (io_handle == ACE_INVALID_HANDLE)
01356     io_handle = event_handler->get_handle ();
01357 
01358   if (this->handler_rep_.invalid_handle (io_handle))
01359     {
01360       errno = ERROR_INVALID_HANDLE;
01361       return -1;
01362     }
01363 
01364   long new_network_events = 0;
01365   int delete_event = 0;
01366   auto_ptr <ACE_Auto_Event> event;
01367 
01368   // Look up the repository to see if the <event_handler> is already
01369   // there.
01370   ACE_Reactor_Mask old_masks;
01371   int found = this->handler_rep_.modify_network_events_i (io_handle,
01372                                                           new_masks,
01373                                                           old_masks,
01374                                                           new_network_events,
01375                                                           event_handle,
01376                                                           delete_event,
01377                                                           ACE_Reactor::ADD_MASK);
01378 
01379   // Check to see if the user passed us a valid event; If not then we
01380   // need to create one
01381   if (event_handle == ACE_INVALID_HANDLE)
01382     {
01383       // Note: don't change this since some C++ compilers have
01384       // <auto_ptr>s that don't work properly...
01385       auto_ptr<ACE_Auto_Event> tmp (new ACE_Auto_Event);
01386       event = tmp;
01387       event_handle = event->handle ();
01388       delete_event = 1;
01389     }
01390 
01391   int result = ::WSAEventSelect ((SOCKET) io_handle,
01392                                  event_handle,
01393                                  new_network_events);
01394   // If we had found the <Event_Handler> there is nothing more to do
01395   if (found)
01396     return result;
01397   else if (result != SOCKET_ERROR &&
01398            this->handler_rep_.bind_i (1,
01399                                       event_handler,
01400                                       new_network_events,
01401                                       io_handle,
01402                                       event_handle,
01403                                       delete_event) != -1)
01404     {
01405       // The <event_handler> was not found in the repository, add to
01406       // the repository.
01407       if (delete_event)
01408         {
01409           // Clear out the handle in the ACE_Auto_Event so that when
01410           // it is destroyed, the handle isn't closed out from under
01411           // the reactor. After setting it, running down the event
01412           // (via auto_ptr<> event, above) at function return will
01413           // cause an error because it'll try to close an invalid handle.
01414           // To avoid that smashing the errno value, save the errno
01415           // here, explicitly remove the event so the dtor won't do it
01416           // again, then restore errno.
01417           ACE_Errno_Guard guard (errno);
01418           event->handle (ACE_INVALID_HANDLE);
01419           event->remove ();
01420         }
01421       return 0;
01422     }
01423   else
01424     return -1;
01425 
01426 #endif /* ACE_HAS_WINSOCK2 || ACE_HAS_WINSOCK2 == 0 */
01427 
01428 }

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

Calls for every signal in .

Implements ACE_Reactor_Impl.

Definition at line 1013 of file WFMO_Reactor.inl.

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

01014 {
01015   int result = 0;
01016 
01017 #if (ACE_NSIG > 0)
01018   for (int s = 1; s < ACE_NSIG; s++)
01019     if (sigset.is_member (s)
01020         && this->signal_handler_->remove_handler (s) == -1)
01021       result = -1;
01022 #else
01023   ACE_UNUSED_ARG (sigset);
01024 #endif /* ACE_NSIG */
01025 
01026   return result;
01027 }

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 . 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 is invalid.

Implements ACE_Reactor_Impl.

Definition at line 1001 of file WFMO_Reactor.inl.

References ACE_Sig_Handler::remove_handler().

01005 {
01006   return this->signal_handler_->remove_handler (signum,
01007                                                 new_disp,
01008                                                 old_disp,
01009                                                 sigkey);
01010 }

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

Removes all the bindings for handles in the bind of . 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 660 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, ACE_WFMO_Reactor_Handler_Repository::unbind_i(), and wakeup_all_threads().

00662 {
00663   ACE_Handle_Set_Iterator handle_iter (handles);
00664   ACE_HANDLE h;
00665   int changes_required = 0;
00666 
00667   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00668 
00669   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00670     if (this->handler_rep_.unbind_i (h,
00671                                      mask,
00672                                      changes_required) == -1)
00673       return -1;
00674 
00675   // Wake up all threads in WaitForMultipleObjects so that they can
00676   // reconsult the handle set
00677   this->wakeup_all_threads ();
00678 
00679   return 0;
00680 }

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

Removes from the . If == <ACE_Event_Handler::DONT_CALL> then the method of the is not invoked. Note that the can either be the or the

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

Implements ACE_Reactor_Impl.

Definition at line 652 of file WFMO_Reactor.inl.

References ACE_Reactor_Mask, and ACE_WFMO_Reactor_Handler_Repository::unbind().

00654 {
00655   return this->handler_rep_.unbind (handle,
00656                                     mask);
00657 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 644 of file WFMO_Reactor.inl.

References ACE_Reactor_Mask, ACE_Event_Handler::get_handle(), and ACE_WFMO_Reactor_Handler_Repository::unbind().

00646 {
00647   return this->handler_rep_.unbind (event_handler->get_handle (),
00648                                     mask);
00649 }

ACE_INLINE int ACE_WFMO_Reactor::requeue_position void   )  [virtual]
 

Not implemented.

Implements ACE_Reactor_Impl.

Definition at line 1073 of file WFMO_Reactor.inl.

References ACE_NOTSUP_RETURN.

01074 {
01075   // Don't have an implementation for this yet...
01076   ACE_NOTSUP_RETURN (-1);
01077 }

ACE_INLINE void ACE_WFMO_Reactor::requeue_position int   )  [virtual]
 

Not implemented.

Implements ACE_Reactor_Impl.

Definition at line 1067 of file WFMO_Reactor.inl.

01068 {
01069   // Not implemented
01070 }

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

Implements ACE_Reactor_Impl.

Definition at line 449 of file WFMO_Reactor.inl.

References ACE_TRACE, and ESHUTDOWN.

00451 {
00452   ACE_TRACE ("ACE_WFMO_Reactor::reset_timer_interval");
00453 
00454   if (0 != this->timer_queue_)
00455     {
00456       long result = this->timer_queue_->reset_interval
00457         (timer_id,
00458          interval);
00459 
00460       // Wakeup the owner thread so that it gets the latest timer values
00461       this->notify ();
00462 
00463       return result;
00464     }
00465 
00466   errno = ESHUTDOWN;
00467   return -1;
00468 }

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 1086 of file WFMO_Reactor.inl.

01087 {
01088   return 0;
01089 }

ACE_INLINE int ACE_WFMO_Reactor::restart void   )  [virtual]
 

Get the existing restart value.

Implements ACE_Reactor_Impl.

Definition at line 1080 of file WFMO_Reactor.inl.

01081 {
01082   return 0;
01083 }

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 2675 of file WFMO_Reactor.cpp.

References ACE_TRACE.

02676 {
02677   ACE_TRACE ("ACE_WFMO_Reactor::resumable_handler");
02678   return 0;
02679 }

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

Resume all in handle set.

Implements ACE_Reactor_Impl.

Definition at line 787 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_WFMO_Reactor_Handler_Repository::resume_handler_i(), and wakeup_all_threads().

00788 {
00789   ACE_Handle_Set_Iterator handle_iter (handles);
00790   ACE_HANDLE h;
00791   int changes_required = 0;
00792 
00793   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00794 
00795   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00796     if (this->handler_rep_.resume_handler_i (h,
00797                                              changes_required) == -1)
00798       return -1;
00799 
00800   // Wake up all threads in WaitForMultipleObjects so that they can
00801   // reconsult the handle set
00802   this->wakeup_all_threads ();
00803 
00804   return 0;
00805 }

ACE_INLINE int ACE_WFMO_Reactor::resume_handler ACE_HANDLE  handle  )  [virtual]
 

Resume .

Implements ACE_Reactor_Impl.

Definition at line 763 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_WFMO_Reactor_Handler_Repository::resume_handler_i(), and wakeup_all_threads().

00764 {
00765   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00766 
00767   int changes_required = 0;
00768   int result =
00769     this->handler_rep_.resume_handler_i (handle,
00770                                          changes_required);
00771 
00772   if (changes_required)
00773     // Wake up all threads in WaitForMultipleObjects so that they can
00774     // reconsult the handle set
00775     this->wakeup_all_threads ();
00776 
00777   return result;
00778 }

ACE_INLINE int ACE_WFMO_Reactor::resume_handler ACE_Event_Handler event_handler  )  [virtual]
 

Resume . Use <ACE_Event_Handler::get_handle> to get the handle.

Implements ACE_Reactor_Impl.

Definition at line 781 of file WFMO_Reactor.inl.

References ACE_Event_Handler::get_handle().

00782 {
00783   return this->resume_handler (event_handler->get_handle ());
00784 }

ACE_INLINE int ACE_WFMO_Reactor::resume_handlers void   )  [virtual]
 

Resume all .

Implements ACE_Reactor_Impl.

Definition at line 808 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, 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().

00809 {
00810   int error = 0;
00811   int result = 0;
00812   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00813 
00814   int changes_required = 0;
00815   for (size_t i = 0;
00816        i < this->handler_rep_.suspended_handles_ && error == 0;
00817        i++)
00818     {
00819       result =
00820         this->handler_rep_.resume_handler_i (this->handler_rep_.current_suspended_info_[i].event_handle_,
00821                                              changes_required);
00822       if (result == -1)
00823         error = 1;
00824     }
00825 
00826   if (!error)
00827     // Then resume all to_be_added_handles
00828     for (size_t i = 0;
00829          i < this->handler_rep_.handles_to_be_added_;
00830          i++)
00831       this->handler_rep_.to_be_added_info_[i].suspend_entry_ = 0;
00832 
00833   // Wake up all threads in WaitForMultipleObjects so that they can
00834   // reconsult the handle set
00835   this->wakeup_all_threads ();
00836 
00837   return error ? -1 : 0;
00838 }

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 930 of file WFMO_Reactor.inl.

References ACE_SEH_FINALLY, ACE_SEH_TRY, dispatch(), and update_state().

Referenced by event_handling().

00931 {
00932   int result = -1;
00933   ACE_SEH_TRY
00934     {
00935       result = this->dispatch (wait_status);
00936     }
00937   ACE_SEH_FINALLY
00938     {
00939       this->update_state ();
00940     }
00941 
00942   return result;
00943 }

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 471 of file WFMO_Reactor.inl.

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

00475 {
00476   ACE_TRACE ("ACE_WFMO_Reactor::schedule_timer");
00477 
00478   if (0 != this->timer_queue_)
00479     {
00480       long result = this->timer_queue_->schedule
00481         (handler,
00482          arg,
00483          timer_queue_->gettimeofday () + delay_time,
00484          interval);
00485 
00486       // Wakeup the owner thread so that it gets the latest timer values
00487       this->notify ();
00488 
00489       return result;
00490     }
00491 
00492   errno = ESHUTDOWN;
00493   return -1;
00494 }

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

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

Implements ACE_Reactor_Impl.

Definition at line 596 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_Reactor_Mask, and mask_ops_i().

00598 {
00599   // This GUARD is necessary since we are updating shared state.
00600   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00601 
00602   return this->mask_ops_i (io_handle,
00603                            masks_to_be_added,
00604                            ACE_Reactor::ADD_MASK);
00605 }

ACE_INLINE int ACE_WFMO_Reactor::schedule_wakeup ACE_Event_Handler event_handler,
ACE_Reactor_Mask  masks_to_be_added
[virtual]
 

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

Implements ACE_Reactor_Impl.

Definition at line 608 of file WFMO_Reactor.inl.

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

00610 {
00611   // This GUARD is necessary since we are updating shared state.
00612   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00613 
00614   return this->mask_ops_i (event_handler->get_handle (),
00615                            masks_to_be_added,
00616                            ACE_Reactor::ADD_MASK);
00617 }

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 1257 of file WFMO_Reactor.cpp.

01258 {
01259   if (this->signal_handler_ != 0 && this->delete_signal_handler_ != 0)
01260     delete this->signal_handler_;
01261   this->signal_handler_ = signal_handler;
01262   this->delete_signal_handler_ = 0;
01263   return 0;
01264 }

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 1985 of file WFMO_Reactor.cpp.

References ACE_Event_Handler::add_reference(), ACE_WFMO_Reactor_Handler_Repository::current_info(), ACE_Event_Handler::handle_signal(), ACE_Event_Handler::reference_counting_policy(), ACE_Event_Handler::remove_reference(), and ACE_WFMO_Reactor_Handler_Repository::unbind().

Referenced by dispatch_handler().

01987 {
01988   // This dispatch is used for non-I/O entires
01989 
01990   // Assign the ``signaled'' HANDLE so that callers can get it.
01991   // siginfo_t is an ACE - specific fabrication. Constructor exists.
01992   siginfo_t sig (event_handle);
01993 
01994   ACE_Event_Handler *event_handler =
01995     this->handler_rep_.current_info ()[slot].event_handler_;
01996 
01997   int requires_reference_counting =
01998     event_handler->reference_counting_policy ().value () ==
01999     ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
02000 
02001   if (requires_reference_counting)
02002     {
02003       event_handler->add_reference ();
02004     }
02005 
02006   // Upcall
02007   if (event_handler->handle_signal (0, &sig) == -1)
02008     this->handler_rep_.unbind (event_handle,
02009                                ACE_Event_Handler::NULL_MASK);
02010 
02011   // Call remove_reference() if needed.
02012   if (requires_reference_counting)
02013     {
02014       event_handler->remove_reference ();
02015     }
02016 
02017   return 0;
02018 }

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 1147 of file WFMO_Reactor.inl.

References ACE_WFMO_Reactor_Handler_Repository::max_size_.

01148 {
01149   // Size of repository minus the 2 used for internal purposes
01150   return this->handler_rep_.max_size_ - 2;
01151 }

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

Suspend all in handle set temporarily.

Implements ACE_Reactor_Impl.

Definition at line 707 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i(), and wakeup_all_threads().

00708 {
00709   ACE_Handle_Set_Iterator handle_iter (handles);
00710   ACE_HANDLE h;
00711   int changes_required = 0;
00712 
00713   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00714 
00715   while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00716     if (this->handler_rep_.suspend_handler_i (h,
00717                                               changes_required) == -1)
00718       return -1;
00719 
00720   // Wake up all threads in WaitForMultipleObjects so that they can
00721   // reconsult the handle set
00722   this->wakeup_all_threads ();
00723 
00724   return 0;
00725 }

ACE_INLINE int ACE_WFMO_Reactor::suspend_handler ACE_HANDLE  handle  )  [virtual]
 

Suspend temporarily.

Implements ACE_Reactor_Impl.

Definition at line 683 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i(), and wakeup_all_threads().

00684 {
00685   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00686 
00687   int changes_required = 0;
00688   int const result =
00689     this->handler_rep_.suspend_handler_i (handle,
00690                                           changes_required);
00691 
00692   if (changes_required)
00693     // Wake up all threads in WaitForMultipleObjects so that they can
00694     // reconsult the handle set
00695     this->wakeup_all_threads ();
00696 
00697   return result;
00698 }

ACE_INLINE int ACE_WFMO_Reactor::suspend_handler ACE_Event_Handler event_handler  )  [virtual]
 

Suspend temporarily. Use <ACE_Event_Handler::get_handle> to get the handle.

Implements ACE_Reactor_Impl.

Definition at line 701 of file WFMO_Reactor.inl.

References ACE_Event_Handler::get_handle().

00702 {
00703   return this->suspend_handler (event_handler->get_handle ());
00704 }

ACE_INLINE int ACE_WFMO_Reactor::suspend_handlers void   )  [virtual]
 

Suspend all temporarily.

Implements ACE_Reactor_Impl.

Definition at line 728 of file WFMO_Reactor.inl.

References ACE_GUARD_RETURN, 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().

00729 {
00730   int error = 0;
00731   int result = 0;
00732   ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00733 
00734   // First suspend all current handles
00735   int changes_required = 0;
00736 
00737   for (size_t i = 0;
00738        i < this->handler_rep_.max_handlep1_ && error == 0;
00739        i++)
00740     {
00741       result =
00742         this->handler_rep_.suspend_handler_i (this->handler_rep_.current_handles_[i],
00743                                               changes_required);
00744       if (result == -1)
00745         error = 1;
00746     }
00747 
00748   if (!error)
00749     // Then suspend all to_be_added_handles
00750     for (size_t i = 0;
00751          i < this->handler_rep_.handles_to_be_added_;
00752          i++)
00753       this->handler_rep_.to_be_added_info_[i].suspend_entry_ = 1;
00754 
00755   // Wake up all threads in WaitForMultipleObjects so that they can
00756   // reconsult the handle set
00757   this->wakeup_all_threads ();
00758 
00759   return error ? -1 : 0;
00760 }

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

Return the current ACE_Timer_Queue.

Implements ACE_Reactor_Impl.

Definition at line 1267 of file WFMO_Reactor.cpp.

01268 {
01269   return this->timer_queue_;
01270 }

int ACE_WFMO_Reactor::timer_queue ACE_Timer_Queue tq  )  [virtual]
 

Set a user-specified timer queue.

Implements ACE_Reactor_Impl.

Definition at line 1273 of file WFMO_Reactor.cpp.

References ACE_Timer_Queue.

01274 {
01275   if (this->timer_queue_ != 0 && this->delete_timer_queue_ != 0)
01276     delete this->timer_queue_;
01277   this->timer_queue_ = tq;
01278   this->delete_timer_queue_ = 0;
01279   return 0;
01280 }

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

Definition at line 2088 of file WFMO_Reactor.cpp.

References ACE_BIT_DISABLED, ACE_BIT_ENABLED, ACE_CLR_BITS, ACE_Reactor_Mask, ACE_SET_BITS, FD_CONNECT_BIT, FD_GROUP_QOS, FD_QOS, 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, and WSANETWORKEVENTS.

Referenced by complex_dispatch_handler().

02091 {
02092   // This method figures out what exactly has happened to the socket
02093   // and then calls appropriate methods.
02094   ACE_Reactor_Mask problems = ACE_Event_Handler::NULL_MASK;
02095 
02096   // Go through the events and do the indicated upcalls. If the handler
02097   // doesn't want to be called back, clear the bit for that event.
02098   // At the end, set the bits back to <events> to request a repeat call.
02099 
02100   long actual_events = events.lNetworkEvents;
02101   int action;
02102 
02103   if (ACE_BIT_ENABLED (actual_events, FD_WRITE))
02104     {
02105       action = event_handler->handle_output (io_handle);
02106       if (action <= 0)
02107         {
02108           ACE_CLR_BITS (actual_events, FD_WRITE);
02109           if (action == -1)
02110             ACE_SET_BITS (problems, ACE_Event_Handler::WRITE_MASK);
02111         }
02112     }
02113 
02114   if (ACE_BIT_ENABLED (actual_events, FD_CONNECT))
02115     {
02116       if (events.iErrorCode[FD_CONNECT_BIT] == 0)
02117         {
02118           // Successful connect
02119           action = event_handler->handle_output (io_handle);
02120           if (action <= 0)
02121             {
02122               ACE_CLR_BITS (actual_events, FD_CONNECT);
02123               if (action == -1)
02124                 ACE_SET_BITS (problems,
02125                               ACE_Event_Handler::CONNECT_MASK);
02126             }
02127         }
02128       // Unsuccessful connect
02129       else
02130         {
02131           action = event_handler->handle_input (io_handle);
02132           if (action <= 0)
02133             {
02134               ACE_CLR_BITS (actual_events, FD_CONNECT);
02135               if (action == -1)
02136                 ACE_SET_BITS (problems,
02137                               ACE_Event_Handler::CONNECT_MASK);
02138             }
02139         }
02140     }
02141 
02142   if (ACE_BIT_ENABLED (actual_events, FD_OOB))
02143     {
02144       action = event_handler->handle_exception (io_handle);
02145       if (action <= 0)
02146         {
02147           ACE_CLR_BITS (actual_events, FD_OOB);
02148           if (action == -1)
02149             ACE_SET_BITS (problems, ACE_Event_Handler::EXCEPT_MASK);
02150         }
02151     }
02152 
02153   if (ACE_BIT_ENABLED (actual_events, FD_READ))
02154     {
02155       action = event_handler->handle_input (io_handle);
02156       if (action <= 0)
02157         {
02158           ACE_CLR_BITS (actual_events, FD_READ);
02159           if (action == -1)
02160             ACE_SET_BITS (problems, ACE_Event_Handler::READ_MASK);
02161         }
02162     }
02163 
02164   if (ACE_BIT_ENABLED (actual_events, FD_CLOSE)
02165       && ACE_BIT_DISABLED (problems, ACE_Event_Handler::READ_MASK))
02166     {
02167       action = event_handler->handle_input (io_handle);
02168       if (action <= 0)
02169         {
02170           ACE_CLR_BITS (actual_events, FD_CLOSE);
02171           if (action == -1)
02172             ACE_SET_BITS (problems, ACE_Event_Handler::READ_MASK);
02173         }
02174     }
02175 
02176           if (ACE_BIT_ENABLED (actual_events, FD_ACCEPT))
02177     {
02178       action = event_handler->handle_input (io_handle);
02179       if (action <= 0)
02180         {
02181           ACE_CLR_BITS (actual_events, FD_ACCEPT);
02182           if (action == -1)
02183             ACE_SET_BITS (problems, ACE_Event_Handler::ACCEPT_MASK);
02184         }
02185     }
02186 
02187   if (ACE_BIT_ENABLED (actual_events, FD_QOS))
02188     {
02189       action = event_handler->handle_qos (io_handle);
02190       if (action <= 0)
02191         {
02192           ACE_CLR_BITS (actual_events, FD_QOS);
02193           if (action == -1)
02194             ACE_SET_BITS (problems, ACE_Event_Handler::QOS_MASK);
02195         }
02196     }
02197 
02198   if (ACE_BIT_ENABLED (actual_events, FD_GROUP_QOS))
02199     {
02200       action = event_handler->handle_group_qos (io_handle);
02201       if (action <= 0)
02202         {
02203           ACE_CLR_BITS (actual_events, FD_GROUP_QOS);
02204           if (action == -1)
02205             ACE_SET_BITS (problems, ACE_Event_Handler::GROUP_QOS_MASK);
02206         }
02207     }
02208 
02209   events.lNetworkEvents = actual_events;
02210   return problems;
02211 }

int ACE_WFMO_Reactor::update_state void   )  [protected, virtual]
 

Update the state of the handler repository.

Definition at line 2215 of file WFMO_Reactor.cpp.

References ACE_GUARD_RETURN, active_threads_, change_owner(), change_state_thread_, ACE_WFMO_Reactor_Handler_Repository::changes_required(), 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().

02216 {
02217   // This GUARD is necessary since we are updating shared state.
02218   ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
02219 
02220   // Decrement active threads
02221   --this->active_threads_;
02222 
02223   // Check if the state of the handler repository has changed or new
02224   // owner has to be set
02225   if (this->handler_rep_.changes_required () || this->new_owner ())
02226     {
02227       if (this->change_state_thread_ == 0)
02228         // Try to become the thread which will be responsible for the
02229         // changes
02230         {
02231           this->change_state_thread_ = ACE_Thread::self ();
02232           // Make sure no new threads are allowed to enter
02233           this->ok_to_wait_.reset ();
02234 
02235           if (this->active_threads_ > 0)
02236             // Check for other active threads
02237             {
02238               // Wake up all other threads
02239               this->wakeup_all_threads_.signal ();
02240               // Release <lock_>
02241               monitor.release ();
02242               // Go to sleep waiting for all other threads to get done
02243               this->waiting_to_change_state_.wait ();
02244               // Re-acquire <lock_> again
02245               monitor.acquire ();
02246             }
02247 
02248           // Note that make_changes() calls into user code which can
02249           // request other changes.  So keep looping until all
02250           // requested changes are completed.
02251           while (this->handler_rep_.changes_required ())
02252             // Make necessary changes to the handler repository
02253             this->handler_rep_.make_changes ();
02254           if (this->new_owner ())
02255             // Update the owner
02256             this->change_owner ();
02257           // Turn off <wakeup_all_threads_>
02258           this->wakeup_all_threads_.reset ();
02259           // Let everyone know that it is ok to go ahead
02260           this->ok_to_wait_.signal ();
02261           // Reset this flag
02262           this->change_state_thread_ = 0;
02263         }
02264       else if (this->active_threads_ == 0)
02265         // This thread did not get a chance to become the change
02266         // thread. If it is the last one out, it will wakeup the
02267         // change thread
02268         this->waiting_to_change_state_.signal ();
02269     }
02270   // This is if we were woken up explicitily by the user and there are
02271   // no state changes required.
02272   else if (this->active_threads_ == 0)
02273     // Turn off <wakeup_all_threads_>
02274     this->wakeup_all_threads_.reset ();
02275 
02276   return 0;
02277 }

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 841 of file WFMO_Reactor.inl.

00842 {
00843   // Since the WFMO_Reactor does use event associations, this function
00844   // always return 1.
00845   return 1;
00846 }

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 1795 of file WFMO_Reactor.cpp.

References ACE_WFMO_Reactor_Handler_Repository::handles().

Referenced by event_handling().

01797 {
01798   // Wait for any of handles_ to be active, or until timeout expires.
01799   // If <alertable> is enabled allow asynchronous completion of
01800   // ReadFile and WriteFile operations.
01801 
01802 #if defined (ACE_HAS_PHARLAP) || defined (ACE_HAS_WINCE)
01803   // PharLap doesn't do async I/O and doesn't implement
01804   // WaitForMultipleObjectsEx, so use WaitForMultipleObjects.
01805   ACE_UNUSED_ARG (alertable);
01806   return ::WaitForMultipleObjects (this->handler_rep_.max_handlep1 (),
01807                                    this->handler_rep_.handles (),
01808                                    FALSE,
01809                                    timeout);
01810 #else
01811   return ::WaitForMultipleObjectsEx (this->handler_rep_.max_handlep1 (),
01812                                      this->handler_rep_.handles (),
01813                                      FALSE,
01814                                      timeout,
01815                                      alertable);
01816 #endif /* ACE_HAS_PHARLAP */
01817 }

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 952 of file WFMO_Reactor.inl.

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().

00953 {
00954   this->wakeup_all_threads_.signal ();
00955 }

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 1059 of file WFMO_Reactor.cpp.

References ACE_NOTSUP_RETURN.

01060 {
01061   ACE_NOTSUP_RETURN (-1);
01062 }


Friends And Related Function Documentation

friend class ACE_WFMO_Reactor_Handler_Repository [friend]
 

Definition at line 645 of file WFMO_Reactor.h.

friend class ACE_WFMO_Reactor_Test [friend]
 

Definition at line 646 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 1167 of file WFMO_Reactor.h.

size_t ACE_WFMO_Reactor::active_threads_ [protected]
 

Count of currently active threads.

Definition at line 1313 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 and handles

Definition at line 1334 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 handle set

Definition at line 1330 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 1341 of file WFMO_Reactor.h.

int ACE_WFMO_Reactor::delete_handler_rep_ [protected]
 

Keeps track of whether we should delete the handler repository.

Definition at line 1269 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 1275 of file WFMO_Reactor.h.

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 1259 of file WFMO_Reactor.h.

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 1266 of file WFMO_Reactor.h.

ACE_WFMO_Reactor_Handler_Repository ACE_WFMO_Reactor::handler_rep_ [protected]
 

Table that maps to <ACE_Event_Handler *>'s.

Definition at line 1292 of file WFMO_Reactor.h.

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 1286 of file WFMO_Reactor.h.

ACE_Lock_Adapter<ACE_Process_Mutex> ACE_WFMO_Reactor::lock_adapter_ [protected]
 

Adapter used to return internal lock to outside world.

Definition at line 1289 of file WFMO_Reactor.h.

ACE_thread_t ACE_WFMO_Reactor::new_owner_ [protected]
 

The owner to be of the WFMO_Reactor.

Definition at line 1326 of file WFMO_Reactor.h.

Referenced by change_owner(), new_owner(), and owner().

ACE_Reactor_Notify* ACE_WFMO_Reactor::notify_handler_ [protected]
 

Used when is called.

Definition at line 1272 of file WFMO_Reactor.h.

ACE_Manual_Event ACE_WFMO_Reactor::ok_to_wait_ [protected]
 

A manual event used to block threads from proceeding into WaitForMultipleObjects

Definition at line 1296 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 1337 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 1323 of file WFMO_Reactor.h.

ACE_Sig_Handler* ACE_WFMO_Reactor::signal_handler_ [protected]
 

Handle signals without requiring global/static variables.

Definition at line 1255 of file WFMO_Reactor.h.

ACE_Timer_Queue* ACE_WFMO_Reactor::timer_queue_ [protected]
 

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

Definition at line 1262 of file WFMO_Reactor.h.

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 1310 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 are bounded and unbound from the handler repository).

Definition at line 1303 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 is signaled.

Definition at line 1306 of file WFMO_Reactor.h.


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