ACE_WIN32_Proactor Class Reference

A manager for asynchronous event demultiplexing on Win32. More...

#include <WIN32_Proactor.h>

Inheritance diagram for ACE_WIN32_Proactor:

Inheritance graph
[legend]
Collaboration diagram for ACE_WIN32_Proactor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_WIN32_Proactor (size_t number_of_threads=0, int used_with_reactor_event_loop=0)
 A do nothing constructor.

virtual ~ACE_WIN32_Proactor (void)
 Virtual destruction.

virtual int close (void)
 Close the IO completion port.

virtual int register_handle (ACE_HANDLE handle, const void *completion_key)
virtual int handle_events (ACE_Time_Value &wait_time)
virtual int handle_events (void)
virtual int post_completion (ACE_WIN32_Asynch_Result *result)
int wake_up_dispatch_threads (void)
 Add wakeup dispatch threads (reinit).

int close_dispatch_threads (int wait)
 Close all dispatch threads.

size_t number_of_threads (void) const
 Get number of thread used as a parameter to CreateIoCompletionPort.

void number_of_threads (size_t threads)
 Set number of thread used as a parameter to CreateIoCompletionPort.

virtual ACE_HANDLE get_handle (void) const
 Get the event handle.

virtual ACE_Asynch_Read_Stream_Implcreate_asynch_read_stream (void)
 Create the correct implementation class for doing Asynch_Read_Stream.

virtual ACE_Asynch_Write_Stream_Implcreate_asynch_write_stream (void)
 Create the correct implementation class for doing Asynch_Write_Stream.

virtual ACE_Asynch_Read_File_Implcreate_asynch_read_file (void)
 Create the correct implementation class for doing Asynch_Read_File.

virtual ACE_Asynch_Write_File_Implcreate_asynch_write_file (void)
 Create the correct implementation class for doing Asynch_Write_File.

virtual ACE_Asynch_Read_Dgram_Implcreate_asynch_read_dgram (void)
virtual ACE_Asynch_Write_Dgram_Implcreate_asynch_write_dgram (void)
virtual ACE_Asynch_Accept_Implcreate_asynch_accept (void)
 Create the correct implementation class for doing Asynch_Accept.

virtual ACE_Asynch_Connect_Implcreate_asynch_connect (void)
 Create the correct implementation class for doing Asynch_Connect.

virtual ACE_Asynch_Transmit_File_Implcreate_asynch_transmit_file (void)
 Create the correct implementation class for doing Asynch_Transmit_File.

virtual ACE_Asynch_Read_Stream_Result_Implcreate_asynch_read_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block &message_block, size_t bytes_to_read, const void *act, ACE_HANDLE event, int priority, int signal_number=0)
 Create the correct implementation class for ACE_Asynch_Read_Stream::Result class.

virtual ACE_Asynch_Write_Stream_Result_Implcreate_asynch_write_stream_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block &message_block, size_t bytes_to_write, const void *act, ACE_HANDLE event, int priority, int signal_number=0)
 Create the correct implementation class for ACE_Asynch_Write_Stream::Result.

virtual ACE_Asynch_Read_File_Result_Implcreate_asynch_read_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block &message_block, size_t bytes_to_read, const void *act, u_long offset, u_long offset_high, ACE_HANDLE event, int priority, int signal_number=0)
 Create the correct implementation class for ACE_Asynch_Read_File::Result.

virtual ACE_Asynch_Write_File_Result_Implcreate_asynch_write_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block &message_block, size_t bytes_to_write, const void *act, u_long offset, u_long offset_high, ACE_HANDLE event, int priority, int signal_number=0)
 Create the correct implementation class for ACE_Asynch_Write_File::Result.

virtual ACE_Asynch_Read_Dgram_Result_Implcreate_asynch_read_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block *message_block, size_t bytes_to_read, int flags, int protocol_family, const void *act, ACE_HANDLE event, int priority, int signal_number=0)
 Create the correct implementation class for ACE_Asynch_Read_Dgram::Result.

virtual ACE_Asynch_Write_Dgram_Result_Implcreate_asynch_write_dgram_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE handle, ACE_Message_Block *message_block, size_t bytes_to_write, int flags, const void *act, ACE_HANDLE event, int priority, int signal_number=0)
 Create the correct implementation class for ACE_Asynch_Write_Dgram::Result.

virtual ACE_Asynch_Accept_Result_Implcreate_asynch_accept_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE listen_handle, ACE_HANDLE accept_handle, ACE_Message_Block &message_block, size_t bytes_to_read, const void *act, ACE_HANDLE event, int priority, int signal_number=0)
 Create the correct implementation class for ACE_Asynch_Accept::Result.

virtual ACE_Asynch_Connect_Result_Implcreate_asynch_connect_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE connect_handle, const void *act, ACE_HANDLE event, int priority, int signal_number=0)
 Create the correct implementation class for ACE_Asynch_Connect::Result.

virtual ACE_Asynch_Transmit_File_Result_Implcreate_asynch_transmit_file_result (const ACE_Handler::Proxy_Ptr &handler_proxy, ACE_HANDLE socket, ACE_HANDLE file, ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer, size_t bytes_to_write, u_long offset, u_long offset_high, size_t bytes_per_send, u_long flags, const void *act, ACE_HANDLE event, int priority, int signal_number=0)
 Create the correct implementation class for ACE_Asynch_Transmit_File::Result.

