00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef ACE_WIN32_PROACTOR_H
00018 #define ACE_WIN32_PROACTOR_H
00019 #include "ace/pre.h"
00020
00021 #include "ace/config-all.h"
00022
00023 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00024 #pragma once
00025 #endif
00026
00027 #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
00028
00029
00030 #include "ace/WIN32_Asynch_IO.h"
00031 #include "ace/Event_Handler.h"
00032
00033 #include "ace/Proactor_Impl.h"
00034 #include "ace/Asynch_Pseudo_Task.h"
00035 #include "ace/Auto_Event.h"
00036
00037 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00038
00039
00040 class ACE_WIN32_Asynch_Result;
00041 class ACE_WIN32_Proactor_Timer_Handler;
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 class ACE_Export ACE_WIN32_Proactor : public ACE_Proactor_Impl
00053 {
00054 friend class ACE_WIN32_Asynch_Connect;
00055
00056 public:
00057
00058 ACE_WIN32_Proactor (size_t number_of_threads = 0,
00059 int used_with_reactor_event_loop = 0);
00060
00061
00062 virtual ~ACE_WIN32_Proactor (void);
00063
00064
00065 virtual int close (void);
00066
00067
00068
00069 virtual int register_handle (ACE_HANDLE handle,
00070 const void *completion_key);
00071
00072
00073
00074
00075
00076
00077
00078 virtual int handle_events (ACE_Time_Value &wait_time);
00079
00080
00081
00082
00083
00084
00085
00086 virtual int handle_events (void);
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096 virtual int post_completion (ACE_WIN32_Asynch_Result *result);
00097
00098
00099 int wake_up_dispatch_threads (void);
00100
00101
00102 int close_dispatch_threads (int wait);
00103
00104
00105 size_t number_of_threads (void) const;
00106
00107
00108 void number_of_threads (size_t threads);
00109
00110
00111 virtual ACE_HANDLE get_handle (void) const;
00112
00113 virtual ACE_Asynch_Read_Stream_Impl *create_asynch_read_stream (void);
00114 virtual ACE_Asynch_Write_Stream_Impl *create_asynch_write_stream (void);
00115 virtual ACE_Asynch_Read_File_Impl *create_asynch_read_file (void);
00116 virtual ACE_Asynch_Write_File_Impl *create_asynch_write_file (void);
00117 virtual ACE_Asynch_Read_Dgram_Impl *create_asynch_read_dgram (void);
00118 virtual ACE_Asynch_Write_Dgram_Impl *create_asynch_write_dgram (void);
00119 virtual ACE_Asynch_Accept_Impl *create_asynch_accept (void);
00120 virtual ACE_Asynch_Connect_Impl *create_asynch_connect (void);
00121 virtual ACE_Asynch_Transmit_File_Impl *create_asynch_transmit_file (void);
00122
00123
00124
00125
00126 virtual ACE_Asynch_Read_Stream_Result_Impl *create_asynch_read_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
00127 ACE_HANDLE handle,
00128 ACE_Message_Block &message_block,
00129 size_t bytes_to_read,
00130 const void* act,
00131 ACE_HANDLE event,
00132 int priority,
00133 int signal_number = 0);
00134
00135 virtual ACE_Asynch_Write_Stream_Result_Impl *create_asynch_write_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
00136 ACE_HANDLE handle,
00137 ACE_Message_Block &message_block,
00138 size_t bytes_to_write,
00139 const void* act,
00140 ACE_HANDLE event,
00141 int priority,
00142 int signal_number = 0);
00143
00144 virtual ACE_Asynch_Read_File_Result_Impl *create_asynch_read_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
00145 ACE_HANDLE handle,
00146 ACE_Message_Block &message_block,
00147 size_t bytes_to_read,
00148 const void* act,
00149 u_long offset,
00150 u_long offset_high,
00151 ACE_HANDLE event,
00152 int priority,
00153 int signal_number = 0);
00154
00155 virtual ACE_Asynch_Write_File_Result_Impl *create_asynch_write_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
00156 ACE_HANDLE handle,
00157 ACE_Message_Block &message_block,
00158 size_t bytes_to_write,
00159 const void* act,
00160 u_long offset,
00161 u_long offset_high,
00162 ACE_HANDLE event,
00163 int priority,
00164 int signal_number = 0);
00165
00166
00167 virtual ACE_Asynch_Read_Dgram_Result_Impl *create_asynch_read_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
00168 ACE_HANDLE handle,
00169 ACE_Message_Block *message_block,
00170 size_t bytes_to_read,
00171 int flags,
00172 int protocol_family,
00173 const void* act,
00174 ACE_HANDLE event,
00175 int priority,
00176 int signal_number = 0);
00177
00178
00179 virtual ACE_Asynch_Write_Dgram_Result_Impl *create_asynch_write_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
00180 ACE_HANDLE handle,
00181 ACE_Message_Block *message_block,
00182 size_t bytes_to_write,
00183 int flags,
00184 const void* act,
00185 ACE_HANDLE event,
00186 int priority,
00187 int signal_number = 0);
00188
00189 virtual ACE_Asynch_Accept_Result_Impl *create_asynch_accept_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
00190 ACE_HANDLE listen_handle,
00191 ACE_HANDLE accept_handle,
00192 ACE_Message_Block &message_block,
00193 size_t bytes_to_read,
00194 const void* act,
00195 ACE_HANDLE event,
00196 int priority,
00197 int signal_number = 0);
00198
00199 virtual ACE_Asynch_Connect_Result_Impl *create_asynch_connect_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
00200 ACE_HANDLE connect_handle,
00201 const void *act,
00202 ACE_HANDLE event,
00203 int priority,
00204 int signal_number = 0);
00205
00206
00207 virtual ACE_Asynch_Transmit_File_Result_Impl *create_asynch_transmit_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy,
00208 ACE_HANDLE socket,
00209 ACE_HANDLE file,
00210 ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
00211 size_t bytes_to_write,
00212 u_long offset,
00213 u_long offset_high,
00214 size_t bytes_per_send,
00215 u_long flags,
00216 const void *act,
00217 ACE_HANDLE event,
00218 int priority,
00219 int signal_number = 0);
00220
00221
00222
00223 virtual ACE_Asynch_Result_Impl *create_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_proxy,
00224 const void *act,
00225 const ACE_Time_Value &tv,
00226 ACE_HANDLE event,
00227 int priority,
00228 int signal_number = 0);
00229
00230 protected:
00231
00232 ACE_Asynch_Pseudo_Task & get_asynch_pseudo_task (void);
00233
00234
00235
00236 virtual int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0);
00237
00238
00239 virtual int handle_close (ACE_HANDLE handle,
00240 ACE_Reactor_Mask close_mask);
00241
00242
00243
00244
00245
00246
00247 virtual int handle_events (unsigned long milli_seconds);
00248
00249
00250
00251 void application_specific_code (ACE_WIN32_Asynch_Result *asynch_result,
00252 size_t bytes_transferred,
00253 const void *completion_key,
00254 u_long error);
00255
00256
00257
00258
00259
00260
00261 virtual int post_wakeup_completions (int how_many);
00262
00263
00264
00265 ACE_HANDLE completion_port_;
00266
00267
00268
00269 DWORD number_of_threads_;
00270
00271
00272
00273 ACE_Auto_Event event_;
00274
00275
00276
00277 int used_with_reactor_event_loop_;
00278
00279
00280
00281 ACE_Handler wakeup_handler_;
00282
00283
00284
00285 ACE_Asynch_Pseudo_Task pseudo_task_;
00286 };
00287
00288
00289
00290
00291
00292
00293
00294
00295
00296 class ACE_WIN32_Asynch_Timer : public ACE_WIN32_Asynch_Result
00297 {
00298
00299
00300 friend class ACE_WIN32_Proactor;
00301
00302 protected:
00303
00304 ACE_WIN32_Asynch_Timer (const ACE_Handler::Proxy_Ptr &handler_proxy,
00305 const void *act,
00306 const ACE_Time_Value &tv,
00307 ACE_HANDLE event = ACE_INVALID_HANDLE,
00308 int priority = 0,
00309 int signal_number = 0);
00310
00311
00312 virtual void complete (size_t bytes_transferred,
00313 int success,
00314 const void *completion_key,
00315 u_long error = 0);
00316
00317
00318 ACE_Time_Value time_;
00319 };
00320
00321 ACE_END_VERSIONED_NAMESPACE_DECL
00322
00323 #endif
00324 #include "ace/post.h"
00325 #endif