/* -*- C++ -*- */ // $Id$ // ============================================================================ // // = LIBRARY // ace // // = FILENAME // WIN_Proactor.h // // = AUTHOR // Irfan Pyarali (irfan@cs.wustl.edu), // Tim Harrison (harrison@cs.wustl.edu) and // Alexander Babu Arulanthu // // ============================================================================ #if !defined (ACE_WIN32_PROACTOR_H) #define ACE_WIN32_PROACTOR_H #include "ace/OS.h" #include "ace/WIN32_Asynch_IO.h" #include "ace/Thread_Manager.h" #include "ace/Event_Handler.h" #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) // WIN implementation of the Proactor. #include "ace/Timer_Queue.h" #include "ace/Timer_List.h" #include "ace/Timer_Heap.h" #include "ace/Timer_Wheel.h" #include "ace/Proactor_Impl.h" // Forward declarations. class ACE_WIN32_Asynch_Result; //class ACE_WIN32_Asynch_Operation; class ACE_WIN32_Proactor_Timer_Handler; class ACE_WIN32_Proactor; class ACE_Export ACE_WIN32_Proactor_Handle_Timeout_Upcall { // = TITLE // Functor for . // // = DESCRIPTION // This class implements the functor required by the Timer // Queue to call on ACE_Handlers. public: friend class ACE_WIN32_Proactor; // Proactor has special privileges, access needed to: proactor (). typedef ACE_Timer_Queue_T TIMER_QUEUE; ACE_WIN32_Proactor_Handle_Timeout_Upcall (void); // Constructor. int timeout (TIMER_QUEUE &timer_queue, ACE_Handler *handler, const void *arg, const ACE_Time_Value &cur_time); // This method is called when the timer expires. int cancellation (TIMER_QUEUE &timer_queue, ACE_Handler *handler); // This method is called when the timer is canceled. int deletion (TIMER_QUEUE &timer_queue, ACE_Handler *handler, const void *arg); // This method is called when the timer queue is destroyed and the // timer is still contained in it. protected: int win32_proactor (ACE_WIN32_Proactor &win32_proactor); // Set the proactor. This will fail, if one is already set! ACE_WIN32_Proactor *win32_proactor_; // Handle to the proactor. This is needed for the completion port. }; class ACE_Export ACE_WIN32_Proactor : public ACE_Proactor_Impl { // = TITLE // A manager for asynchronous event demultiplexing. // // = DESCRIPTION // See the Proactor pattern description at // http://www.cs.wustl.edu/~schmidt/proactor.ps.gz for more // details. public: friend class ACE_WIN32_Proactor_Timer_Handler; // Timer Handler has special privileges because Access needed to: // thr_mgr_ friend class ACE_WIN32_Proactor_Handle_Timeout_Upcall; // Access needed to: Asynch_Timer, and completion_port_. // = Here are the typedefs that the uses. typedef ACE_Timer_Queue_T TIMER_QUEUE; typedef ACE_Timer_Queue_Iterator_T TIMER_QUEUE_ITERATOR; typedef ACE_Timer_List_T TIMER_LIST; typedef ACE_Timer_List_Iterator_T TIMER_LIST_ITERATOR; typedef ACE_Timer_Heap_T TIMER_HEAP; typedef ACE_Timer_Heap_Iterator_T TIMER_HEAP_ITERATOR; typedef ACE_Timer_Wheel_T TIMER_WHEEL; typedef ACE_Timer_Wheel_Iterator_T TIMER_WHEEL_ITERATOR; ACE_WIN32_Proactor (size_t number_of_threads = 0, TIMER_QUEUE *tq = 0, int used_with_reactor_event_loop = 0); // A do nothing constructor. virtual ~ACE_WIN32_Proactor (void); // Virtual destruction. virtual int close (void); // Close the IO completion port. virtual int register_handle (ACE_HANDLE handle, const void *completion_key); // This method adds the to the I/O completion port. This // function is a no-op function for Unix systems. // = Timer management. virtual long schedule_timer (ACE_Handler &handler, const void *act, const ACE_Time_Value &time); // Schedule a that will expire after