virtual ACE_Asynch_Result_Implcreate_asynch_timer (const ACE_Handler::Proxy_Ptr &handler_proxy, const void *act, const ACE_Time_Value &tv, ACE_HANDLE event, int priority, int signal_number=0)

Protected Member Functions

ACE_Asynch_Pseudo_Taskget_asynch_pseudo_task (void)
 Task to process pseudo-asynchronous operations.

virtual int handle_signal (int signum, siginfo_t *=0, ucontext_t *=0)
virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask)
 Called when object is removed from the ACE_Reactor.

virtual int handle_events (unsigned long milli_seconds)
void application_specific_code (ACE_WIN32_Asynch_Result *asynch_result, size_t bytes_transferred, const void *completion_key, u_long error)
virtual int post_wakeup_completions (int how_many)

Protected Attributes

ACE_HANDLE completion_port_
DWORD number_of_threads_
ACE_Auto_Event event_
 integrate the event loops of Reactor and the Proactor.

int used_with_reactor_event_loop_
ACE_Handler wakeup_handler_
ACE_Asynch_Pseudo_Task pseudo_task_

Friends

class ACE_WIN32_Asynch_Connect

Detailed Description

A manager for asynchronous event demultiplexing on Win32.

See the Proactor pattern description at http://www.cs.wustl.edu/~schmidt/PDF/proactor.pdf for more details.

Definition at line 52 of file WIN32_Proactor.h.


Constructor & Destructor Documentation

ACE_WIN32_Proactor::ACE_WIN32_Proactor size_t  number_of_threads = 0,
int  used_with_reactor_event_loop = 0
 

A do nothing constructor.

Definition at line 45 of file WIN32_Proactor.cpp.

References ACE_ERROR, ACE_LIB_TEXT, completion_port_, get_asynch_pseudo_task(), LM_ERROR, number_of_threads_, and ACE_Asynch_Pseudo_Task::start().

00047   : completion_port_ (0),
00048     // This *MUST* be 0, *NOT* ACE_INVALID_HANDLE !!!
00049     number_of_threads_ (static_cast<DWORD> (number_of_threads)),
00050     used_with_reactor_event_loop_ (used_with_reactor_event_loop)
00051 {
00052   // Create the completion port.
00053   this->completion_port_ = ::CreateIoCompletionPort (INVALID_HANDLE_VALUE,
00054                                                      0,
00055                                                      0,
00056                                                      this->number_of_threads_);
00057   if (this->completion_port_ == 0)
00058     ACE_ERROR ((LM_ERROR,
00059                 ACE_LIB_TEXT ("%p\n"),
00060                 ACE_LIB_TEXT ("CreateIoCompletionPort")));
00061 
00062   this->get_asynch_pseudo_task ().start ();
00063 }

ACE_WIN32_Proactor::~ACE_WIN32_Proactor void   )  [virtual]
 

Virtual destruction.

Definition at line 65 of file WIN32_Proactor.cpp.

References close(), get_asynch_pseudo_task(), and ACE_Asynch_Pseudo_Task::stop().

00066 {
00067   this->get_asynch_pseudo_task ().stop ();
00068 
00069   this->close ();
00070 }


Member Function Documentation

void ACE_WIN32_Proactor::application_specific_code ACE_WIN32_Asynch_Result asynch_result,
size_t  bytes_transferred,
const void *  completion_key,
u_long  error
[protected]
 

Protect against structured exceptions caused by user code when dispatching handles.

Definition at line 636 of file WIN32_Proactor.cpp.

References ACE_SEH_FINALLY, ACE_SEH_TRY, and ACE_Asynch_Result_Impl::complete().

Referenced by handle_events().

00640 {
00641   ACE_SEH_TRY
00642     {
00643       // Call completion hook
00644       asynch_result->complete (bytes_transferred,
00645                                error ? 0 : 1,
00646                                (void *) completion_key,
00647                                error);
00648     }
00649   ACE_SEH_FINALLY
00650     {
00651       // This is crucial to prevent memory leaks
00652       delete asynch_result;
00653     }
00654 }

int ACE_WIN32_Proactor::close void   )  [virtual]
 

Close the IO completion port.

Implements ACE_Proactor_Impl.

Definition at line 79 of file WIN32_Proactor.cpp.

References ACE_OVERLAPPED, ACE_OS::close(), and completion_port_.

Referenced by handle_close(), and ~ACE_WIN32_Proactor().

00080 {
00081   // Close the completion port
00082   if (this->completion_port_ != 0)
00083     {
00084       // To avoid memory leaks we should delete all results from queue.
00085 
00086       for (;;)
00087         {
00088           ACE_OVERLAPPED *overlapped = 0;
00089           u_long bytes_transferred = 0;
00090           ULONG_PTR completion_key = 0;
00091 
00092           // Get the next asynchronous operation that completes
00093           BOOL res = ::GetQueuedCompletionStatus
00094             (this->completion_port_,
00095              &bytes_transferred,
00096              &completion_key,
00097              &overlapped,
00098              0);  // poll
00099 
00100           if (overlapped == 0 || res == FALSE)
00101             break;
00102 
00103           ACE_WIN32_Asynch_Result *asynch_result =
00104             (ACE_WIN32_Asynch_Result *) overlapped;
00105 
00106           delete asynch_result;
00107         }
00108 
00109       int result = ACE_OS::close (this->completion_port_);
00110       this->completion_port_ = 0;
00111       return result;
00112     }
00113 
00114   return 0;
00115 }

