/* -*- C++ -*- */ // $Id: Proactor.h,v // ============================================================================ // // = LIBRARY // ace // // = FILENAME // Proactor.h // // = AUTHOR // Irfan Pyarali (irfan@cs.wustl.edu) // Tim Harrison (harrison@cs.wustl.edu) // // ============================================================================ #if !defined (ACE_PROACTOR_H) #define ACE_PROACTOR_H #include "ace/Asynch_IO.h" #include "ace/Thread_Manager.h" #include "ace/Event_Handler.h" #include "ace/Timer_Queue.h" #include "ace/Timer_List.h" #include "ace/Timer_Heap.h" #include "ace/Timer_Wheel.h" #if defined (ACE_WIN32) // This only works on Win32 platforms // Forward declarations. class ACE_Asynch_Result; class ACE_Proactor_Timer_Handler; class ACE_Proactor; class ACE_Export ACE_Proactor_Handle_Timeout_Upcall // = TITLE // Functor for Timer_Queues. // // = DESCRIPTION // // This class implements the functor required by the Timer // Queue to call on ACE_Handlers. { friend class ACE_Proactor; // Proactor has special privileges // Access needed to: proactor () public: typedef ACE_Timer_Queue_T TIMER_QUEUE; ACE_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 proactor (ACE_Proactor &proactor); // Set the proactor. This will fail, if one is already set! ACE_Proactor *proactor_; // Handle to the proactor. This is needed for the completion port. }; class ACE_Export ACE_Proactor : public ACE_Event_Handler // // = TITLE // // A Proactor for asynchronous I/O events. // // = DESCRIPTION // // A manager for the I/O completion port. { friend class ACE_Proactor_Timer_Handler; // Timer Handler has special privileges because // Access needed to: thr_mgr_ friend class ACE_Proactor_Handle_Timeout_Upcall; // Access needed to: Asynch_Timer, and completion_port_ public: // Here are the typedef for Timer_Queue, Timer_List, and Timer_Heap // for the Proactor (add to the ease of use of these template // classes). 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_Proactor (size_t number_of_threads = 0, Timer_Queue *tq = 0, int used_with_reactorEx_event_loop = 0); // A do nothing constructor. virtual ~ACE_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 // = Timer management. virtual int schedule_timer (ACE_Handler &handler, const void *act, const ACE_Time_Value &time); // Schedule a that will expire after