Merge pull request #2309 from mitza-oci/warnings
[ACE_TAO.git] / ACE / ace / Proactor_Impl.h
blobddd98917d7c63f31f865bfbbdc8b3d45d458f47b
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Proactor_Impl.h
7 * @author Alexander Babu Arulanthu <alex@cs.wustl.edu>
8 * @author Alexander Libman <alibman@ihug.com.au>
9 */
10 //=============================================================================
12 #ifndef ACE_PROACTOR_IMPL_H
13 #define ACE_PROACTOR_IMPL_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/config-all.h"
18 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
19 // This only works on standard Win32 platforms and on Unix platforms supporting
20 // aio calls.
22 #include "ace/Asynch_IO.h"
23 #include "ace/Reactor.h"
24 #include "ace/Countdown_Time.h"
26 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
28 /**
29 * @class ACE_Proactor_Impl
31 * @brief A manager for asynchronous event demultiplexing. This class
32 * is the base class for all the concrete implementation
33 * classes.
35 * See the Proactor pattern description at
36 * http://www.dre.vanderbilt.edu/~schmidt/PDF/proactor.pdf for more
37 * details.
39 class ACE_Export ACE_Proactor_Impl : public ACE_Event_Handler
41 public:
42 /// Virtual destruction.
43 virtual ~ACE_Proactor_Impl ();
45 /// Close the IO completion port.
46 virtual int close () = 0;
48 /// This method adds the @a handle to the I/O completion port. This
49 /// function is a no-op function for Unix systems.
50 virtual int register_handle (ACE_HANDLE handle,
51 const void *completion_key) = 0;
53 /**
54 * Dispatch a single set of events. If @a wait_time elapses before
55 * any events occur, return 0. Return 1 on success i.e., when a
56 * completion is dispatched, non-zero (-1) on errors and errno is
57 * set accordingly.
59 virtual int handle_events (ACE_Time_Value &wait_time) = 0;
61 /**
62 * Block indefinitely until at least one event is dispatched.
63 * Dispatch a single set of events. If <wait_time> elapses before
64 * any events occur, return 0. Return 1 on success i.e., when a
65 * completion is dispatched, non-zero (-1) on errors and errno is
66 * set accordingly.
68 virtual int handle_events () = 0;
70 /// Add wakeup dispatch threads (reinit).
71 virtual int wake_up_dispatch_threads () = 0;
73 /// Close all dispatch threads.
74 virtual int close_dispatch_threads (int wait) = 0;
76 /// Get number of thread used as a parameter to CreatIoCompletionPort.
77 virtual size_t number_of_threads () const = 0;
79 /// Set number of thread used as a parameter to CreatIoCompletionPort.
80 virtual void number_of_threads (size_t threads) = 0;
82 /// Get the event handle.
83 virtual ACE_HANDLE get_handle () const = 0;
86 // = Factory methods for the operations
88 // Note that the user does not have to use or know about these
89 // methods.
91 /// Create the correct implementation class for doing Asynch_Read_Stream.
92 virtual ACE_Asynch_Read_Stream_Impl *create_asynch_read_stream () = 0;
94 /// Create the correct implementation class for doing Asynch_Write_Stream.
95 virtual ACE_Asynch_Write_Stream_Impl *create_asynch_write_stream () = 0;
97 /// Create the correct implementation class for doing Asynch_Read_File.
98 virtual ACE_Asynch_Read_File_Impl *create_asynch_read_file () = 0;
100 /// Create the correct implementation class for doing Asynch_Write_File.
101 virtual ACE_Asynch_Write_File_Impl *create_asynch_write_file () = 0;
103 /// Create the correct implementation class for doing Asynch_Accept.
104 virtual ACE_Asynch_Accept_Impl *create_asynch_accept () = 0;
106 /// Create the correct implementation class for doing Asynch_Connect.
107 virtual ACE_Asynch_Connect_Impl *create_asynch_connect () = 0;
109 /// Create the correct implementation class for doing Asynch_Transmit_File.
110 virtual ACE_Asynch_Transmit_File_Impl *create_asynch_transmit_file () = 0;
112 /// Create the correct implementation class for doing
113 /// Asynch_Read_Dgram.
114 virtual ACE_Asynch_Read_Dgram_Impl *create_asynch_read_dgram () = 0;
116 /// Create the correct implementation class for doing
117 /// Asynch_Write_Dgram.
118 virtual ACE_Asynch_Write_Dgram_Impl *create_asynch_write_dgram () = 0;
121 // = Factory methods for the results
123 // Note that the user does not have to use or know about these
124 // methods unless they want to "fake" results.
126 /// Create the correct implementation class for ACE_Asynch_Read_Stream::Result class.
127 virtual ACE_Asynch_Read_Stream_Result_Impl *
128 create_asynch_read_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
129 ACE_HANDLE handle,
130 ACE_Message_Block &message_block,
131 size_t bytes_to_read,
132 const void* act,
133 ACE_HANDLE event = ACE_INVALID_HANDLE,
134 int priority = 0,
135 int signal_number = ACE_SIGRTMIN) = 0;
137 /// Create the correct implementation class for ACE_Asynch_Write_Stream::Result.
138 virtual ACE_Asynch_Write_Stream_Result_Impl *
139 create_asynch_write_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
140 ACE_HANDLE handle,
141 ACE_Message_Block &message_block,
142 size_t bytes_to_write,
143 const void* act,
144 ACE_HANDLE event = ACE_INVALID_HANDLE,
145 int priority = 0,
146 int signal_number = ACE_SIGRTMIN) = 0;
148 /// Create the correct implementation class for ACE_Asynch_Read_File::Result.
149 virtual ACE_Asynch_Read_File_Result_Impl *
150 create_asynch_read_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
151 ACE_HANDLE handle,
152 ACE_Message_Block &message_block,
153 size_t bytes_to_read,
154 const void* act,
155 u_long offset,
156 u_long offset_high,
157 ACE_HANDLE event = ACE_INVALID_HANDLE,
158 int priority = 0,
159 int signal_number = ACE_SIGRTMIN) = 0;
161 /// Create the correct implementation class for ACE_Asynch_Write_File::Result.
162 virtual ACE_Asynch_Write_File_Result_Impl *
163 create_asynch_write_file_result (const ACE_Handler::Proxy_Ptr &handler,
164 ACE_HANDLE handle,
165 ACE_Message_Block &message_block,
166 size_t bytes_to_write,
167 const void* act,
168 u_long offset,
169 u_long offset_high,
170 ACE_HANDLE event = ACE_INVALID_HANDLE,
171 int priority = 0,
172 int signal_number = ACE_SIGRTMIN) = 0;
174 /// Create the correct implementation class for ACE_Asynch_Read_Dgram::Result.
175 virtual ACE_Asynch_Read_Dgram_Result_Impl *
176 create_asynch_read_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
177 ACE_HANDLE handle,
178 ACE_Message_Block *message_block,
179 size_t bytes_to_read,
180 int flags,
181 int protocol_family,
182 const void* act,
183 ACE_HANDLE event = ACE_INVALID_HANDLE,
184 int priority = 0,
185 int signal_number = ACE_SIGRTMIN) = 0;
187 /// Create the correct implementation class for ACE_Asynch_Write_Dgram::Result.
188 virtual ACE_Asynch_Write_Dgram_Result_Impl *
189 create_asynch_write_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
190 ACE_HANDLE handle,
191 ACE_Message_Block *message_block,
192 size_t bytes_to_write,
193 int flags,
194 const void* act,
195 ACE_HANDLE event = ACE_INVALID_HANDLE,
196 int priority = 0,
197 int signal_number = ACE_SIGRTMIN) = 0;
199 /// Create the correct implementation class for ACE_Asynch_Accept::Result.
200 virtual ACE_Asynch_Accept_Result_Impl *
201 create_asynch_accept_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
202 ACE_HANDLE listen_handle,
203 ACE_HANDLE accept_handle,
204 ACE_Message_Block &message_block,
205 size_t bytes_to_read,
206 const void* act,
207 ACE_HANDLE event = ACE_INVALID_HANDLE,
208 int priority = 0,
209 int signal_number = ACE_SIGRTMIN) = 0;
211 /// Create the correct implementation class for ACE_Asynch_Connect::Result.
212 virtual ACE_Asynch_Connect_Result_Impl *
213 create_asynch_connect_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
214 ACE_HANDLE connect_handle,
215 const void* act,
216 ACE_HANDLE event = ACE_INVALID_HANDLE,
217 int priority = 0,
218 int signal_number = ACE_SIGRTMIN) = 0;
220 /// Create the correct implementation class for ACE_Asynch_Transmit_File::Result.
221 virtual ACE_Asynch_Transmit_File_Result_Impl *
222 create_asynch_transmit_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
223 ACE_HANDLE socket,
224 ACE_HANDLE file,
225 ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
226 size_t bytes_to_write,
227 u_long offset,
228 u_long offset_high,
229 size_t bytes_per_send,
230 u_long flags,
231 const void *act,
232 ACE_HANDLE event = ACE_INVALID_HANDLE,
233 int priority = 0,
234 int signal_number = ACE_SIGRTMIN) = 0;
237 * Create the correct implementation object for the Timer
238 * result. POSIX_SIG_Proactor will create a Timer object with a
239 * meaningful signal number, if you leave the signal number as 0.
241 virtual ACE_Asynch_Result_Impl *
242 create_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_proxy,
243 const void *act,
244 const ACE_Time_Value &tv,
245 ACE_HANDLE event = ACE_INVALID_HANDLE,
246 int priority = 0,
247 int signal_number = 0) = 0;
250 * Post @a how_many completions to the completion port so that all
251 * threads can wake up. This is used in conjunction with the
252 * <run_event_loop>.
254 virtual int post_wakeup_completions (int how_many) = 0;
257 ACE_END_VERSIONED_NAMESPACE_DECL
259 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */
260 #include /**/ "ace/post.h"
261 #endif /* ACE_PROACTOR_IMPL_H */