int ACE_WIN32_Proactor::close_dispatch_threads int  wait  )  [virtual]
 

Close all dispatch threads.

Implements ACE_Proactor_Impl.

Definition at line 733 of file WIN32_Proactor.cpp.

00734 {
00735   return 0;
00736 }

ACE_Asynch_Accept_Impl * ACE_WIN32_Proactor::create_asynch_accept void   )  [virtual]
 

Create the correct implementation class for doing Asynch_Accept.

Implements ACE_Proactor_Impl.

Definition at line 208 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00209 {
00210   ACE_Asynch_Accept_Impl *implementation = 0;
00211   ACE_NEW_RETURN (implementation,
00212                   ACE_WIN32_Asynch_Accept (this),
00213                   0);
00214   return implementation;
00215 }

ACE_Asynch_Accept_Result_Impl * ACE_WIN32_Proactor::create_asynch_accept_result const ACE_Handler::Proxy_Ptr handler_proxy,
ACE_HANDLE  listen_handle,
ACE_HANDLE  accept_handle,
ACE_Message_Block message_block,
size_t  bytes_to_read,
const void *  act,
ACE_HANDLE  event,
int  priority,
int  signal_number = 0
[virtual]
 

Create the correct implementation class for ACE_Asynch_Accept::Result.

Implements ACE_Proactor_Impl.

Definition at line 403 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Handler::Proxy_Ptr.

00412 {
00413   ACE_Asynch_Accept_Result_Impl *implementation = 0;
00414   ACE_NEW_RETURN (implementation,
00415                   ACE_WIN32_Asynch_Accept_Result (handler_proxy,
00416                                                   listen_handle,
00417                                                   accept_handle,
00418                                                   message_block,
00419                                                   bytes_to_read,
00420                                                   act,
00421                                                   event,
00422                                                   priority,
00423                                                   signal_number),
00424                   0);
00425   return implementation;
00426 }

ACE_Asynch_Connect_Impl * ACE_WIN32_Proactor::create_asynch_connect void   )  [virtual]
 

Create the correct implementation class for doing Asynch_Connect.

Implements ACE_Proactor_Impl.

Definition at line 218 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00219 {
00220   ACE_Asynch_Connect_Impl *implementation = 0;
00221   ACE_NEW_RETURN (implementation,
00222                   ACE_WIN32_Asynch_Connect (this),
00223                   0);
00224   return implementation;
00225 }

ACE_Asynch_Connect_Result_Impl * ACE_WIN32_Proactor::create_asynch_connect_result const ACE_Handler::Proxy_Ptr handler_proxy,
ACE_HANDLE  connect_handle,
const void *  act,
ACE_HANDLE  event,
int  priority,
int  signal_number = 0
[virtual]
 

Create the correct implementation class for ACE_Asynch_Connect::Result.

Implements ACE_Proactor_Impl.

Definition at line 430 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Handler::Proxy_Ptr.

00436 {
00437   ACE_Asynch_Connect_Result_Impl *implementation = 0;
00438   ACE_NEW_RETURN (implementation,
00439                   ACE_WIN32_Asynch_Connect_Result (handler_proxy,
00440                                                    connect_handle,
00441                                                    act,
00442                                                    event,
00443                                                    priority,
00444                                                    signal_number),
00445                   0);
00446   return implementation;
00447 }

ACE_Asynch_Read_Dgram_Impl * ACE_WIN32_Proactor::create_asynch_read_dgram void   )  [virtual]
 

Create the correct implementation class for doing Asynch_Read_Dgram.

Implements ACE_Proactor_Impl.

Definition at line 168 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00169 {
00170   ACE_Asynch_Read_Dgram_Impl *implementation = 0;
00171   ACE_NEW_RETURN (implementation,
00172                   ACE_WIN32_Asynch_Read_Dgram (this),
00173                   0);
00174   return implementation;
00175 }

ACE_Asynch_Read_Dgram_Result_Impl * ACE_WIN32_Proactor::create_asynch_read_dgram_result const ACE_Handler::Proxy_Ptr handler_proxy,
ACE_HANDLE  handle,
ACE_Message_Block message_block,
size_t  bytes_to_read,
int  flags,
int  protocol_family,
const void *  act,
ACE_HANDLE  event,
int  priority,
int  signal_number = 0
[virtual]
 

Create the correct implementation class for ACE_Asynch_Read_Dgram::Result.

Implements ACE_Proactor_Impl.

Definition at line 347 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Handler::Proxy_Ptr.

