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

POSIX_Proactor.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    POSIX_Proactor.h
00006  *
00007  *  $Id: POSIX_Proactor.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Irfan Pyarali <irfan@cs.wustl.edu>
00010  *  @author Tim Harrison <harrison@cs.wustl.edu>
00011  *  @author Alexander Babu Arulanthu <alex@cs.wustl.edu>
00012  *  @author Roger Tragin <r.tragin@computer.org>
00013  *  @author Alexander Libman <alibman@baltimore.com>
00014  */
00015 //=============================================================================
00016 
00017 #ifndef ACE_POSIX_PROACTOR_H
00018 #define ACE_POSIX_PROACTOR_H
00019 
00020 #include "ace/config-all.h"
00021 
00022 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00023 #pragma once
00024 #endif /* ACE_LACKS_PRAGMA_ONCE */
00025 
00026 #if defined (ACE_HAS_AIO_CALLS)
00027 // POSIX implementation of Proactor depends on the <aio_> family of
00028 // system calls.
00029 
00030 #include "ace/Proactor_Impl.h"
00031 #include "ace/Free_List.h"
00032 #include "ace/Pipe.h"
00033 #include "ace/POSIX_Asynch_IO.h"
00034 #include "ace/Asynch_Pseudo_Task.h"
00035 
00036 #define ACE_AIO_MAX_SIZE     2048
00037 #define ACE_AIO_DEFAULT_SIZE 1024
00038 
00039 /**
00040  * @class ACE_POSIX_Proactor
00041  *
00042  * @brief POSIX implementation of the Proactor.
00043  *
00044  * There are two different strategies by which Proactor can get
00045  * to know the completion of <aio> operations. One is based on
00046  * Asynchronous I/O Control Blocks (AIOCB) where a list of
00047  * AIOCBs are stored and completion status of the corresponding
00048  * operations are queried on them. The other one is based on
00049  * POSIX Real Time signals. This class abstracts out the common
00050  * code needed for both the strategies. <ACE_AIOCB_Proactor> and
00051  * <ACE_SIG_Proactor> specialize this class for each strategy.
00052  */
00053 class ACE_Export ACE_POSIX_Proactor : public ACE_Proactor_Impl
00054 {
00055 public:
00056   enum Proactor_Type
00057   {
00058     /// Base class type
00059     PROACTOR_POSIX  = 0,
00060 
00061     /// Aio_suspend() based
00062     PROACTOR_AIOCB  = 1,
00063 
00064     /// Signals notifications
00065     PROACTOR_SIG    = 2,
00066 
00067     /// SUN specific aiowait()
00068     PROACTOR_SUN    = 3,
00069 
00070     /// Callback notifications
00071     PROACTOR_CB     = 4
00072   };
00073 
00074 
00075   enum SystemType  // open for future extention
00076   {
00077     OS_UNDEFINED= 0x0000,
00078     OS_WIN      = 0x0100,          // for future
00079     OS_WIN_NT   = OS_WIN | 0x0001,
00080     OS_WIN_2000 = OS_WIN | 0x0002,
00081     OS_SUN      = 0x0200,          // Sun Solaris family
00082     OS_SUN_55   = OS_SUN | 0x0001,
00083     OS_SUN_56   = OS_SUN | 0x0002,
00084     OS_SUN_57   = OS_SUN | 0x0004,
00085     OS_SUN_58   = OS_SUN | 0x0008,
00086     OS_HPUX     = 0x0400,          // HPUX family
00087     OS_HPUX_11  = OS_HPUX | 0x0001,
00088     OS_LINUX    = 0x0800,          // Linux family
00089     OS_FREEBSD  = 0x1000,          // FreeBSD family
00090     OS_IRIX     = 0x2000,          // SGI IRIX family
00091     OS_OPENBSD  = 0x4000           // OpenBSD familty
00092   };
00093 
00094   enum Opcode {
00095     READ = 1,
00096     WRITE = 2
00097   };
00098 
00099   virtual Proactor_Type  get_impl_type (void);
00100 
00101   /// Virtual destructor.
00102   virtual ~ACE_POSIX_Proactor (void);
00103 
00104   /// Close down the Proactor.
00105   virtual int close (void);
00106 
00107   /**
00108    * Dispatch a single set of events.  If <wait_time> elapses before
00109    * any events occur, return 0.  Return 1 on success i.e., when a
00110    * completion is dispatched, non-zero (-1) on errors and errno is
00111    * set accordingly.
00112    */
00113   virtual int handle_events (ACE_Time_Value &wait_time) = 0;
00114 
00115   /**
00116    * Block indefinitely until at least one event is dispatched.
00117    * Dispatch a single set of events.  If <wait_time> elapses before
00118    * any events occur, return 0.  Return 1 on success i.e., when a
00119    * completion is dispatched, non-zero (-1) on errors and errno is
00120    * set accordingly.
00121    */
00122   virtual int handle_events (void) = 0;
00123 
00124   /**
00125    * Post a result to the completion port of the Proactor.  If errors
00126    * occur, the result will be deleted by this method.  If successful,
00127    * the result will be deleted by the Proactor when the result is
00128    * removed from the completion port. Therefore, the result should
00129    * have been dynamically allocated and should be orphaned by the
00130    * user once this method is called.
00131    */
00132   virtual int post_completion (ACE_POSIX_Asynch_Result *result) = 0;
00133 
00134   virtual int start_aio (ACE_POSIX_Asynch_Result *result, Opcode op) = 0;
00135 
00136   virtual int cancel_aio (ACE_HANDLE h) = 0;
00137 
00138   /// Task to process pseudo-asynchronous operations
00139   ACE_Asynch_Pseudo_Task &get_asynch_pseudo_task ();
00140 
00141   /// This function is a no-op function for Unix systems. Returns 0.
00142   virtual int register_handle (ACE_HANDLE handle,
00143                                const void *completion_key);
00144 
00145   /// @@ This is a no-op on POSIX platforms. Returns 0.
00146   int wake_up_dispatch_threads (void);
00147 
00148   /// @@ This is a no-op on POSIX platforms. Returns 0.
00149   int close_dispatch_threads (int wait);
00150 
00151   /// @@ This is a no-op on POSIX platforms. Returns 0.
00152   size_t number_of_threads (void) const;
00153   void number_of_threads (size_t threads);
00154 
00155   /// This is a no-op in POSIX. Returns ACE_INVALID_HANDLE.
00156   virtual ACE_HANDLE get_handle (void) const;
00157 
00158   // Methods used to create Asynch IO factory and result objects. We
00159   // create the right objects here in these methods.
00160 
00161   virtual ACE_Asynch_Read_Stream_Impl *create_asynch_read_stream (void);
00162   virtual ACE_Asynch_Read_Stream_Result_Impl *
00163     create_asynch_read_stream_result (ACE_Handler &handler,
00164                                       ACE_HANDLE handle,
00165                                       ACE_Message_Block &message_block,
00166                                       size_t bytes_to_read,
00167                                       const void *act,
00168                                       ACE_HANDLE event = ACE_INVALID_HANDLE,
00169                                       int priority = 0,
00170                                       int signal_number = ACE_SIGRTMIN);
00171 
00172   virtual ACE_Asynch_Write_Stream_Impl *create_asynch_write_stream (void);
00173   virtual ACE_Asynch_Write_Stream_Result_Impl *
00174     create_asynch_write_stream_result (ACE_Handler &handler,
00175                                        ACE_HANDLE handle,
00176                                        ACE_Message_Block &message_block,
00177                                        size_t bytes_to_write,
00178                                        const void *act,
00179                                        ACE_HANDLE event = ACE_INVALID_HANDLE,
00180                                        int priority = 0,
00181                                        int signal_number = ACE_SIGRTMIN);
00182 
00183   virtual ACE_Asynch_Read_File_Impl *create_asynch_read_file (void);
00184   virtual ACE_Asynch_Read_File_Result_Impl *
00185     create_asynch_read_file_result (ACE_Handler &handler,
00186                                     ACE_HANDLE handle,
00187                                     ACE_Message_Block &message_block,
00188                                     size_t bytes_to_read,
00189                                     const void *act,
00190                                     u_long offset,
00191                                     u_long offset_high,
00192                                     ACE_HANDLE event = ACE_INVALID_HANDLE,
00193                                     int priority = 0,
00194                                     int signal_number = ACE_SIGRTMIN);
00195 
00196   virtual ACE_Asynch_Write_File_Impl *create_asynch_write_file (void);
00197   virtual ACE_Asynch_Write_File_Result_Impl *
00198     create_asynch_write_file_result (ACE_Handler &handler,
00199                                      ACE_HANDLE handle,
00200                                      ACE_Message_Block &message_block,
00201                                      size_t bytes_to_write,
00202                                      const void *act,
00203                                      u_long offset,
00204                                      u_long offset_high,
00205                                      ACE_HANDLE event = ACE_INVALID_HANDLE,
00206                                      int priority = 0,
00207                                      int signal_number = ACE_SIGRTMIN);
00208 
00209   virtual ACE_Asynch_Read_Dgram_Impl *create_asynch_read_dgram (void);
00210   virtual ACE_Asynch_Read_Dgram_Result_Impl *
00211     create_asynch_read_dgram_result (ACE_Handler &handler,
00212                                      ACE_HANDLE handle,
00213                                      ACE_Message_Block *message_block,
00214                                      size_t bytes_to_read,
00215                                      int flags,
00216                                      int protocol_family,
00217                                      const void* act,
00218                                      ACE_HANDLE event = ACE_INVALID_HANDLE,
00219                                      int priority = 0,
00220                                      int signal_number = ACE_SIGRTMIN);
00221 
00222   virtual ACE_Asynch_Write_Dgram_Impl *create_asynch_write_dgram (void);
00223   virtual ACE_Asynch_Write_Dgram_Result_Impl *
00224     create_asynch_write_dgram_result (ACE_Handler &handler,
00225                                       ACE_HANDLE handle,
00226                                       ACE_Message_Block *message_block,
00227                                       size_t bytes_to_write,
00228                                       int flags,
00229                                       const void* act,
00230                                       ACE_HANDLE event = ACE_INVALID_HANDLE,
00231                                       int priority = 0,
00232                                       int signal_number = ACE_SIGRTMIN);
00233 
00234   virtual ACE_Asynch_Accept_Impl *create_asynch_accept (void);
00235   virtual ACE_Asynch_Accept_Result_Impl *
00236     create_asynch_accept_result (ACE_Handler &handler,
00237                                  ACE_HANDLE listen_handle,
00238                                  ACE_HANDLE accept_handle,
00239                                  ACE_Message_Block &message_block,
00240                                  size_t bytes_to_read,
00241                                  const void *act,
00242                                  ACE_HANDLE event = ACE_INVALID_HANDLE,
00243                                  int priority = 0,
00244                                  int signal_number = ACE_SIGRTMIN);
00245 
00246   virtual ACE_Asynch_Connect_Impl *create_asynch_connect (void);
00247   virtual ACE_Asynch_Connect_Result_Impl *
00248     create_asynch_connect_result (ACE_Handler & handler,
00249                                   ACE_HANDLE connect_handle,
00250                                   const void *act,
00251                                   ACE_HANDLE event = ACE_INVALID_HANDLE,
00252                                   int priority = 0,
00253                                   int signal_number = ACE_SIGRTMIN);
00254 
00255   virtual ACE_Asynch_Transmit_File_Impl *create_asynch_transmit_file (void);
00256   virtual ACE_Asynch_Transmit_File_Result_Impl *
00257     create_asynch_transmit_file_result (ACE_Handler &handler,
00258                                         ACE_HANDLE socket,
00259                                         ACE_HANDLE file,
00260                                         ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
00261                                         size_t bytes_to_write,
00262                                         u_long offset,
00263                                         u_long offset_high,
00264                                         size_t bytes_per_send,
00265                                         u_long flags,
00266                                         const void *act,
00267                                         ACE_HANDLE event = ACE_INVALID_HANDLE,
00268                                         int priority = 0,
00269                                         int signal_number = ACE_SIGRTMIN);
00270 
00271   /// Create a timer result object which can be used with the Timer
00272   /// mechanism of the Proactor.
00273   virtual ACE_Asynch_Result_Impl *
00274     create_asynch_timer (ACE_Handler &handler,
00275                          const void *act,
00276                          const ACE_Time_Value &tv,
00277                          ACE_HANDLE event = ACE_INVALID_HANDLE,
00278                          int priority = 0,
00279                          int signal_number = ACE_SIGRTMIN);
00280 
00281 protected:
00282   /// Constructor.
00283   ACE_POSIX_Proactor (void);
00284 
00285   /**
00286    * Protect against structured exceptions caused by user code when
00287    * dispatching handles. The <completion_key> is not very useful
00288    * compared to <AST> that can be associated each asynchronous
00289    * operation. <completion_key> is implemented right now for the
00290    * POSIX Proators.
00291    */
00292   void application_specific_code (ACE_POSIX_Asynch_Result *asynch_result,
00293                                   size_t bytes_transferred,
00294                                   const void *completion_key,
00295                                   u_long error);
00296 
00297   /**
00298    * Post <how_many> completions to the completion port so that all
00299    * threads can wake up. This is used in conjunction with the
00300    * <run_event_loop>.
00301    */
00302   virtual int post_wakeup_completions (int how_many);
00303 
00304 protected:
00305   /// Handler to handle the wakeups. This works in conjunction with the
00306   /// <ACE_Proactor::run_event_loop>.
00307   ACE_Handler wakeup_handler_;
00308   int os_id_;
00309 
00310 private:
00311   /// Task to process pseudo-asynchronous accept/connect
00312   ACE_Asynch_Pseudo_Task  pseudo_task_;
00313 
00314 };
00315 
00316 // Forward declarations.
00317 class ACE_AIOCB_Notify_Pipe_Manager;
00318 
00319 /**
00320  * @class ACE_POSIX_AIOCB_Proactor
00321  *
00322  * @brief This Proactor makes use of Asynchronous I/O Control Blocks
00323  * (AIOCB) to notify/get the completion status of the <aio_>
00324  * operations issued.
00325  */
00326 class ACE_Export ACE_POSIX_AIOCB_Proactor : public ACE_POSIX_Proactor
00327 {
00328 
00329   /// Handler needs to call application specific code.
00330   friend class ACE_AIOCB_Notify_Pipe_Manager;
00331 
00332   /// This class does the registering of Asynch Operations with the
00333   /// Proactor which is necessary in the AIOCB strategy.
00334   friend class ACE_POSIX_Asynch_Operation;
00335   friend class ACE_POSIX_Asynch_Accept;
00336   friend class ACE_POSIX_Asynch_Connect;
00337 
00338 
00339 public:
00340   /// Constructor defines max number asynchronous operations
00341   /// which can be started at the same time
00342   ACE_POSIX_AIOCB_Proactor (size_t nmaxop = ACE_AIO_DEFAULT_SIZE);
00343 
00344   virtual Proactor_Type  get_impl_type (void);
00345 
00346   /// Destructor.
00347   virtual ~ACE_POSIX_AIOCB_Proactor (void);
00348 
00349   /// Close down the Proactor.
00350   virtual int close (void);
00351 
00352   /**
00353    * Dispatch a single set of events.  If <wait_time> elapses before
00354    * any events occur, return 0.  Return 1 on success i.e., when a
00355    * completion is dispatched, non-zero (-1) on errors and errno is
00356    * set accordingly.
00357    */
00358   virtual int handle_events (ACE_Time_Value &wait_time);
00359 
00360   /**
00361    * Block indefinitely until at least one event is dispatched.
00362    * Dispatch a single set of events.  If <wait_time> elapses before
00363    * any events occur, return 0.  Return 1 on success i.e., when a
00364    * completion is dispatched, non-zero (-1) on errors and errno is
00365    * set accordingly.
00366    */
00367   virtual int handle_events (void);
00368 
00369   /// Post a result to the completion port of the Proactor.
00370   virtual int post_completion (ACE_POSIX_Asynch_Result *result);
00371 
00372   virtual int start_aio (ACE_POSIX_Asynch_Result *result,
00373                          ACE_POSIX_Proactor::Opcode op);
00374 
00375   /**
00376    * This method should be called from
00377    * ACE_POSIX_Asynch_Operation::cancel()
00378    * instead of usual ::aio_cancel.
00379    * For all deferred AIO requests with handle "h"
00380    * it removes its from the lists and notifies user.
00381    * For all running AIO requests with handle "h"
00382    * it calls ::aio_cancel. According to the POSIX standards
00383    * we will receive ECANCELED  for all ::aio_canceled AIO requests
00384    * later on return from ::aio_suspend
00385    */
00386   virtual int cancel_aio (ACE_HANDLE h);
00387 
00388 protected:
00389 
00390   /// Special constructor for ACE_SUN_Proactor
00391   /// and ACE_POSIX_SIG_Proactor
00392   ACE_POSIX_AIOCB_Proactor (size_t nmaxop,
00393                             ACE_POSIX_Proactor::Proactor_Type ptype);
00394 
00395   /// Check AIO for completion, error and result status
00396   /// Return: 1 - AIO completed , 0 - not completed yet
00397   virtual int get_result_status (ACE_POSIX_Asynch_Result *asynch_result,
00398                                  int &error_status,
00399                                  size_t &transfer_count);
00400 
00401   /// Create aiocb list
00402   int create_result_aiocb_list (void);
00403 
00404   /// Call this method from derived class when virtual table is
00405   /// built.
00406   int delete_result_aiocb_list (void);
00407 
00408   /// Call these methods from derived class when virtual table is
00409   /// built.
00410   void create_notify_manager (void);
00411   void delete_notify_manager (void);
00412 
00413   /// Define the maximum number of asynchronous I/O requests
00414   /// for the current OS
00415   void check_max_aio_num (void) ;
00416 
00417   /// To identify requests from Notify_Pipe_Manager
00418   void set_notify_handle (ACE_HANDLE h);
00419 
00420   /**
00421    * Dispatch a single set of events.  If <milli_seconds> elapses
00422    * before any events occur, return 0. Return 1 if a completion
00423    * dispatched. Return -1 on errors.
00424    */
00425   int handle_events_i (u_long milli_seconds);
00426 
00427   /// Start deferred AIO if necessary
00428   int start_deferred_aio (void);
00429 
00430   /// Cancel running or deferred AIO
00431   virtual int cancel_aiocb (ACE_POSIX_Asynch_Result * result);
00432 
00433   /// Extract the results of aio.
00434   ACE_POSIX_Asynch_Result *find_completed_aio (int &error_status,
00435                                                size_t &transfer_count,
00436                                                size_t &index,
00437                                                size_t &count);
00438 
00439   /// Find free slot to store result and aiocb pointer
00440   virtual ssize_t allocate_aio_slot (ACE_POSIX_Asynch_Result *result);
00441 
00442   /// Initiate an aio operation.
00443   virtual int start_aio_i (ACE_POSIX_Asynch_Result *result);
00444 
00445   /// Notify queue of "post_completed" ACE_POSIX_Asynch_Results
00446   /// called from post_completion method
00447   virtual int notify_completion (int sig_num);
00448 
00449   /// Put "post_completed" result into the internal queue
00450   int  putq_result (ACE_POSIX_Asynch_Result *result);
00451 
00452   /// Get "post_completed" result from the internal queue
00453   ACE_POSIX_Asynch_Result * getq_result (void);
00454 
00455   /// Clear the internal results queue
00456   int clear_result_queue (void);
00457 
00458   /// Process the internal results queue
00459   int process_result_queue (void);
00460 
00461 
00462   /// This class takes care of doing <accept> when we use
00463   /// AIO_CONTROL_BLOCKS strategy.
00464   ACE_AIOCB_Notify_Pipe_Manager *aiocb_notify_pipe_manager_;
00465 
00466   /// Use a dynamically allocated array to keep track of all the aio's
00467   /// issued currently.
00468   aiocb **aiocb_list_;
00469   ACE_POSIX_Asynch_Result **result_list_;
00470 
00471   /// To maintain the maximum size of the array (list).
00472   size_t aiocb_list_max_size_;
00473 
00474   /// To maintain the current size of the array (list).
00475   size_t aiocb_list_cur_size_;
00476 
00477   /// Mutex to protect work with lists.
00478   ACE_SYNCH_MUTEX mutex_;
00479 
00480   /// The purpose of this member is only to identify asynchronous request
00481   /// from NotifyManager. We will reserve for it always slot 0
00482   /// in the list of aiocb's to be sure that don't lose notifications.
00483   ACE_HANDLE notify_pipe_read_handle_ ;
00484 
00485   /// Number of ACE_POSIX_Asynch_Result's waiting for start
00486   /// i.e. deferred AIOs
00487   size_t num_deferred_aiocb_ ;
00488 
00489   /// Number active,i.e. running requests
00490   size_t num_started_aio_ ;
00491 
00492   /// Queue which keeps "post_completed" ACE_POSIX_Asynch_Result's
00493   ACE_Unbounded_Queue<ACE_POSIX_Asynch_Result *> result_queue_;
00494 };
00495 
00496 #if defined(ACE_HAS_POSIX_REALTIME_SIGNALS)
00497 /**
00498  * @class ACE_POSIX_SIG_Proactor
00499  *
00500  * @brief This Proactor implementation does completion event detection using
00501  * POSIX Real Time signals. @c sigtimedwait() or @c sigwaitinfo() is
00502  * used to wait for completions.
00503  * The real-time signals that are going to be used with this
00504  * Proactor should be given apriori in the constructor, so that
00505  * those signals can be masked from asynchronous delivery.
00506  */
00507 class ACE_Export ACE_POSIX_SIG_Proactor : public ACE_POSIX_AIOCB_Proactor
00508 {
00509 
00510   /**
00511    * This class does the registering of Asynch Operations with the
00512    * Proactor which is necessary in the SIG strategy, because we need
00513    * to store the signal number.
00514    */
00515   friend class ACE_POSIX_SIG_Asynch_Operation;
00516 
00517 public:
00518   /**
00519    * This constructor masks only the <ACE_SIGRTMIN>
00520    * real-time signal. Only this signal should be used to issue
00521    * asynchronous operations using this Proctor.
00522    */
00523   ACE_POSIX_SIG_Proactor (size_t nmaxop = ACE_AIO_DEFAULT_SIZE);
00524 
00525   virtual Proactor_Type  get_impl_type (void);
00526 
00527   /**
00528    * This constructor should be used to tell the Proactor to mask and
00529    * wait for the real-time signals specified in this set. Only these
00530    * signals should be used by the asynchronous operations when they
00531    * use this Proactor.
00532    */
00533   ACE_POSIX_SIG_Proactor (const sigset_t mask_set,
00534                           size_t nmaxop = ACE_AIO_DEFAULT_SIZE);
00535 
00536   /// Destructor.
00537   virtual ~ACE_POSIX_SIG_Proactor (void);
00538 
00539   /**
00540    * Dispatch a single set of events.  If <wait_time> elapses before
00541    * any events occur, return 0.  Return 1 on success i.e., when a
00542    * completion is dispatched, non-zero (-1) on errors and errno is
00543    * set accordingly.
00544    */
00545   virtual int handle_events (ACE_Time_Value &wait_time);
00546 
00547   /**
00548    * Block indefinitely until at least one event is dispatched.
00549    * Dispatch a single set of events.  If <wait_time> elapses before
00550    * any events occur, return 0.  Return 1 on success i.e., when a
00551    * completion is dispatched, non-zero (-1) on errors and errno is
00552    * set accordingly.
00553    */
00554   virtual int handle_events (void);
00555 
00556   /// Post a result to the completion port of the Proactor.
00557   /// now it is implemented in base ACE_POSIX_AIOCB_Proactor class
00558   ///virtual int post_completion (ACE_POSIX_Asynch_Result *result);
00559 
00560   /**
00561    * If <signal_number> is -1, check with the Proactor and use one of
00562    * the signals that is present in the mask set (i.e., the signals for
00563    * which the Proactor will be waiting) of the Proactor. If there are
00564    * more than one signal, the higher numbered signal will be chosen.
00565    */
00566   virtual ACE_Asynch_Result_Impl *create_asynch_timer (ACE_Handler &handler,
00567                                                        const void *act,
00568                                                        const ACE_Time_Value &tv,
00569                                                        ACE_HANDLE event = ACE_INVALID_HANDLE,
00570                                                        int priority = 0,
00571                                                        int signal_number = ACE_SIGRTMIN);
00572 
00573 protected:
00574   /// To setup the handler for a real-time signbal.
00575   int setup_signal_handler (int signal_number) const;
00576 
00577   /// Insures that RT_completion_signals_ are blocked in the calling thread.
00578   int block_signals (void) const;
00579 
00580   /**
00581    * Dispatch a single set of events.  @a timeout is a pointer to a
00582    * relative time representing the maximum amount of time to wait for
00583    * an event to occur. If 0, wait indefinitely.
00584    *
00585    * @retval 0  A timeout occurred before any event was detected.
00586    * @retval 1  A completion was dispatched.
00587    * @retval -1 An error occurred; errno contains an error code.
00588    */
00589   virtual int handle_events_i (const ACE_Time_Value *timeout);
00590 
00591   /// Find free slot to store result and aiocb pointer
00592   virtual ssize_t allocate_aio_slot (ACE_POSIX_Asynch_Result *result);
00593 
00594 
00595   /// Notify queue of "post_completed" ACE_POSIX_Asynch_Results
00596   /// called from post_completion method
00597   virtual int notify_completion (int sig_num);
00598 
00599   /**
00600    * These signals are used for completion notification by the
00601    * Proactor. The signals specified while issuing asynchronous
00602    * operations are stored here in this set. These signals are masked
00603    * for a thread when it calls handle_events().
00604    */
00605   sigset_t RT_completion_signals_;
00606 };
00607 
00608 
00609 #endif /* ACE_HAS_POSIX_REALTIME_SIGNALS */
00610 
00611 /**
00612  * @class ACE_POSIX_Asynch_Timer
00613  *
00614  * @brief This class is posted to the completion port when a timer
00615  * expires. When the <complete method> of this object is
00616  * called, the <handler>'s <handle_timeout> method will be
00617  * called.
00618  */
00619 class ACE_Export ACE_POSIX_Asynch_Timer : public ACE_POSIX_Asynch_Result
00620 {
00621 
00622   /// The factory method for this class is with the POSIX_Proactor
00623   /// class.
00624   friend class ACE_POSIX_Proactor;
00625 #if defined(ACE_HAS_POSIX_REALTIME_SIGNALS) 
00626   friend class ACE_POSIX_SIG_Proactor;
00627 #endif
00628 
00629 protected:
00630   /// Constructor.
00631   ACE_POSIX_Asynch_Timer (ACE_Handler &handler,
00632                           const void *act,
00633                           const ACE_Time_Value &tv,
00634                           ACE_HANDLE event = ACE_INVALID_HANDLE,
00635                           int priority = 0,
00636                           int signal_number = ACE_SIGRTMIN);
00637 
00638   /// Destructor.
00639   virtual ~ACE_POSIX_Asynch_Timer (void) {}
00640 
00641   /// This method calls the <handler>'s handle_timeout method.
00642   virtual void complete (size_t bytes_transferred,
00643                          int success,
00644                          const void *completion_key,
00645                          u_long error = 0);
00646 
00647   /// Time value requested by caller
00648   ACE_Time_Value time_;
00649 };
00650 
00651 #if defined (__ACE_INLINE__)
00652 #include "ace/POSIX_Proactor.i"
00653 #endif /* __ACE_INLINE__ */
00654 
00655 #endif /* ACE_HAS_AIO_CALLS  && ACE_HAS_POSIX_REALTIME_SIGNALS */
00656 #endif /* ACE_POSIX_PROACTOR_H */

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