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