00357 {
00358   ACE_Asynch_Read_Dgram_Result_Impl *implementation = 0;
00359   ACE_NEW_RETURN (implementation,
00360                   ACE_WIN32_Asynch_Read_Dgram_Result (handler_proxy,
00361                                                       handle,
00362                                                       message_block,
00363                                                       bytes_to_read,
00364                                                       flags,
00365                                                       protocol_family,
00366                                                       act,
00367                                                       event,
00368                                                       priority,
00369                                                       signal_number),
00370                   0);
00371   return implementation;
00372 }

ACE_Asynch_Read_File_Impl * ACE_WIN32_Proactor::create_asynch_read_file void   )  [virtual]
 

Create the correct implementation class for doing Asynch_Read_File.

Implements ACE_Proactor_Impl.

Definition at line 188 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00189 {
00190   ACE_Asynch_Read_File_Impl *implementation = 0;
00191   ACE_NEW_RETURN (implementation,
00192                   ACE_WIN32_Asynch_Read_File (this),
00193                   0);
00194   return  implementation;
00195 }

ACE_Asynch_Read_File_Result_Impl * ACE_WIN32_Proactor::create_asynch_read_file_result const ACE_Handler::Proxy_Ptr handler_proxy,
ACE_HANDLE  handle,
ACE_Message_Block message_block,
size_t  bytes_to_read,
const void *  act,
u_long  offset,
u_long  offset_high,
ACE_HANDLE  event,
int  priority,
int  signal_number = 0
[virtual]
 

Create the correct implementation class for ACE_Asynch_Read_File::Result.

Implements ACE_Proactor_Impl.

Definition at line 289 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Handler::Proxy_Ptr.

00299 {
00300   ACE_Asynch_Read_File_Result_Impl *implementation = 0;
00301   ACE_NEW_RETURN (implementation,
00302                   ACE_WIN32_Asynch_Read_File_Result (handler_proxy,
00303                                                      handle,
00304                                                      message_block,
00305                                                      bytes_to_read,
00306                                                      act,
00307                                                      offset,
00308                                                      offset_high,
00309                                                      event,
00310                                                      priority,
00311                                                      signal_number),
00312                   0);
00313   return implementation;
00314 }

ACE_Asynch_Read_Stream_Impl * ACE_WIN32_Proactor::create_asynch_read_stream void   )  [virtual]
 

Create the correct implementation class for doing Asynch_Read_Stream.

Implements ACE_Proactor_Impl.

Definition at line 148 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00149 {
00150   ACE_Asynch_Read_Stream_Impl *implementation = 0;
00151   ACE_NEW_RETURN (implementation,
00152                   ACE_WIN32_Asynch_Read_Stream (this),
00153                   0);
00154   return implementation;
00155 }

ACE_Asynch_Read_Stream_Result_Impl * ACE_WIN32_Proactor::create_asynch_read_stream_result const ACE_Handler::Proxy_Ptr handler_proxy,
ACE_HANDLE  handle,
ACE_Message_Block message_block,
size_t  bytes_to_read,
const void *  act,
ACE_HANDLE  event,
int  priority,
int  signal_number = 0
[virtual]
 

Create the correct implementation class for ACE_Asynch_Read_Stream::Result class.

Implements ACE_Proactor_Impl.

Definition at line 239 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Handler::Proxy_Ptr.

00247 {
00248   ACE_Asynch_Read_Stream_Result_Impl *implementation = 0;
00249   ACE_NEW_RETURN (implementation,
00250                   ACE_WIN32_Asynch_Read_Stream_Result (handler_proxy,
00251                                                        handle,
00252                                                        message_block,
00253                                                        bytes_to_read,
00254                                                        act,
00255                                                        event,
00256                                                        priority,
00257                                                        signal_number),
00258                   0);
00259   return implementation;
00260 }

ACE_Asynch_Result_Impl * ACE_WIN32_Proactor::create_asynch_timer const ACE_Handler::Proxy_Ptr handler_proxy,
const void *  act,
const ACE_Time_Value tv,
ACE_HANDLE  event,
int  priority,
int  signal_number = 0
[virtual]
 

Create a timer result object which can be used with the Timer mechanism of the Proactor.

Implements ACE_Proactor_Impl.

Definition at line 485 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Handler::Proxy_Ptr.

00491 {
00492   ACE_Asynch_Result_Impl *implementation = 0;
00493   ACE_NEW_RETURN (implementation,
00494                   ACE_WIN32_Asynch_Timer (handler_proxy,
00495                                           act,
00496                                           tv,
00497                                           event,
00498                                           priority,
00499                                           signal_number),
00500                   0);
00501   return implementation;
00502 }

ACE_Asynch_Transmit_File_Impl * ACE_WIN32_Proactor::create_asynch_transmit_file void   )  [virtual]
 

Create the correct implementation class for doing Asynch_Transmit_File.

Implements ACE_Proactor_Impl.

Definition at line 228 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00229 {
00230   ACE_Asynch_Transmit_File_Impl *implementation = 0;
00231   ACE_NEW_RETURN (implementation,
00232                   ACE_WIN32_Asynch_Transmit_File (this),
00233                   0);
00234   return  implementation;
00235 }

