SUN_Proactor.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    SUN_Proactor.h
00006  *
00007  *  SUN_Proactor.h,v 4.19 2005/10/28 16:14:55 ossama Exp
00008  *
00009  *  @author Alexander Libman <alibman@baltimore.com>
00010  */
00011 //=============================================================================
00012 
00013 #ifndef ACE_SUN_PROACTOR_H
00014 #define ACE_SUN_PROACTOR_H
00015 
00016 #include "ace/config-all.h"
00017 
00018 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00019 # pragma once
00020 #endif /* ACE_LACKS_PRAGMA_ONCE */
00021 
00022 #if defined (ACE_HAS_AIO_CALLS) && defined (sun)
00023 
00024 #include "ace/POSIX_Proactor.h"
00025 #include /**/ <sys/asynch.h>    // Sun native aio calls
00026 
00027 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00028 
00029 /**
00030  * @class ACE_SUN_Proactor
00031  *
00032  * @brief Implementation of the fast and reliable Proactor
00033  * for SunOS 5.6, 5.7, etc.
00034  *
00035  * This proactor, based on <ACE_POSIX_AIOCB_Proactor>,
00036  * works with Sun native interface for aio calls.
00037  * POSIX_API          Native SUN_API
00038  * aio_read           aioread
00039  * aio_write          aiowrite
00040  * aio_suspend        aiowait
00041  * aio_error          aio_result_t.errno
00042  * aio_return         aio_result_t.return
00043  * On Solaris, the Sun <aio*()> native implementation is more
00044  * reliable and efficient than POSIX <aio_*()> implementation.
00045  * There is a problem of lost RT signals with POSIX, if we start
00046  * more than SIGQUEUEMAX asynchronous operations at the same
00047  * time.
00048  * The Sun <aiocb> it is not the standard POSX <aiocb>, instead,
00049  * it has the following structure:
00050  * typedef struct aiocb
00051  * {
00052  * int          aio_fildes;     File descriptor
00053  * void         *aio_buf;       buffer location
00054  * size_t       aio_nbytes;     length of transfer
00055  * off_t        aio_offset;     file offset
00056  * int          aio_reqprio;    request priority offset
00057  * sigevent     aio_sigevent;   signal number and offset
00058  * int          aio_lio_opcode; listio operation
00059  * aio_result_t aio_resultp;    results
00060  * int          aio_state;      state flag for List I/O
00061  * int          aio__pad[1];    extension padding
00062  * };
00063  */
00064 class ACE_Export ACE_SUN_Proactor : public ACE_POSIX_AIOCB_Proactor
00065 {
00066 
00067 public:
00068   virtual Proactor_Type get_impl_type (void);
00069 
00070   /// Destructor.
00071   virtual ~ACE_SUN_Proactor (void);
00072 
00073   /// Constructor defines max number asynchronous operations that can
00074   /// be started at the same time.
00075   ACE_SUN_Proactor (size_t max_aio_operations = ACE_AIO_DEFAULT_SIZE);
00076 
00077 protected:
00078   /**
00079    * Dispatch a single set of events.  If @a wait_time elapses before
00080    * any events occur, return 0.  Return 1 on success i.e., when a
00081    * completion is dispatched, non-zero (-1) on errors and errno is
00082    * set accordingly.
00083    */
00084   virtual int handle_events (ACE_Time_Value &wait_time);
00085 
00086   /**
00087    * Block indefinitely until at least one event is dispatched.
00088    * Dispatch a single set of events. Return 1 on success i.e., when a
00089    * completion is dispatched, non-zero (-1) on errors and errno is
00090    * set accordingly.
00091    */
00092   virtual int handle_events (void);
00093 
00094   /// Internal completion detection and dispatching.
00095   int handle_events_i (ACE_Time_Value *delta);
00096 
00097   /// Initiate an aio operation.
00098   virtual int start_aio_i (ACE_POSIX_Asynch_Result *result);
00099 
00100   /// Check AIO for completion, error and result status
00101   /// Return: 1 - AIO completed , 0 - not completed yet
00102   virtual int get_result_status (ACE_POSIX_Asynch_Result* asynch_result,
00103                                  int &error_status,
00104                                  size_t &transfer_count);
00105 
00106   /// Extract the results of aio.
00107   ACE_POSIX_Asynch_Result *find_completed_aio (aio_result_t *result,
00108                                                int &error_status,
00109                                                size_t &transfer_count);
00110 
00111   /// From ACE_POSIX_AIOCB_Proactor.
00112   /// Attempt to cancel running request
00113   virtual int cancel_aiocb (ACE_POSIX_Asynch_Result *result);
00114 
00115   /// Specific Sun aiowait
00116   int wait_for_start (ACE_Time_Value * abstime);
00117 
00118   /// Condition variable .
00119   /// used to wait the first AIO start
00120   ACE_SYNCH_CONDITION condition_;
00121 };
00122 
00123 ACE_END_VERSIONED_NAMESPACE_DECL
00124 
00125 #endif /* ACE_HAS_AIO_CALLS && sun */
00126 #endif /* ACE_SUN_PROACTOR_H*/

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