From 2ceb56853bcd37ef07a0ea8eaa7839321327e4fc Mon Sep 17 00:00:00 2001 From: irfan Date: Wed, 31 Dec 1997 22:33:55 +0000 Subject: *** empty log message *** --- ace/WFMO_Reactor.h | 180 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 111 insertions(+), 69 deletions(-) (limited to 'ace/WFMO_Reactor.h') diff --git a/ace/WFMO_Reactor.h b/ace/WFMO_Reactor.h index 208d57f584b..c0bef5d74c0 100644 --- a/ace/WFMO_Reactor.h +++ b/ace/WFMO_Reactor.h @@ -31,8 +31,10 @@ class ACE_Handle_Set; class ACE_Export ACE_Wakeup_All_Threads_Handler : public ACE_Event_Handler { // = TITLE + // // This is a helper class whose sole purpose is to handle events // on wakeup_all_threads_> + // public: virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); // Called when the wakeup_all_threads_> @@ -41,6 +43,7 @@ public: class ACE_Export ACE_WFMO_Reactor_Handler_Repository { // = TITLE + // // Used to map s onto the appropriate // * and other information. // @@ -50,11 +53,13 @@ public: class Common_Info { // = TITLE + // // This struct contains the necessary information for every // entry. The reason the event is not in this // structure is because we need to pass an event array into // WaitForMultipleObjects and therefore keeping the events // seperate makes sense. + // public: int io_entry_; // This indicates whether this entry is for I/O or for a regular @@ -64,18 +69,19 @@ public: // The assosiated ACE_HANDLE io_handle_; - // The I/O handle related to the . - // This entry is only valid if the flag is true. + // The I/O handle related to the . This entry is + // only valid if the flag is true. long network_events_; - // This is the set of events that the is interested in - // This entry is only valid if the flag is true. + // This is the set of events that the is + // interested in This entry is only valid if the flag + // is true. int delete_event_; // This flag indicates that created the event on // behalf of the user. Therefore we need to clean this up when the - // removes itself from . - // This entry is only valid if the flag is true. + // removes itself from . This entry + // is only valid if the flag is true. Common_Info (void); // Constructor used for initializing the structure @@ -97,14 +103,17 @@ public: class Current_Info : public Common_Info { // = TITLE + // // This structure inherits from the common structure to add // information for current entries. + // public: int delete_entry_; // This is set when the entry needed to be deleted. ACE_Reactor_Mask close_masks_; - // These are the masks related to for the . + // These are the masks related to for the + // . int suspend_entry_; // This is set when the entry needed to be suspended. @@ -135,8 +144,10 @@ public: class To_Be_Added_Info : public Common_Info { // = TITLE + // // This structure inherits from the common structure to add // information for entries. + // public: ACE_HANDLE event_handle_; // Handle for the event @@ -163,8 +174,10 @@ public: class Suspended_Info : public Common_Info { // = TITLE + // // This structure inherits from the common structure to add // information for suspended entries. + // public: ACE_HANDLE event_handle_; // Handle for the event @@ -173,7 +186,8 @@ public: // This is set when the entry needed to be deleted. ACE_Reactor_Mask close_masks_; - // These are the masks related to for the . + // These are the masks related to for the + // . int resume_entry_; // This is set when the entry needed to be resumed. @@ -249,7 +263,8 @@ public: // Maximum ACE_HANDLE value, plus 1. ACE_HANDLE *handles (void) const; - // Pointer to the beginning of the current array of *'s. + // Pointer to the beginning of the current array of + // *'s. Current_Info *current_info (void) const; // Pointer to the beginning of the current array of @@ -347,18 +362,21 @@ protected: class ACE_Export ACE_WFMO_Reactor_Notify : public ACE_Event_Handler { // = TITLE - // Unblock the from its event loop, passing it an - // optional to dispatch. + // + // Unblock the from its event loop, passing + // it an optional to dispatch. // // = DESCRIPTION + // // This implementation is necessary for cases where the - // is run in a multi-threaded program. In this - // case, we need to be able to unblock WaitForMultipleObjects() - // when updates occur other than in the main - // thread. To do this, we signal an auto-reset event the - // is listening on. If an - // and is passed to , the appropriate - // method is dispatched. + // is run in a multi-threaded program. In + // this case, we need to be able to unblock + // WaitForMultipleObjects() when updates occur other than in the + // main thread. To do this, we signal an + // auto-reset event the is listening on. If + // an and is passed to + // , the appropriate method is dispatched. + // public: ACE_WFMO_Reactor_Notify (void); // Constructor @@ -374,9 +392,9 @@ public: // occur. All we do is enqueue and onto the // and wakeup the WFMO_Reactor by signaling its // handle. 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). + // 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). virtual ACE_HANDLE get_handle (void) const; // Returns a handle to the . @@ -404,9 +422,9 @@ private: // Pointer to the wfmo_reactor's timer queue. virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0); - // Called when the notification event waited on by - // is signaled. This dequeues all pending and - // dispatches them. + // Called when the notification event waited on by + // is signaled. This dequeues all pending + // and dispatches them. ACE_Auto_Event wakeup_one_thread_; // An auto event is used so that we can it to wakeup one @@ -432,15 +450,32 @@ private: class ACE_Export ACE_WFMO_Reactor : public ACE_Reactor_Impl { // = TITLE + // // An object oriented event demultiplexor and event handler // WFMO_Reactor for Win32 WaitForMultipleObjects // // = DESCRIPTION - // The ACE_WFMO_Reactor is an object-oriented event demultiplexor - // and event handler Reactor. The sources of events that the - // ACE_WFMO_Reactor waits for and dispatches includes I/O events, - // general Win32 synchronization events (such as mutexes, - // semaphores, threads, etc.) and timer events. + // + // The ACE_WFMO_Reactor is an object-oriented event + // demultiplexor and event handler Reactor. The sources of + // events that the ACE_WFMO_Reactor waits for and dispatches + // includes I/O events, general Win32 synchronization events + // (such as mutexes, semaphores, threads, etc.) and timer + // events. + // + // Note that changes to the state of WFMO_Reactor are not + // instantaneous. Most changes (registration, removal, + // suspension, and resumption of handles, and changes in + // ownership) are made when the WFMO_Reactor reaches a stable + // state. Users should be careful, specially when removing + // handlers. This is because the WFMO_Reactor will call + // handle_close on the handler when it is finally removed and + // not when remove_handler is called. If the handler is not + // going to be around when the WFMO_Reactor calls + // handler->handle_close(), use the DONT_CALL flag with + // remove_handler(). Or else, dynamically allocate the handler, + // and then call "delete this" inside handler->handle_close(). + // public: friend class ACE_WFMO_Reactor_Handler_Repository; friend class ACE_WFMO_Reactor_Test; @@ -448,8 +483,8 @@ public: enum { DEFAULT_SIZE = MAXIMUM_WAIT_OBJECTS - 2 - // Default size of the WFMO_Reactor's handle table. Two slots will be - // added to the parameter in the constructor and open + // Default size of the WFMO_Reactor's handle table. Two slots will + // be added to the parameter in the constructor and open // methods which will store handles used for internal management // purposes. }; @@ -464,17 +499,17 @@ public: int unused = 0, ACE_Sig_Handler * = 0, ACE_Timer_Queue * = 0); - // Initialize with size . Two slots will be - // added to the parameter which will store handles used for - // internal management purposes. + // Initialize with size . Two slots will + // be added to the parameter which will store handles used + // for internal management purposes. virtual int open (size_t size = DEFAULT_SIZE, int restart = 0, ACE_Sig_Handler * = 0, ACE_Timer_Queue * = 0); - // Initialize with size . Two slots will be - // added to the parameter which will store handles used for - // internal management purposes. + // Initialize with size . Two slots will + // be added to the parameter which will store handles used + // for internal management purposes. virtual int set_sig_handler (ACE_Sig_Handler *signal_handler); // Use a user specified signal handler instead. @@ -529,13 +564,13 @@ public: virtual int register_handler (ACE_Event_Handler *event_handler, ACE_HANDLE event_handle = ACE_INVALID_HANDLE); - // Register an . 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. + // Register an . 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. virtual int register_handler (ACE_HANDLE event_handle, ACE_HANDLE io_handle, @@ -543,12 +578,13 @@ public: ACE_Reactor_Mask mask); // Register an . 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 - // callback will be invoked on the + // == 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 callback will be invoked on + // the virtual int register_handler (ACE_HANDLE io_handle, ACE_Event_Handler *event_handler, @@ -567,7 +603,8 @@ public: virtual int register_handler (const ACE_Handle_Set &handles, ACE_Event_Handler *event_handler, ACE_Reactor_Mask mask); - // Register with all the in the . + // Register with all the in the + // . virtual int register_handler (int signum, ACE_Event_Handler *new_sh, @@ -597,14 +634,15 @@ public: ACE_Reactor_Mask mask); // Removes from the . If == // then the method of - // the is not invoked. Note that the can either be the - // or the + // 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 + // 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 + // virtual int remove_handler (const ACE_Handle_Set &handle_set, ACE_Reactor_Mask); @@ -628,7 +666,8 @@ public: // = Suspend and resume Handlers. virtual int suspend_handler (ACE_Event_Handler *event_handler); - // Suspend temporarily. Use get_handle()> to get the handle. + // Suspend temporarily. Use + // get_handle()> to get the handle. virtual int suspend_handler (ACE_HANDLE handle); // Suspend temporarily. @@ -640,7 +679,8 @@ public: // Suspend all temporarily. virtual int resume_handler (ACE_Event_Handler *event_handler); - // Resume . Use get_handle()> to get the handle. + // Resume . Use get_handle()> to get + // the handle. virtual int resume_handler (ACE_HANDLE handle); // Resume . @@ -721,11 +761,12 @@ public: virtual int notify (ACE_Event_Handler * = 0, ACE_Reactor_Mask = ACE_Event_Handler::EXCEPT_MASK, ACE_Time_Value * = 0); - // 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). + // 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). virtual void max_notify_iterations (int); // Set the maximum number of times that the @@ -903,6 +944,7 @@ protected: ACE_Process_Mutex lock_; // 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 @@ -938,12 +980,12 @@ protected: // Count of currently active threads ACE_thread_t owner_; - // 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. + // 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. ACE_thread_t new_owner_; // The owner to be of the WFMO_Reactor -- cgit v1.2.1