ACE_Asynch_Transmit_File_Result_Impl * ACE_WIN32_Proactor::create_asynch_transmit_file_result const ACE_Handler::Proxy_Ptr handler_proxy,
ACE_HANDLE  socket,
ACE_HANDLE  file,
ACE_Asynch_Transmit_File::Header_And_Trailer header_and_trailer,
size_t  bytes_to_write,
u_long  offset,
u_long  offset_high,
size_t  bytes_per_send,
u_long  flags,
const void *  act,
ACE_HANDLE  event,
int  priority,
int  signal_number = 0
[virtual]
 

Create the correct implementation class for ACE_Asynch_Transmit_File::Result.

Implements ACE_Proactor_Impl.

Definition at line 451 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Handler::Proxy_Ptr.

00464 {
00465   ACE_Asynch_Transmit_File_Result_Impl *implementation = 0;
00466   ACE_NEW_RETURN (implementation,
00467                   ACE_WIN32_Asynch_Transmit_File_Result (handler_proxy,
00468                                                          socket,
00469                                                          file,
00470                                                          header_and_trailer,
00471                                                          bytes_to_write,
00472                                                          offset,
00473                                                          offset_high,
00474                                                          bytes_per_send,
00475                                                          flags,
00476                                                          act,
00477                                                          event,
00478                                                          priority,
00479                                                          signal_number),
00480                   0);
00481   return implementation;
00482 }

ACE_Asynch_Write_Dgram_Impl * ACE_WIN32_Proactor::create_asynch_write_dgram void   )  [virtual]
 

Create the correct implementation class for doing Asynch_Write_Dgram.

Implements ACE_Proactor_Impl.

Definition at line 178 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00179 {
00180   ACE_Asynch_Write_Dgram_Impl *implementation = 0;
00181   ACE_NEW_RETURN (implementation,
00182                   ACE_WIN32_Asynch_Write_Dgram (this),
00183                   0);
00184   return implementation;
00185 }

ACE_Asynch_Write_Dgram_Result_Impl * ACE_WIN32_Proactor::create_asynch_write_dgram_result const ACE_Handler::Proxy_Ptr handler_proxy,
ACE_HANDLE  handle,
ACE_Message_Block message_block,
size_t  bytes_to_write,
int  flags,
const void *  act,
ACE_HANDLE  event,
int  priority,
int  signal_number = 0
[virtual]
 

Create the correct implementation class for ACE_Asynch_Write_Dgram::Result.

Implements ACE_Proactor_Impl.

Definition at line 376 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Handler::Proxy_Ptr.

00385 {
00386   ACE_Asynch_Write_Dgram_Result_Impl *implementation = 0;
00387   ACE_NEW_RETURN (implementation,
00388                   ACE_WIN32_Asynch_Write_Dgram_Result(handler_proxy,
00389                                                       handle,
00390                                                       message_block,
00391                                                       bytes_to_read,
00392                                                       flags,
00393                                                       act,
00394                                                       event,
00395                                                       priority,
00396                                                       signal_number),
00397                  0);
00398   return implementation;
00399 }

ACE_Asynch_Write_File_Impl * ACE_WIN32_Proactor::create_asynch_write_file void   )  [virtual]
 

Create the correct implementation class for doing Asynch_Write_File.

Implements ACE_Proactor_Impl.

Definition at line 198 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00199 {
00200   ACE_Asynch_Write_File_Impl *implementation = 0;
00201   ACE_NEW_RETURN (implementation,
00202                   ACE_WIN32_Asynch_Write_File (this),
00203                   0);
00204   return  implementation;
00205 }

ACE_Asynch_Write_File_Result_Impl * ACE_WIN32_Proactor::create_asynch_write_file_result const ACE_Handler::Proxy_Ptr handler_proxy,
ACE_HANDLE  handle,
ACE_Message_Block message_block,
size_t  bytes_to_write,
const void *  act,
u_long  offset,
u_long  offset_high,
ACE_HANDLE  event,
int  priority,
int  signal_number = 0
[virtual]
 

Create the correct implementation class for ACE_Asynch_Write_File::Result.

Implements ACE_Proactor_Impl.

Definition at line 318 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Handler::Proxy_Ptr.

00328 {
00329   ACE_Asynch_Write_File_Result_Impl *implementation = 0;
00330   ACE_NEW_RETURN (implementation,
00331                   ACE_WIN32_Asynch_Write_File_Result (handler_proxy,
00332                                                       handle,
00333                                                       message_block,
00334                                                       bytes_to_write,
00335                                                       act,
00336                                                       offset,
00337                                                       offset_high,
00338                                                       event,
00339                                                       priority,
00340                                                       signal_number),
00341                   0);
00342   return implementation;
00343 }

ACE_Asynch_Write_Stream_Impl * ACE_WIN32_Proactor::create_asynch_write_stream void   )  [virtual]
 

Create the correct implementation class for doing Asynch_Write_Stream.

Implements ACE_Proactor_Impl.

Definition at line 158 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00159 {
00160   ACE_Asynch_Write_Stream_Impl *implementation = 0;
00161   ACE_NEW_RETURN (implementation,
00162                   ACE_WIN32_Asynch_Write_Stream (this),
00163                   0);
00164   return implementation;
00165 }

