Proactor_Impl.h

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

Generated on Thu Nov 9 09:42:00 2006 for ACE by doxygen 1.3.6