NAME

ACE_Proactor - A Proactor for asynchronous I/O events.

SYNOPSIS

#include <ace/Proactor.h>

class ACE_Proactor : public ACE_Event_Handler { public: friend class ACE_Proactor_Timer_Handler; friend class ACE_Proactor_Handle_Timeout_Upcall; typedef ACE_Timer_Queue_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> Timer_Queue; typedef ACE_Timer_Queue_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> Timer_Queue_Iterator; typedef ACE_Timer_List_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> Timer_List; typedef ACE_Timer_List_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> Timer_List_Iterator; typedef ACE_Timer_Heap_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> Timer_Heap; typedef ACE_Timer_Heap_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> Timer_Heap_Iterator; typedef ACE_Timer_Wheel_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> Timer_Wheel; typedef ACE_Timer_Wheel_Iterator_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> Timer_Wheel_Iterator; ACE_Proactor ( size_t number_of_threads = 0, Timer_Queue *tq = 0, int used_with_reactor_event_loop = 0 ); virtual ~ACE_Proactor (void); static ACE_Proactor *instance (size_t threads = 0); static ACE_Proactor *instance (ACE_Proactor *); static void close_singleton (void); static int run_event_loop (void); static int run_event_loop (ACE_Time_Value &tv); static int end_event_loop (void); static int event_loop_done (void); virtual int close (void); virtual int register_handle ( ACE_HANDLE handle, const void *completion_key ); virtual long schedule_timer ( ACE_Handler &handler, const void *act, const ACE_Time_Value &time ); virtual long schedule_repeating_timer ( ACE_Handler &handler, const void *act, const ACE_Time_Value &interval ); virtual long schedule_timer ( ACE_Handler &handler, const void *act, const ACE_Time_Value &time, const ACE_Time_Value &interval ); virtual int cancel_timer ( ACE_Handler &handler, int dont_call_handle_close = 1 ); virtual int cancel_timer ( long timer_id, const void **act = 0, int dont_call_handle_close = 1 ); virtual int handle_events (ACE_Time_Value &wait_time); virtual int handle_events (void); virtual int post_completion (ACE_Asynch_Result *result); int wake_up_dispatch_threads (void); int close_dispatch_threads (int wait); size_t number_of_threads (void) const; void number_of_threads (size_t threads); Timer_Queue *timer_queue (void) const; void timer_queue (Timer_Queue *); virtual ACE_HANDLE get_handle (void) const; inline ACE_Proactor (size_t = 0, Timer_Queue * = 0); static ACE_Proactor *instance (size_t threads = 0); static ACE_Proactor *instance (ACE_Proactor *); static void close_singleton (void); static int run_event_loop (void); static int run_event_loop (ACE_Time_Value &tv); static int end_event_loop (void); static sig_atomic_t event_loop_done (void); protected: virtual int handle_signal ( int signum, siginfo_t * = 0, ucontext_t * = 0 ); virtual int handle_close ( ACE_HANDLE handle, ACE_Reactor_Mask close_mask ); void application_specific_code ( ACE_Asynch_Result *asynch_result, u_long bytes_transferred, int success, const void *completion_key, u_long error ); virtual int handle_events (unsigned long milli_seconds);

class Asynch_Timer : protected ACE_Asynch_Result { public: friend class ACE_Proactor_Handle_Timeout_Upcall; Asynch_Timer ( ACE_Handler &handler, const void *act, const ACE_Time_Value &tv, ACE_HANDLE event = ACE_INVALID_HANDLE ); protected: virtual void complete ( u_long bytes_transferred, int success, const void *completion_key, u_long error = 0 ); ACE_Time_Value time_; };

ACE_HANDLE completion_port_; size_t number_of_threads_; Timer_Queue *timer_queue_; int delete_timer_queue_; ACE_Proactor_Timer_Handler *timer_handler_; ACE_Thread_Manager thr_mgr_; ACE_Auto_Event event_; int used_with_reactor_event_loop_; private: static ACE_Proactor *proactor_; static int delete_proactor_; static sig_atomic_t end_event_loop_; };

DESCRIPTION

A manager for the I/O completion port.

Proactor event loop management methods.

static int run_event_loop (void);

static int run_event_loop (ACE_Time_Value &tv);

static int end_event_loop (void);

static int event_loop_done (void);

virtual int close (void);

virtual int register_handle (
    ACE_HANDLE handle,
    const void *completion_key
    );

Timer management.

virtual long schedule_timer (
    ACE_Handler &handler,
    const void *act,
    const ACE_Time_Value &time
    );

virtual long schedule_repeating_timer (
    ACE_Handler &handler,
    const void *act,
    const ACE_Time_Value &interval
    );

Same as above except interval it is used to reschedule the handler automatically.

virtual long schedule_timer (
    ACE_Handler &handler,
    const void *act,
    const ACE_Time_Value &time,
    const ACE_Time_Value &interval
    );

virtual int cancel_timer (
    ACE_Handler &handler,
    int dont_call_handle_close = 1
    );

virtual int cancel_timer (
    long timer_id,
    const void **act = 0,
    int dont_call_handle_close = 1
    );

virtual int handle_events (ACE_Time_Value &wait_time);

virtual int handle_events (void);

virtual int post_completion (ACE_Asynch_Result *result);

int wake_up_dispatch_threads (void);

int close_dispatch_threads (int wait);

size_t number_of_threads (void) const;

void number_of_threads (size_t threads);

Timer_Queue *timer_queue (void) const;

void timer_queue (Timer_Queue *);

virtual ACE_HANDLE get_handle (void) const;

AUTHOR

Irfan Pyarali (irfan@cs.wustl.edu) Tim Harrison (harrison@cs.wustl.edu)

LIBRARY

ace