ACE_Asynch_Write_Stream_Result_Impl * ACE_WIN32_Proactor::create_asynch_write_stream_result const ACE_Handler::Proxy_Ptr handler_proxy,
ACE_HANDLE  handle,
ACE_Message_Block message_block,
size_t  bytes_to_write,
const void *  act,
ACE_HANDLE  event,
int  priority,
int  signal_number = 0
[virtual]
 

Create the correct implementation class for ACE_Asynch_Write_Stream::Result.

Implements ACE_Proactor_Impl.

Definition at line 264 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Handler::Proxy_Ptr.

00272 {
00273   ACE_Asynch_Write_Stream_Result_Impl *implementation = 0;
00274   ACE_NEW_RETURN (implementation,
00275                   ACE_WIN32_Asynch_Write_Stream_Result (handler_proxy,
00276                                                         handle,
00277                                                         message_block,
00278                                                         bytes_to_write,
00279                                                         act,
00280                                                         event,
00281                                                         priority,
00282                                                         signal_number),
00283                   0);
00284   return implementation;
00285 }

ACE_Asynch_Pseudo_Task & ACE_WIN32_Proactor::get_asynch_pseudo_task void   )  [protected]
 

Task to process pseudo-asynchronous operations.

Definition at line 73 of file WIN32_Proactor.cpp.

Referenced by ACE_WIN32_Proactor(), ACE_WIN32_Asynch_Connect::cancel(), ACE_WIN32_Asynch_Connect::close(), ACE_WIN32_Asynch_Connect::connect(), ACE_WIN32_Asynch_Connect::handle_close(), ACE_WIN32_Asynch_Connect::handle_output(), and ~ACE_WIN32_Proactor().

00074 {
00075   return this->pseudo_task_;
00076 }

ACE_HANDLE ACE_WIN32_Proactor::get_handle void   )  const [virtual]
 

Get the event handle.

Implements ACE_Proactor_Impl.

Definition at line 538 of file WIN32_Proactor.cpp.

References ACE_Event::handle(), and used_with_reactor_event_loop_.

Referenced by post_completion().

00539 {
00540   if (this->used_with_reactor_event_loop_)
00541     return this->event_.handle ();
00542   else
00543     return 0;
00544 }

int ACE_WIN32_Proactor::handle_close ACE_HANDLE  handle,
ACE_Reactor_Mask  close_mask
[protected, virtual]
 

Called when object is removed from the ACE_Reactor.

Reimplemented from ACE_Event_Handler.

Definition at line 528 of file WIN32_Proactor.cpp.

References ACE_Reactor_Mask, and close().

00530 {
00531   ACE_UNUSED_ARG (close_mask);
00532   ACE_UNUSED_ARG (handle);
00533 
00534   return this->close ();
00535 }

int ACE_WIN32_Proactor::handle_events unsigned long  milli_seconds  )  [protected, virtual]
 

Dispatch a single set of events. If milli_seconds elapses before any events occur, return 0. Return 1 if a completion is dispatched. Return -1 on errors.

Definition at line 561 of file WIN32_Proactor.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, ACE_OVERLAPPED, application_specific_code(), completion_port_, ACE::debug(), ACE_WIN32_Asynch_Result::error(), ETIME, LM_ERROR, and ACE_OS::set_errno_to_last_error().

00562 {
00563   ACE_OVERLAPPED *overlapped = 0;
00564   u_long bytes_transferred = 0;
00565   ULONG_PTR completion_key = 0;
00566 
00567   // Get the next asynchronous operation that completes
00568   BOOL result = ::GetQueuedCompletionStatus (this->completion_port_,
00569                                              &bytes_transferred,
00570                                              &completion_key,
00571                                              &overlapped,
00572                                              milli_seconds);
00573   if (result == FALSE && overlapped == 0)
00574     {
00575       ACE_OS::set_errno_to_last_error ();
00576 
00577       switch (errno)
00578         {
00579         case WAIT_TIMEOUT:
00580           errno = ETIME;
00581           return 0;
00582 
00583         case ERROR_SUCCESS:
00584           // Calling GetQueuedCompletionStatus with timeout value 0
00585           // returns FALSE with extended errno "ERROR_SUCCESS" errno =
00586           // ETIME; ?? I don't know if this has to be done !!
00587           return 0;
00588 
00589         default:
00590           if (ACE::debug ())
00591             ACE_DEBUG ((LM_ERROR,
00592                         ACE_LIB_TEXT ("%p\n"),
00593                         ACE_LIB_TEXT ("GetQueuedCompletionStatus")));
00594           return -1;
00595         }
00596     }
00597   else
00598     {
00599       // Narrow the result.
00600       ACE_WIN32_Asynch_Result *asynch_result = (ACE_WIN32_Asynch_Result *) overlapped;
00601 
00602       // If errors happen, grab the error.
00603       if (result == FALSE)
00604         ACE_OS::set_errno_to_last_error ();
00605       else
00606         errno = 0;
00607 
00608       u_long result_err = asynch_result->error ();
00609 
00610       // if "result_err" is 0 than
00611       //     It is normal OS/WIN32 AIO completion.
00612       //     We have cleared asynch_result->error_
00613       //     during shared_read/shared_write.
00614       //     The real error code is already stored in "errno",
00615       //     so copy "errno" value to the "result_err"
00616       //     and pass this "result_err" code
00617       //     to the application_specific_code ()
00618       // else
00619       //    "result_err" non zero
00620       //     it means we have "post_completed" result
00621       //     so pass this "result_err" code
00622       //     to the application_specific_code ()
00623 
00624       if (result_err == 0)
00625         result_err = errno ;
00626 
00627       this->application_specific_code (asynch_result,
00628                                        static_cast<size_t> (bytes_transferred),
00629                                        (void *) completion_key,
00630                                        result_err);
00631     }
00632   return 1;
00633 }

