NAME

ACE_Proactor - A manager for asynchronous event demultiplexing.

SYNOPSIS

#include <ace/Proactor.h>

class ACE_Proactor { public: friend class ACE_Proactor_Timer_Handler; typedef ACE_Timer_Queue_T<ACE_Handler *, ACE_Proactor_Handle_Timeout_Upcall, ACE_SYNCH_RECURSIVE_MUTEX> TIMER_QUEUE; ACE_Proactor ( ACE_Proactor_Impl *implementation = 0, int delete_implementation = 0, TIMER_QUEUE *tq = 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); 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 *timer_queue); virtual ACE_HANDLE get_handle (void) const; virtual ACE_Proactor_Impl *implementation (void) const; virtual ACE_Asynch_Read_Stream_Impl *create_asynch_read_stream ( void ); virtual ACE_Asynch_Write_Stream_Impl *create_asynch_write_stream ( void ); virtual ACE_Asynch_Read_File_Impl *create_asynch_read_file (void); virtual ACE_Asynch_Write_File_Impl *create_asynch_write_file ( void ); virtual ACE_Asynch_Accept_Impl *create_asynch_accept (void); virtual ACE_Asynch_Transmit_File_Impl *create_asynch_transmit_file ( void ); virtual ACE_Asynch_Read_Stream_Result_Impl *create_asynch_read_stream_result ( ACE_Handler &handler, ACE_HANDLE handle, ACE_Message_Block &message_block, u_long bytes_to_read, const void* act, ACE_HANDLE event = ACE_INVALID_HANDLE, int priority = 0, int signal_number = ACE_SIGRTMIN ); virtual ACE_Asynch_Write_Stream_Result_Impl *create_asynch_write_stream_result ( ACE_Handler &handler, ACE_HANDLE handle, ACE_Message_Block &message_block, u_long bytes_to_write, const void* act, ACE_HANDLE event = ACE_INVALID_HANDLE, int priority = 0, int signal_number = ACE_SIGRTMIN ); virtual ACE_Asynch_Read_File_Result_Impl *create_asynch_read_file_result ( ACE_Handler &handler, ACE_HANDLE handle, ACE_Message_Block &message_block, u_long bytes_to_read, const void* act, u_long offset, u_long offset_high, ACE_HANDLE event = ACE_INVALID_HANDLE, int priority = 0, int signal_number = ACE_SIGRTMIN ); virtual ACE_Asynch_Write_File_Result_Impl *create_asynch_write_file_result ( ACE_Handler &handler, ACE_HANDLE handle, ACE_Message_Block &message_block, u_long bytes_to_write, const void* act, u_long offset, u_long offset_high, ACE_HANDLE event = ACE_INVALID_HANDLE, int priority = 0, int signal_number = ACE_SIGRTMIN ); virtual ACE_Asynch_Accept_Result_Impl *create_asynch_accept_result ( ACE_Handler &handler, ACE_HANDLE listen_handle, ACE_HANDLE accept_handle, ACE_Message_Block &message_block, u_long bytes_to_read, const void* act, ACE_HANDLE event = ACE_INVALID_HANDLE, int priority = 0, int signal_number = ACE_SIGRTMIN ); virtual ACE_Asynch_Transmit_File_Result_Impl *create_asynch_transmit_file_result ( ACE_Handler &handler, ACE_HANDLE socket, ACE_HANDLE file, ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, u_long bytes_to_write, u_long offset, u_long offset_high, u_long bytes_per_send, u_long flags, const void *act, ACE_HANDLE event = ACE_INVALID_HANDLE, int priority = 0, int signal_number = ACE_SIGRTMIN ); virtual ACE_Asynch_Result_Impl *create_asynch_timer ( ACE_Handler &handler, const void *act, const ACE_Time_Value &tv, ACE_HANDLE event = ACE_INVALID_HANDLE, int priority = 0, int signal_number = ACE_SIGRTMIN ); 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: static int post_wakeup_completions (int how_many); virtual void implementation (ACE_Proactor_Impl *implementation); ACE_Proactor_Impl *implementation_; int delete_implementation_; static ACE_Proactor *proactor_; static int delete_proactor_; ACE_Proactor_Timer_Handler *timer_handler_; ACE_Thread_Manager thr_mgr_; TIMER_QUEUE *timer_queue_; int delete_timer_queue_; static sig_atomic_t end_event_loop_; static sig_atomic_t event_loop_thread_count_; private: ACE_Proactor (const ACE_Proactor &); ACE_Proactor &operator= (const ACE_Proactor &); };

