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