int ACE_WIN32_Proactor::handle_events void   )  [virtual]
 

Block indefinitely until at least one event is dispatched. Dispatch a single set of events. Return 1 on success i.e., when a completion is dispatched, non-zero (-1) on errors and errno is set accordingly.

Implements ACE_Proactor_Impl.

Definition at line 555 of file WIN32_Proactor.cpp.

References ACE_INFINITE.

Referenced by handle_events(), and handle_signal().

00556 {
00557   return this->handle_events (ACE_INFINITE);
00558 }

int ACE_WIN32_Proactor::handle_events ACE_Time_Value wait_time  )  [virtual]
 

Dispatch a single set of events. If wait_time elapses before any events occur, return 0. Return 1 on success i.e., when a completion is dispatched, non-zero (-1) on errors and errno is set accordingly.

Implements ACE_Proactor_Impl.

Definition at line 547 of file WIN32_Proactor.cpp.

References handle_events(), and ACE_Time_Value::msec().

00548 {
00549   // Decrement <wait_time> with the amount of time spent in the method
00550   ACE_Countdown_Time countdown (&wait_time);
00551   return this->handle_events (wait_time.msec ());
00552 }

int ACE_WIN32_Proactor::handle_signal int  signum,
siginfo_t = 0,
ucontext_t = 0
[protected, virtual]
 

Called when object is signaled by OS (either via UNIX signals or when a Win32 object becomes signaled).

Reimplemented from ACE_Event_Handler.

Definition at line 505 of file WIN32_Proactor.cpp.

References handle_events(), and ucontext_t.

00506 {
00507   // Perform a non-blocking "poll" for all the I/O events that have
00508   // completed in the I/O completion queue.
00509 
00510   int result = 0;
00511 
00512   for (ACE_Time_Value timeout (0, 0);
00513        ;
00514       )
00515     {
00516       result = this->handle_events (timeout);
00517 
00518       if (result != 1)
00519         break;
00520     }
00521 
00522   // If our handle_events failed, we'll report a failure to the
00523   // Reactor.
00524   return result == -1 ? -1 : 0;
00525 }

void ACE_WIN32_Proactor::number_of_threads size_t  threads  )  [virtual]
 

Set number of thread used as a parameter to CreateIoCompletionPort.

Implements ACE_Proactor_Impl.

Definition at line 745 of file WIN32_Proactor.cpp.

References number_of_threads_.

00746 {
00747   this->number_of_threads_ = static_cast<DWORD> (threads);
00748 }

size_t ACE_WIN32_Proactor::number_of_threads void   )  const [virtual]
 

Get number of thread used as a parameter to CreateIoCompletionPort.

Implements ACE_Proactor_Impl.

Definition at line 739 of file WIN32_Proactor.cpp.

References number_of_threads_.

00740 {
00741   return static_cast<size_t> (this->number_of_threads_);
00742 }

int ACE_WIN32_Proactor::post_completion ACE_WIN32_Asynch_Result result  )  [virtual]
 

Post a result to the completion port of the Proactor. If errors occur, the result will be deleted by this method. If successful, the result will be deleted by the Proactor when the result is removed from the completion port. Therefore, the result should have been dynamically allocated and should be orphaned by the user once this method is called.

Definition at line 657 of file WIN32_Proactor.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, ACE_WIN32_Asynch_Result::bytes_transferred(), ACE_WIN32_Asynch_Result::completion_key(), completion_port_, ACE::debug(), ACE_OS::event_signal(), get_handle(), and LM_ERROR.

Referenced by ACE_WIN32_Asynch_Result::post_completion(), and ACE_WIN32_Asynch_Connect::post_result().

00658 {
00659   // Grab the event associated with the Proactor
00660   HANDLE handle = this->get_handle ();
00661 
00662   // pass
00663   //   bytes_transferred
00664   //   completion_key
00665   // to the ::PostQueuedCompletionStatus()
00666   //   error will be extracted later in handle_events()
00667 
00668   DWORD bytes_transferred = 0;
00669   const void * completion_key = 0 ;
00670 
00671   if (result != 0)
00672     {
00673       // This cast is ok since the original API calls restricted the transfer
00674       // counts to DWORD range.
00675       bytes_transferred = static_cast<DWORD> (result->bytes_transferred ());
00676       completion_key = result->completion_key();
00677     }
00678 
00679   ULONG_PTR comp_key (reinterpret_cast<ULONG_PTR> (completion_key));
00680 
00681   // Post a completion
00682   if (::PostQueuedCompletionStatus (this->completion_port_, // completion port
00683                                     bytes_transferred,      // xfer count
00684                                     comp_key,               // completion key
00685                                     result                  // overlapped
00686                                    ) == FALSE)
00687     {
00688       delete result;
00689 
00690       if (ACE::debug ())
00691         {
00692           ACE_DEBUG ((LM_ERROR,
00693                       ACE_LIB_TEXT ("%p\n"),
00694                       ACE_LIB_TEXT ("PostQueuedCompletionStatus failed")));
00695         }
00696       return -1;
00697     }
00698 
00699   // If Proactor event is valid, signal it
00700   if (handle != ACE_INVALID_HANDLE
00701       && handle != 0)
00702     ACE_OS::event_signal (&handle);
00703 
00704   return 0;
00705 }