DESCRIPTION

See the Proactor pattern description at http://www.cs.wustl.edu/~schmidt/proactor.ps.gz for more details.

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

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 *timer_queue);

virtual ACE_HANDLE get_handle (void) const;

virtual ACE_Proactor_Impl *implementation (void) const;

Factory methods for the operations

Note that the user does not have to use or know about these methods.
virtual ACE_Asynch_Read_Stream_Impl *create_asynch_read_stream (void);

virtual ACE_Asynch_Write_Stream_Impl *create_asynch_write_stream (
    void
    );

virtual ACE_Asynch_Read_File_Impl *create_asynch_read_file (void);

virtual ACE_Asynch_Write_File_Impl *create_asynch_write_file (void);

virtual ACE_Asynch_Accept_Impl *create_asynch_accept (void);

virtual ACE_Asynch_Transmit_File_Impl *create_asynch_transmit_file (
    void
    );

Factory methods for the results

Note that the user does not have to use or know about these methods unless they want to "fake" results.
virtual ACE_Asynch_Read_Stream_Result_Impl *create_asynch_read_stream_result (
    ACE_Handler &handler,
    ACE_HANDLE handle,
    ACE_Message_Block &message_block,
    u_long bytes_to_read,
    const void* act,
    ACE_HANDLE event = ACE_INVALID_HANDLE,
    int priority = 0,
    int signal_number = ACE_SIGRTMIN
    );

virtual ACE_Asynch_Write_Stream_Result_Impl *create_asynch_write_stream_result (
    ACE_Handler &handler,
    ACE_HANDLE handle,
    ACE_Message_Block &message_block,
    u_long bytes_to_write,
    const void* act,
    ACE_HANDLE event = ACE_INVALID_HANDLE,
    int priority = 0,
    int signal_number = ACE_SIGRTMIN
    );

virtual ACE_Asynch_Read_File_Result_Impl *create_asynch_read_file_result (
    ACE_Handler &handler,
    ACE_HANDLE handle,
    ACE_Message_Block &message_block,
    u_long bytes_to_read,
    const void* act,
    u_long offset,
    u_long offset_high,
    ACE_HANDLE event = ACE_INVALID_HANDLE,
    int priority = 0,
    int signal_number = ACE_SIGRTMIN
    );

virtual ACE_Asynch_Write_File_Result_Impl *create_asynch_write_file_result (
    ACE_Handler &handler,
    ACE_HANDLE handle,
    ACE_Message_Block &message_block,
    u_long bytes_to_write,
    const void* act,
    u_long offset,
    u_long offset_high,
    ACE_HANDLE event = ACE_INVALID_HANDLE,
    int priority = 0,
    int signal_number = ACE_SIGRTMIN
    );

virtual ACE_Asynch_Accept_Result_Impl *create_asynch_accept_result (
    ACE_Handler &handler,
    ACE_HANDLE listen_handle,
    ACE_HANDLE accept_handle,
    ACE_Message_Block &message_block,
    u_long bytes_to_read,
    const void* act,
    ACE_HANDLE event = ACE_INVALID_HANDLE,
    int priority = 0,
    int signal_number = ACE_SIGRTMIN
    );

virtual ACE_Asynch_Transmit_File_Result_Impl *create_asynch_transmit_file_result (
    ACE_Handler &handler,
    ACE_HANDLE socket,
    ACE_HANDLE file,
    ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
    u_long bytes_to_write,
    u_long offset,
    u_long offset_high,
    u_long bytes_per_send,
    u_long flags,
    const void *act,
    ACE_HANDLE event = ACE_INVALID_HANDLE,
    int priority = 0,
    int signal_number = ACE_SIGRTMIN
    );

virtual ACE_Asynch_Result_Impl *create_asynch_timer (
    ACE_Handler &handler,
    const void *act,
    const ACE_Time_Value &tv,
    ACE_HANDLE event = ACE_INVALID_HANDLE,
    int priority = 0,
    int signal_number = ACE_SIGRTMIN
    );

AUTHOR

Irfan Pyarali irfan@cs.wustl.edu, Tim Harrison harrison@cs.wustl.edu and Alexander Babu Arulanthu alex@cs.wustl.edu

Friendship.

LIBRARY

ace