Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Proactor_Impl.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Proactor_Impl.h
00006  *
00007  *  $Id: Proactor_Impl.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Alexander Babu Arulanthu <alex@cs.wustl.edu>
00010  *  @author Alexander Libman <alibman@ihug.com.au>
00011  */
00012 //=============================================================================
00013 
00014 
00015 #ifndef ACE_PROACTOR_IMPL_H
00016 #define ACE_PROACTOR_IMPL_H
00017 #include "ace/pre.h"
00018 
00019 #include "ace/config-all.h"
00020 
00021 #if ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || (defined (ACE_HAS_AIO_CALLS)))
00022 // This only works on Win32 platforms and on Unix platforms supporting
00023 // aio calls.
00024 #include "ace/OS.h"
00025 
00026 #include "ace/Asynch_IO.h"
00027 #include "ace/Reactor.h"
00028 
00029 /**
00030  * @class ACE_Proactor_Impl
00031  *
00032  * @brief A manager for asynchronous event demultiplexing. This class
00033  * is the base class for all the concrete implementation
00034  * classes.
00035  *
00036  * See the Proactor pattern description at
00037  * http://www.cs.wustl.edu/~schmidt/proactor.ps.gz for more
00038  * details.
00039  */
00040 class ACE_Export ACE_Proactor_Impl : public ACE_Event_Handler
00041 {
00042 
00043 public:
00044   /// Virtual destruction.
00045   virtual ~ACE_Proactor_Impl (void) {}
00046 
00047   /// Close the IO completion port.
00048   virtual int close (void) = 0;
00049 
00050   /// This method adds the <handle> to the I/O completion port. This
00051   /// function is a no-op function for Unix systems.
00052   virtual int register_handle (ACE_HANDLE handle,
00053                                const void *completion_key) = 0;
00054 
00055   /**
00056    * Dispatch a single set of events.  If <wait_time> elapses before
00057    * any events occur, return 0.  Return 1 on success i.e., when a
00058    * completion is dispatched, non-zero (-1) on errors and errno is
00059    * set accordingly.
00060    */
00061   virtual int handle_events (ACE_Time_Value &wait_time) = 0;
00062 
00063   /**
00064    * Block indefinitely until at least one event is dispatched.
00065    * Dispatch a single set of events.  If <wait_time> elapses before
00066    * any events occur, return 0.  Return 1 on success i.e., when a
00067    * completion is dispatched, non-zero (-1) on errors and errno is
00068    * set accordingly.
00069    */
00070   virtual int handle_events (void) = 0;
00071 
00072   /// Add wakeup dispatch threads (reinit).
00073   virtual int wake_up_dispatch_threads (void) = 0;
00074 
00075   /// Close all dispatch threads.
00076   virtual int close_dispatch_threads (int wait) = 0;
00077 
00078   /// Get number of thread used as a parameter to CreatIoCompletionPort.
00079   virtual size_t number_of_threads (void) const = 0;
00080 
00081   /// Set number of thread used as a parameter to CreatIoCompletionPort.
00082   virtual void number_of_threads (size_t threads) = 0;
00083 
00084   /// Get the event handle.
00085   virtual ACE_HANDLE get_handle (void) const = 0;
00086 
00087   //
00088   // = Factory methods for the operations
00089   //
00090   // Note that the user does not have to use or know about these
00091   // methods.
00092 
00093   /// Create the correct implementation class for doing Asynch_Read_Stream.
00094   virtual ACE_Asynch_Read_Stream_Impl *create_asynch_read_stream (void) = 0;
00095 
00096   /// Create the correct implementation class for doing Asynch_Write_Stream.
00097   virtual ACE_Asynch_Write_Stream_Impl *create_asynch_write_stream (void) = 0;
00098 
00099   /// Create the correct implementation class for doing Asynch_Read_File.
00100   virtual ACE_Asynch_Read_File_Impl *create_asynch_read_file (void) = 0;
00101 
00102     /// Create the correct implementation class for doing Asynch_Write_File.
00103   virtual ACE_Asynch_Write_File_Impl *create_asynch_write_file (void) = 0;
00104 
00105   /// Create the correct implementation class for doing Asynch_Accept.
00106   virtual ACE_Asynch_Accept_Impl *create_asynch_accept (void) = 0;
00107 
00108   /// Create the correct implementation class for doing Asynch_Connect.
00109   virtual ACE_Asynch_Connect_Impl *create_asynch_connect (void) = 0;
00110 
00111   /// Create the correct implementation class for doing Asynch_Transmit_File.
00112   virtual ACE_Asynch_Transmit_File_Impl *create_asynch_transmit_file (void) = 0;
00113 
00114   /// Create the correct implementation class for doing
00115   /// Asynch_Read_Dgram.
00116   virtual ACE_Asynch_Read_Dgram_Impl *create_asynch_read_dgram (void) = 0;
00117 
00118   /// Create the correct implementation class for doing
00119   /// Asynch_Write_Dgram.
00120   virtual ACE_Asynch_Write_Dgram_Impl *create_asynch_write_dgram (void) = 0;
00121 
00122   //
00123   // = Factory methods for the results
00124   //
00125   // Note that the user does not have to use or know about these
00126   // methods unless they want to "fake" results.
00127 
00128   /// Create the correct implementation class for ACE_Asynch_Read_Stream::Result class.
00129   virtual ACE_Asynch_Read_Stream_Result_Impl *create_asynch_read_stream_result (ACE_Handler &handler,
00130                                                                                 ACE_HANDLE handle,
00131                                                                                 ACE_Message_Block &message_block,
00132                                                                                 size_t bytes_to_read,
00133                                                                                 const void* act,
00134                                                                                 ACE_HANDLE event = ACE_INVALID_HANDLE,
00135                                                                                 int priority = 0,
00136                                                                                 int signal_number = ACE_SIGRTMIN) = 0;
00137 
00138   /// Create the correct implementation class for ACE_Asynch_Write_Stream::Result.
00139   virtual ACE_Asynch_Write_Stream_Result_Impl *create_asynch_write_stream_result (ACE_Handler &handler,
00140                                                                                   ACE_HANDLE handle,
00141                                                                                   ACE_Message_Block &message_block,
00142                                                                                   size_t bytes_to_write,
00143                                                                                   const void* act,
00144                                                                                   ACE_HANDLE event = ACE_INVALID_HANDLE,
00145                                                                                   int priority = 0,
00146                                                                                   int signal_number = ACE_SIGRTMIN) = 0;
00147 
00148   /// Create the correct implementation class for ACE_Asynch_Read_File::Result.
00149   virtual ACE_Asynch_Read_File_Result_Impl *create_asynch_read_file_result (ACE_Handler &handler,
00150                                                                             ACE_HANDLE handle,
00151                                                                             ACE_Message_Block &message_block,
00152                                                                             size_t bytes_to_read,
00153                                                                             const void* act,
00154                                                                             u_long offset,
00155                                                                             u_long offset_high,
00156                                                                             ACE_HANDLE event = ACE_INVALID_HANDLE,
00157                                                                             int priority = 0,
00158                                                                             int signal_number = ACE_SIGRTMIN) = 0;
00159 
00160     /// Create the correct implementation class for ACE_Asynch_Write_File::Result.
00161   virtual ACE_Asynch_Write_File_Result_Impl *create_asynch_write_file_result (ACE_Handler &handler,
00162                                                                               ACE_HANDLE handle,
00163                                                                               ACE_Message_Block &message_block,
00164                                                                               size_t bytes_to_write,
00165                                                                               const void* act,
00166                                                                               u_long offset,
00167                                                                               u_long offset_high,
00168                                                                               ACE_HANDLE event = ACE_INVALID_HANDLE,
00169                                                                               int priority = 0,
00170                                                                               int signal_number = ACE_SIGRTMIN) = 0;
00171 
00172   /// Create the correct implementation class for ACE_Asynch_Read_Dgram::Result.
00173   virtual ACE_Asynch_Read_Dgram_Result_Impl *create_asynch_read_dgram_result (ACE_Handler &handler,
00174                                                                               ACE_HANDLE handle,
00175                                                                               ACE_Message_Block *message_block,
00176                                                                               size_t bytes_to_read,
00177                                                                               int flags,
00178                                                                               int protocol_family,
00179                                                                               const void* act,
00180                                                                               ACE_HANDLE event = ACE_INVALID_HANDLE,
00181                                                                               int priority = 0,
00182                                                                               int signal_number = ACE_SIGRTMIN) = 0;
00183 
00184   /// Create the correct implementation class for ACE_Asynch_Write_Dgram::Result.
00185   virtual ACE_Asynch_Write_Dgram_Result_Impl *create_asynch_write_dgram_result (ACE_Handler &handler,
00186                                                                                 ACE_HANDLE handle,
00187                                                                                 ACE_Message_Block *message_block,
00188                                                                                 size_t bytes_to_write,
00189                                                                                 int flags,
00190                                                                                 const void* act,
00191                                                                                 ACE_HANDLE event = ACE_INVALID_HANDLE,
00192                                                                                 int priority = 0,
00193                                                                                 int signal_number = ACE_SIGRTMIN) = 0;
00194 
00195   /// Create the correct implementation class for ACE_Asynch_Accept::Result.
00196   virtual ACE_Asynch_Accept_Result_Impl *create_asynch_accept_result (ACE_Handler &handler,
00197                                                                       ACE_HANDLE listen_handle,
00198                                                                       ACE_HANDLE accept_handle,
00199                                                                       ACE_Message_Block &message_block,
00200                                                                       size_t bytes_to_read,
00201                                                                       const void* act,
00202                                                                       ACE_HANDLE event = ACE_INVALID_HANDLE,
00203                                                                       int priority = 0,
00204                                                                       int signal_number = ACE_SIGRTMIN) = 0;
00205 
00206   /// Create the correct implementation class for ACE_Asynch_Connect::Result.
00207   virtual ACE_Asynch_Connect_Result_Impl *create_asynch_connect_result (ACE_Handler &handler,
00208                                                                         ACE_HANDLE connect_handle,
00209                                                                         const void* act,
00210                                                                         ACE_HANDLE event = ACE_INVALID_HANDLE,
00211                                                                         int priority = 0,
00212                                                                         int signal_number = ACE_SIGRTMIN) = 0;
00213 
00214   /// Create the correct implementation class for ACE_Asynch_Transmit_File::Result.
00215   virtual ACE_Asynch_Transmit_File_Result_Impl *create_asynch_transmit_file_result (ACE_Handler &handler,
00216                                                                                     ACE_HANDLE socket,
00217                                                                                     ACE_HANDLE file,
00218                                                                                     ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
00219                                                                                     size_t bytes_to_write,
00220                                                                                     u_long offset,
00221                                                                                     u_long offset_high,
00222                                                                                     size_t bytes_per_send,
00223                                                                                     u_long flags,
00224                                                                                     const void *act,
00225                                                                                     ACE_HANDLE event = ACE_INVALID_HANDLE,
00226                                                                                     int priority = 0,
00227                                                                                     int signal_number = ACE_SIGRTMIN) = 0;
00228 
00229   /**
00230    * Create the correct implementation object for the Timer
00231    * result. POSIX_SIG_Proactor will create a Timer object with a
00232    * meaningful signal number, if you leave the signal number as 0.
00233    */
00234   virtual ACE_Asynch_Result_Impl *create_asynch_timer (ACE_Handler &handler,
00235                                                        const void *act,
00236                                                        const ACE_Time_Value &tv,
00237                                                        ACE_HANDLE event = ACE_INVALID_HANDLE,
00238                                                        int priority = 0,
00239                                                        int signal_number = 0) = 0;
00240 
00241   /**
00242    * Post <how_many> completions to the completion port so that all
00243    * threads can wake up. This is used in conjunction with the
00244    * <run_event_loop>.
00245    */
00246   virtual int post_wakeup_completions (int how_many) = 0;
00247 };
00248 
00249 #endif /* (ACE_WIN32 && ACE_HAS_WINCE) || ACE_HAS_AIO_CALLS */
00250 #include "ace/post.h"
00251 #endif /* ACE_PROACTOR_IMPL_H */

Generated on Mon Jun 16 11:20:54 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002