int ACE_WIN32_Proactor::post_wakeup_completions int  how_many  )  [protected, virtual]
 

Post how_many completions to the completion port so that all threads can wake up. This is used in conjunction with the run_event_loop().

Implements ACE_Proactor_Impl.

Definition at line 708 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ssize_t.

00709 {
00710   ACE_WIN32_Wakeup_Completion *wakeup_completion = 0;
00711 
00712   for (ssize_t ci = 0; ci < how_many; ci++)
00713     {
00714       ACE_NEW_RETURN
00715         (wakeup_completion,
00716          ACE_WIN32_Wakeup_Completion (this->wakeup_handler_.proxy ()),
00717          -1);
00718 
00719       if (wakeup_completion->post_completion (this) == -1)
00720         return -1;
00721     }
00722 
00723   return 0;
00724 }

int ACE_WIN32_Proactor::register_handle ACE_HANDLE  handle,
const void *  completion_key
[virtual]
 

This method adds the handle to the I/O completion port. This function is a no-op function for Unix systems.

Implements ACE_Proactor_Impl.

Definition at line 118 of file WIN32_Proactor.cpp.

References ACE_DEBUG, ACE_LIB_TEXT, completion_port_, ACE::debug(), LM_ERROR, number_of_threads_, and ACE_OS::set_errno_to_last_error().

Referenced by ACE_WIN32_Asynch_Operation::open().

00120 {
00121   ULONG_PTR comp_key (reinterpret_cast<ULONG_PTR> (completion_key));
00122 
00123   // No locking is needed here as no state changes.
00124   ACE_HANDLE cp = ::CreateIoCompletionPort (handle,
00125                                             this->completion_port_,
00126                                             comp_key,
00127                                             this->number_of_threads_);
00128   if (cp == 0)
00129     {
00130       ACE_OS::set_errno_to_last_error ();
00131       // If errno == ERROR_INVALID_PARAMETER, then this handle was
00132       // already registered.
00133       if (errno != ERROR_INVALID_PARAMETER)
00134         {
00135           if (ACE::debug ())
00136             {
00137               ACE_DEBUG ((LM_ERROR,
00138                           ACE_LIB_TEXT ("%p\n"),
00139                           ACE_LIB_TEXT ("CreateIoCompletionPort")));
00140             }
00141           return -1;
00142         }
00143     }
00144   return 0;
00145 }

int ACE_WIN32_Proactor::wake_up_dispatch_threads void   )  [virtual]
 

Add wakeup dispatch threads (reinit).

Implements ACE_Proactor_Impl.

Definition at line 727 of file WIN32_Proactor.cpp.

00728 {
00729   return 0;
00730 }


Friends And Related Function Documentation

friend class ACE_WIN32_Asynch_Connect [friend]
 

Definition at line 54 of file WIN32_Proactor.h.


Member Data Documentation

ACE_HANDLE ACE_WIN32_Proactor::completion_port_ [protected]
 

Handle for the completion port. Unix doesnt have completion ports.

Definition at line 265 of file WIN32_Proactor.h.

Referenced by ACE_WIN32_Proactor(), close(), handle_events(), post_completion(), and register_handle().

ACE_Auto_Event ACE_WIN32_Proactor::event_ [protected]
 

integrate the event loops of Reactor and the Proactor.

This event is used in conjunction with Reactor when we try to

Definition at line 273 of file WIN32_Proactor.h.

DWORD ACE_WIN32_Proactor::number_of_threads_ [protected]
 

This number is passed to the CreateIOCompletionPort system call.

Definition at line 269 of file WIN32_Proactor.h.

Referenced by ACE_WIN32_Proactor(), number_of_threads(), and register_handle().

ACE_Asynch_Pseudo_Task ACE_WIN32_Proactor::pseudo_task_ [protected]
 

Pseudo-task for asynch connect ( NT/2000) In future should removed in XP with ConnectEx support

Definition at line 285 of file WIN32_Proactor.h.

int ACE_WIN32_Proactor::used_with_reactor_event_loop_ [protected]
 

Flag that indicates whether we are used in conjunction with Reactor.

Definition at line 277 of file WIN32_Proactor.h.

Referenced by get_handle().

ACE_Handler ACE_WIN32_Proactor::wakeup_handler_ [protected]
 

Handler to handle the wakeups. This works in conjunction with the ACE_Proactor::run_event_loop().

Definition at line 281 of file WIN32_Proactor.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:33:27 2006 for ACE by doxygen 1.3.6