summaryrefslogtreecommitdiff
path: root/ace/POSIX_Proactor.h
diff options
context:
space:
mode:
authorSteve Huston <shuston@riverace.com>2002-11-09 23:54:06 +0000
committerSteve Huston <shuston@riverace.com>2002-11-09 23:54:06 +0000
commitd146dbb82170c4ae2c27b2d8f135cf346b39cdeb (patch)
treebb2fabe45bafd455feaaf5ca63166383a47e43ef /ace/POSIX_Proactor.h
parentfb8b22af774cd5cca94e0d6f1081cc5ba828c801 (diff)
downloadATCD-d146dbb82170c4ae2c27b2d8f135cf346b39cdeb.tar.gz
ChangeLogTag:Sat Nov 9 18:49:11 2002 Steve Huston <shuston@riverace.com>
Diffstat (limited to 'ace/POSIX_Proactor.h')
-rw-r--r--ace/POSIX_Proactor.h321
1 files changed, 173 insertions, 148 deletions
diff --git a/ace/POSIX_Proactor.h b/ace/POSIX_Proactor.h
index ba54a6f9431..6eddf84e49b 100644
--- a/ace/POSIX_Proactor.h
+++ b/ace/POSIX_Proactor.h
@@ -91,6 +91,11 @@ public:
OS_OPENBSD = 0x4000 // OpenBSD familty
};
+ enum Opcode {
+ READ = 1,
+ WRITE = 2
+ };
+
virtual Proactor_Type get_impl_type (void);
/// Virtual destructor.
@@ -99,9 +104,22 @@ public:
/// Close down the Proactor.
virtual int close (void);
- /// This function is a no-op function for Unix systems. Returns 0.
- virtual int register_handle (ACE_HANDLE handle,
- const void *completion_key);
+ /**
+ * Dispatch a single set of events. If <wait_time> elapses before
+ * any events occur, return 0. Return 1 on success i.e., when a
+ * completion is dispatched, non-zero (-1) on errors and errno is
+ * set accordingly.
+ */
+ virtual int handle_events (ACE_Time_Value &wait_time) = 0;
+
+ /**
+ * Block indefinitely until at least one event is dispatched.
+ * Dispatch a single set of events. If <wait_time> elapses before
+ * any events occur, return 0. Return 1 on success i.e., when a
+ * completion is dispatched, non-zero (-1) on errors and errno is
+ * set accordingly.
+ */
+ virtual int handle_events (void) = 0;
/**
* Post a result to the completion port of the Proactor. If errors
@@ -113,6 +131,17 @@ public:
*/
virtual int post_completion (ACE_POSIX_Asynch_Result *result) = 0;
+ virtual int start_aio (ACE_POSIX_Asynch_Result *result, Opcode op) = 0;
+
+ virtual int cancel_aio (ACE_HANDLE h) = 0;
+
+ /// Task to process pseudo-asynchronous operations
+ ACE_Asynch_Pseudo_Task &get_asynch_pseudo_task ();
+
+ /// This function is a no-op function for Unix systems. Returns 0.
+ virtual int register_handle (ACE_HANDLE handle,
+ const void *completion_key);
+
/// @@ This is a no-op on POSIX platforms. Returns 0.
int wake_up_dispatch_threads (void);
@@ -126,109 +155,129 @@ public:
/// This is a no-op in POSIX. Returns ACE_INVALID_HANDLE.
virtual ACE_HANDLE get_handle (void) const;
- // Methods used to create Asynch_IO_Result objects. We create the right
- // objects here in these methods.
-
- virtual ACE_Asynch_Read_Stream_Result_Impl *create_asynch_read_stream_result (ACE_Handler &handler,
- ACE_HANDLE handle,
- ACE_Message_Block &message_block,
- size_t 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,
- size_t 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,
- size_t 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,
- size_t 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_Read_Dgram_Result_Impl *create_asynch_read_dgram_result (ACE_Handler &handler,
- ACE_HANDLE handle,
- ACE_Message_Block *message_block,
- size_t bytes_to_read,
- int flags,
- int protocol_family,
- const void* act,
- ACE_HANDLE event = ACE_INVALID_HANDLE,
- int priority = 0,
- int signal_number = ACE_SIGRTMIN);
-
- virtual ACE_Asynch_Write_Dgram_Result_Impl *create_asynch_write_dgram_result (ACE_Handler &handler,
- ACE_HANDLE handle,
- ACE_Message_Block *message_block,
- size_t bytes_to_write,
- int flags,
- const void* act,
- 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,
- size_t bytes_to_read,
- const void *act,
- ACE_HANDLE event = ACE_INVALID_HANDLE,
- int priority = 0,
- int signal_number = ACE_SIGRTMIN);
-
- virtual ACE_Asynch_Connect_Result_Impl *create_asynch_connect_result (ACE_Handler & handler,
- ACE_HANDLE connect_handle,
- 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,
- size_t bytes_to_write,
- u_long offset,
- u_long offset_high,
- size_t bytes_per_send,
- u_long flags,
- const void *act,
- ACE_HANDLE event = ACE_INVALID_HANDLE,
- int priority = 0,
- int signal_number = ACE_SIGRTMIN);
+ // Methods used to create Asynch IO factory and result objects. We
+ // create the right objects here in these methods.
+
+ virtual ACE_Asynch_Read_Stream_Impl *create_asynch_read_stream (void);
+ virtual ACE_Asynch_Read_Stream_Result_Impl *
+ create_asynch_read_stream_result (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t 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_Impl *create_asynch_write_stream (void);
+ virtual ACE_Asynch_Write_Stream_Result_Impl *
+ create_asynch_write_stream_result (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t 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_Impl *create_asynch_read_file (void);
+ virtual ACE_Asynch_Read_File_Result_Impl *
+ create_asynch_read_file_result (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t 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_Impl *create_asynch_write_file (void);
+ virtual ACE_Asynch_Write_File_Result_Impl *
+ create_asynch_write_file_result (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ ACE_Message_Block &message_block,
+ size_t 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_Read_Dgram_Impl *create_asynch_read_dgram (void);
+ virtual ACE_Asynch_Read_Dgram_Result_Impl *
+ create_asynch_read_dgram_result (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_read,
+ int flags,
+ int protocol_family,
+ const void* act,
+ ACE_HANDLE event = ACE_INVALID_HANDLE,
+ int priority = 0,
+ int signal_number = ACE_SIGRTMIN);
+
+ virtual ACE_Asynch_Write_Dgram_Impl *create_asynch_write_dgram (void);
+ virtual ACE_Asynch_Write_Dgram_Result_Impl *
+ create_asynch_write_dgram_result (ACE_Handler &handler,
+ ACE_HANDLE handle,
+ ACE_Message_Block *message_block,
+ size_t bytes_to_write,
+ int flags,
+ const void* act,
+ ACE_HANDLE event = ACE_INVALID_HANDLE,
+ int priority = 0,
+ int signal_number = ACE_SIGRTMIN);
+
+ virtual ACE_Asynch_Accept_Impl *create_asynch_accept (void);
+ 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,
+ size_t bytes_to_read,
+ const void *act,
+ ACE_HANDLE event = ACE_INVALID_HANDLE,
+ int priority = 0,
+ int signal_number = ACE_SIGRTMIN);
+
+ virtual ACE_Asynch_Connect_Impl *create_asynch_connect (void);
+ virtual ACE_Asynch_Connect_Result_Impl *
+ create_asynch_connect_result (ACE_Handler & handler,
+ ACE_HANDLE connect_handle,
+ const void *act,
+ ACE_HANDLE event = ACE_INVALID_HANDLE,
+ int priority = 0,
+ int signal_number = ACE_SIGRTMIN);
+
+ virtual ACE_Asynch_Transmit_File_Impl *create_asynch_transmit_file (void);
+ 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,
+ size_t bytes_to_write,
+ u_long offset,
+ u_long offset_high,
+ size_t bytes_per_send,
+ u_long flags,
+ const void *act,
+ ACE_HANDLE event = ACE_INVALID_HANDLE,
+ int priority = 0,
+ int signal_number = ACE_SIGRTMIN);
/// Create a timer result object which can be used with the Timer
/// mechanism of the Proactor.
- 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);
+ 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);
+
protected:
/// Constructor.
ACE_POSIX_Proactor (void);
@@ -256,7 +305,12 @@ protected:
/// Handler to handle the wakeups. This works in conjunction with the
/// <ACE_Proactor::run_event_loop>.
ACE_Handler wakeup_handler_;
- int os_id_ ;
+ int os_id_;
+
+private:
+ /// Task to process pseudo-asynchronous accept/connect
+ ACE_Asynch_Pseudo_Task pseudo_task_;
+
};
// Forward declarations.
@@ -315,38 +369,20 @@ public:
/// Post a result to the completion port of the Proactor.
virtual int post_completion (ACE_POSIX_Asynch_Result *result);
- // = Methods used to create Asynch_IO objects. We create the right
- // objects here in 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_Dgram_Impl *create_asynch_read_dgram (void);
-
- virtual ACE_Asynch_Write_Dgram_Impl *create_asynch_write_dgram (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_Connect_Impl *create_asynch_connect (void);
-
- virtual ACE_Asynch_Transmit_File_Impl *create_asynch_transmit_file (void);
+ virtual int start_aio (ACE_POSIX_Asynch_Result *result,
+ ACE_POSIX_Proactor::Opcode op);
/**
- * This method should be called from
- * ACE_POSIX_Asynch_Operation::cancel()
- * instead of usual ::aio_cancel.
- * For all deferred AIO requests with handle "h"
- * it removes its from the lists and notifies user.
- * For all running AIO requests with handle "h"
- * it calls ::aio_cancel. According to the POSIX standards
- * we will receive ECANCELED for all ::aio_canceled AIO requests
- * later on return from ::aio_suspend
- */
+ * This method should be called from
+ * ACE_POSIX_Asynch_Operation::cancel()
+ * instead of usual ::aio_cancel.
+ * For all deferred AIO requests with handle "h"
+ * it removes its from the lists and notifies user.
+ * For all running AIO requests with handle "h"
+ * it calls ::aio_cancel. According to the POSIX standards
+ * we will receive ECANCELED for all ::aio_canceled AIO requests
+ * later on return from ::aio_suspend
+ */
virtual int cancel_aio (ACE_HANDLE h);
protected:
@@ -362,9 +398,6 @@ protected:
int &error_status,
size_t &transfer_count);
- /// Task to process pseudo-asynchronous operations
- ACE_Asynch_Pseudo_Task & get_asynch_pseudo_task();
-
/// Create aiocb list
int create_result_aiocb_list (void);
@@ -372,7 +405,6 @@ protected:
/// built.
int delete_result_aiocb_list (void);
-
/// Call these methods from derived class when virtual table is
/// built.
void create_notify_manager (void);
@@ -392,12 +424,6 @@ protected:
*/
virtual int handle_events (u_long milli_seconds);
- virtual int register_and_start_aio (ACE_POSIX_Asynch_Result *result,
- int op);
-
- /// Op code now is saved in ACE_POSIX_Asynch_Result
- virtual int start_aio (ACE_POSIX_Asynch_Result *result);
-
/// Start deferred AIO if necessary
int start_deferred_aio (void);
@@ -413,6 +439,8 @@ protected:
/// Find free slot to store result and aiocb pointer
virtual ssize_t allocate_aio_slot (ACE_POSIX_Asynch_Result *result);
+ /// Initiate an aio operation.
+ int start_aio_i (ACE_POSIX_Asynch_Result *result);
/// Notify queue of "post_completed" ACE_POSIX_Asynch_Results
/// called from post_completion method
@@ -452,7 +480,7 @@ protected:
/// The purpose of this member is only to identify asynchronous request
/// from NotifyManager. We will reserve for it always slot 0
/// in the list of aiocb's to be sure that don't lose notifications.
- ACE_HANDLE notify_pipe_read_handle_ ;
+ ACE_HANDLE notify_pipe_read_handle_ ;
/// Number of ACE_POSIX_Asynch_Result's waiting for start
/// i.e. deferred AIOs
@@ -463,9 +491,6 @@ protected:
/// Queue which keeps "post_completed" ACE_POSIX_Asynch_Result's
ACE_Unbounded_Queue<ACE_POSIX_Asynch_Result *> result_queue_;
-
- /// Task to process pseudo-asynchronous accept
- ACE_Asynch_Pseudo_Task pseudo_task_;
};
/**