Also use Objects as part of an operation but as a result don't generate Any operation...
[ACE_TAO.git] / ACE / ace / SUN_Proactor.h
blob974fe9e1ef9773c98a659b0b729cefa3c054d1b7
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file SUN_Proactor.h
7 * @author Alexander Libman <alibman@baltimore.com>
8 */
9 //=============================================================================
11 #ifndef ACE_SUN_PROACTOR_H
12 #define ACE_SUN_PROACTOR_H
14 #include /**/ "ace/config-all.h"
16 #if !defined (ACE_LACKS_PRAGMA_ONCE)
17 # pragma once
18 #endif /* ACE_LACKS_PRAGMA_ONCE */
20 #if defined (ACE_HAS_AIO_CALLS) && defined (sun)
22 #include "ace/POSIX_Proactor.h"
23 #include /**/ <sys/asynch.h> // Sun native aio calls
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 /**
28 * @class ACE_SUN_Proactor
30 * @brief Implementation of the fast and reliable Proactor
31 * for SunOS 5.6, 5.7, etc.
33 * This proactor, based on ACE_POSIX_AIOCB_Proactor,
34 * works with Sun native interface for aio calls.
35 * POSIX_API Native SUN_API
36 * aio_read aioread
37 * aio_write aiowrite
38 * aio_suspend aiowait
39 * aio_error aio_result_t.errno
40 * aio_return aio_result_t.return
41 * On Solaris, the Sun <aio*()> native implementation is more
42 * reliable and efficient than POSIX <aio_*()> implementation.
43 * There is a problem of lost RT signals with POSIX, if we start
44 * more than SIGQUEUEMAX asynchronous operations at the same
45 * time.
46 * The Sun <aiocb> it is not the standard POSX <aiocb>, instead,
47 * it has the following structure:
48 * typedef struct aiocb
49 * {
50 * int aio_fildes; File descriptor
51 * void *aio_buf; buffer location
52 * size_t aio_nbytes; length of transfer
53 * off_t aio_offset; file offset
54 * int aio_reqprio; request priority offset
55 * sigevent aio_sigevent; signal number and offset
56 * int aio_lio_opcode; listio operation
57 * aio_result_t aio_resultp; results
58 * int aio_state; state flag for List I/O
59 * int aio__pad[1]; extension padding
60 * };
62 class ACE_Export ACE_SUN_Proactor : public ACE_POSIX_AIOCB_Proactor
64 public:
65 virtual Proactor_Type get_impl_type (void);
67 /// Destructor.
68 virtual ~ACE_SUN_Proactor (void);
70 /// Constructor defines max number asynchronous operations that can
71 /// be started at the same time.
72 ACE_SUN_Proactor (size_t max_aio_operations = ACE_AIO_DEFAULT_SIZE);
74 protected:
75 /**
76 * Dispatch a single set of events. If @a wait_time elapses before
77 * any events occur, return 0. Return 1 on success i.e., when a
78 * completion is dispatched, non-zero (-1) on errors and errno is
79 * set accordingly.
81 virtual int handle_events (ACE_Time_Value &wait_time);
83 /**
84 * Block indefinitely until at least one event is dispatched.
85 * Dispatch a single set of events. Return 1 on success i.e., when a
86 * completion is dispatched, non-zero (-1) on errors and errno is
87 * set accordingly.
89 virtual int handle_events (void);
91 /// Internal completion detection and dispatching.
92 int handle_events_i (ACE_Time_Value *delta);
94 /// Initiate an aio operation.
95 virtual int start_aio_i (ACE_POSIX_Asynch_Result *result);
97 /// Check AIO for completion, error and result status
98 /// Return: 1 - AIO completed , 0 - not completed yet
99 virtual int get_result_status (ACE_POSIX_Asynch_Result* asynch_result,
100 int &error_status,
101 size_t &transfer_count);
103 /// Extract the results of aio.
104 ACE_POSIX_Asynch_Result *find_completed_aio (aio_result_t *result,
105 int &error_status,
106 size_t &transfer_count);
108 /// From ACE_POSIX_AIOCB_Proactor.
109 /// Attempt to cancel running request
110 virtual int cancel_aiocb (ACE_POSIX_Asynch_Result *result);
112 /// Specific Sun aiowait
113 int wait_for_start (ACE_Time_Value * abstime);
115 /// Condition variable .
116 /// used to wait the first AIO start
117 ACE_SYNCH_CONDITION condition_;
120 ACE_END_VERSIONED_NAMESPACE_DECL
122 #endif /* ACE_HAS_AIO_CALLS && sun */
123 #endif /* ACE_SUN_PROACTOR_H*/