Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

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 Methods

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

virtual ~ACE_WIN32_Proactor (void)
 Virtual destruction. More...

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

virtual int register_handle (ACE_HANDLE handle, const void *completion_key)
 This method adds the <handle> to the I/O completion port. This function is a no-op function for Unix systems. More...

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). More...

int close_dispatch_threads (int wait)
 Close all dispatch threads. More...

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

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

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

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

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

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

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

virtual ACE_Asynch_Read_Dgram_Implcreate_asynch_read_dgram (void)
 Create the correct implementation class for doing Asynch_Read_Dgram. More...

virtual ACE_Asynch_Write_Dgram_Implcreate_asynch_write_dgram (void)
 Create the correct implementation class for doing Asynch_Write_Dgram. More...

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

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

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

virtual ACE_Asynch_Read_Stream_Result_Implcreate_asynch_read_stream_result (ACE_Handler &handler, 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. More...

virtual ACE_Asynch_Write_Stream_Result_Implcreate_asynch_write_stream_result (ACE_Handler &handler, 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. More...

virtual ACE_Asynch_Read_File_Result_Implcreate_asynch_read_file_result (ACE_Handler &handler, 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. More...

virtual ACE_Asynch_Write_File_Result_Implcreate_asynch_write_file_result (ACE_Handler &handler, 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. More...

virtual ACE_Asynch_Read_Dgram_Result_Implcreate_asynch_read_dgram_result (ACE_Handler &handler, 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. More...

virtual ACE_Asynch_Write_Dgram_Result_Implcreate_asynch_write_dgram_result (ACE_Handler &handler, 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. More...

virtual ACE_Asynch_Accept_Result_Implcreate_asynch_accept_result (ACE_Handler &handler, 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. More...

virtual ACE_Asynch_Connect_Result_Implcreate_asynch_connect_result (ACE_Handler &handler, 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. More...

virtual ACE_Asynch_Transmit_File_Result_Implcreate_asynch_transmit_file_result (ACE_Handler &handler, 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. More...

virtual ACE_Asynch_Result_Implcreate_asynch_timer (ACE_Handler &handler, const void *act, const ACE_Time_Value &tv, ACE_HANDLE event, int priority, int signal_number=0)
 Create a timer result object which can be used with the Timer mechanism of the Proactor. More...


Protected Methods

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

virtual int handle_signal (int signum, siginfo_t *=0, ucontext_t *=0)
 Called when object is signaled by OS (either via UNIX signals or when a Win32 object becomes signaled). More...

virtual int handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask)
 Called when object is removed from the ACE_Reactor. More...

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)
 Protect against structured exceptions caused by user code when dispatching handles. More...

virtual int post_wakeup_completions (int how_many)

Protected Attributes

ACE_HANDLE completion_port_
 Handle for the completion port. Unix doesnt have completion ports. More...

DWORD number_of_threads_
 This number is passed to the <CreatIOCompletionPort> system call. More...

ACE_Auto_Event event_
 This event is used in conjunction with Reactor when we try to integrate the event loops of Reactor and the Proactor. More...

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

ACE_Handler wakeup_handler_
 Handler to handle the wakeups. This works in conjunction with the <ACE_Proactor::run_event_loop>. More...

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


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 50 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 42 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.

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

ACE_WIN32_Proactor::~ACE_WIN32_Proactor void    [virtual]
 

Virtual destruction.

Definition at line 62 of file WIN32_Proactor.cpp.

References close, get_asynch_pseudo_task, and ACE_Asynch_Pseudo_Task::stop.

00063 {
00064   this->get_asynch_pseudo_task ().stop ();
00065 
00066   this->close ();
00067 }


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 637 of file WIN32_Proactor.cpp.

References ACE_SEH_FINALLY, ACE_SEH_TRY, and ACE_Asynch_Result_Impl::complete.

Referenced by handle_events.

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

int ACE_WIN32_Proactor::close void    [virtual]
 

Close the IO completion port.

Implements ACE_Proactor_Impl.

Definition at line 76 of file WIN32_Proactor.cpp.

References ACE_OVERLAPPED, ACE_OS::close, and completion_port_.

Referenced by handle_close, and ~ACE_WIN32_Proactor.

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

int ACE_WIN32_Proactor::close_dispatch_threads int    wait [virtual]
 

Close all dispatch threads.

Implements ACE_Proactor_Impl.

Definition at line 737 of file WIN32_Proactor.cpp.

00738 {
00739   return 0;
00740 }

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 213 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00214 {
00215   ACE_Asynch_Accept_Impl *implementation = 0;
00216   ACE_NEW_RETURN (implementation,
00217                   ACE_WIN32_Asynch_Accept (this),
00218                   0);
00219   return implementation;
00220 }

ACE_Asynch_Accept_Result_Impl * ACE_WIN32_Proactor::create_asynch_accept_result ACE_Handler   handler,
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 401 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Event_Handler::priority.

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

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 223 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00224 {
00225   ACE_Asynch_Connect_Impl *implementation = 0;
00226   ACE_NEW_RETURN (implementation,
00227                   ACE_WIN32_Asynch_Connect (this),
00228                   0);
00229   return implementation;
00230 }

ACE_Asynch_Connect_Result_Impl * ACE_WIN32_Proactor::create_asynch_connect_result ACE_Handler   handler,
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 427 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Event_Handler::priority.

00433 {
00434   ACE_Asynch_Connect_Result_Impl *implementation = 0;
00435   ACE_NEW_RETURN (implementation,
00436                   ACE_WIN32_Asynch_Connect_Result (handler,
00437                                                    connect_handle,
00438                                                    act,
00439                                                    event,
00440                                                    priority,
00441                                                    signal_number),
00442                   0);
00443   return implementation;
00444 }

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 173 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00174 {
00175   ACE_Asynch_Read_Dgram_Impl *implementation = 0;
00176   ACE_NEW_RETURN (implementation,
00177                   ACE_WIN32_Asynch_Read_Dgram (this),
00178                   0);
00179   return implementation;
00180 }

ACE_Asynch_Read_Dgram_Result_Impl * ACE_WIN32_Proactor::create_asynch_read_dgram_result ACE_Handler   handler,
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_Event_Handler::priority.

00357 {
00358   ACE_Asynch_Read_Dgram_Result_Impl *implementation = 0;
00359   ACE_NEW_RETURN (implementation,
00360                   ACE_WIN32_Asynch_Read_Dgram_Result (handler,
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 193 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00194 {
00195   ACE_Asynch_Read_File_Impl *implementation = 0;
00196   ACE_NEW_RETURN (implementation,
00197                   ACE_WIN32_Asynch_Read_File (this),
00198                   0);
00199   return  implementation;
00200 }

ACE_Asynch_Read_File_Result_Impl * ACE_WIN32_Proactor::create_asynch_read_file_result ACE_Handler   handler,
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 291 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Event_Handler::priority.

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

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 153 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00154 {
00155   ACE_Asynch_Read_Stream_Impl *implementation = 0;
00156   ACE_NEW_RETURN (implementation,
00157                   ACE_WIN32_Asynch_Read_Stream (this),
00158                   0);
00159   return implementation;
00160 }

ACE_Asynch_Read_Stream_Result_Impl * ACE_WIN32_Proactor::create_asynch_read_stream_result ACE_Handler   handler,
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 243 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Event_Handler::priority.

00251 {
00252   ACE_Asynch_Read_Stream_Result_Impl *implementation = 0;
00253   ACE_NEW_RETURN (implementation,
00254                   ACE_WIN32_Asynch_Read_Stream_Result (handler,
00255                                                        handle,
00256                                                        message_block,
00257                                                        bytes_to_read,
00258                                                        act,
00259                                                        event,
00260                                                        priority,
00261                                                        signal_number),
00262                   0);
00263   return implementation;
00264 }

ACE_Asynch_Result_Impl * ACE_WIN32_Proactor::create_asynch_timer ACE_Handler   handler,
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 481 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Event_Handler::priority.

00487 {
00488   ACE_Asynch_Result_Impl *implementation = 0;
00489   ACE_NEW_RETURN (implementation,
00490                   ACE_WIN32_Asynch_Timer (handler,
00491                                           act,
00492                                           tv,
00493                                           event,
00494                                           priority,
00495                                           signal_number),
00496                   0);
00497   return implementation;
00498 }

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 233 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00234 {
00235   ACE_Asynch_Transmit_File_Impl *implementation = 0;
00236   ACE_NEW_RETURN (implementation,
00237                   ACE_WIN32_Asynch_Transmit_File (this),
00238                   0);
00239   return  implementation;
00240 }

ACE_Asynch_Transmit_File_Result_Impl * ACE_WIN32_Proactor::create_asynch_transmit_file_result ACE_Handler   handler,
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 447 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Event_Handler::priority.

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

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 183 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00184 {
00185   ACE_Asynch_Write_Dgram_Impl *implementation = 0;
00186   ACE_NEW_RETURN (implementation,
00187                   ACE_WIN32_Asynch_Write_Dgram (this),
00188                   0);
00189   return implementation;
00190 }

ACE_Asynch_Write_Dgram_Result_Impl * ACE_WIN32_Proactor::create_asynch_write_dgram_result ACE_Handler   handler,
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 375 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Event_Handler::priority.

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

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 203 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00204 {
00205   ACE_Asynch_Write_File_Impl *implementation = 0;
00206   ACE_NEW_RETURN (implementation,
00207                   ACE_WIN32_Asynch_Write_File (this),
00208                   0);
00209   return  implementation;
00210 }

ACE_Asynch_Write_File_Result_Impl * ACE_WIN32_Proactor::create_asynch_write_file_result ACE_Handler   handler,
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 319 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Event_Handler::priority.

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

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 163 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN.

00164 {
00165   ACE_Asynch_Write_Stream_Impl *implementation = 0;
00166   ACE_NEW_RETURN (implementation,
00167                   ACE_WIN32_Asynch_Write_Stream (this),
00168                   0);
00169   return implementation;
00170 }

ACE_Asynch_Write_Stream_Result_Impl * ACE_WIN32_Proactor::create_asynch_write_stream_result ACE_Handler   handler,
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 267 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, and ACE_Event_Handler::priority.

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

ACE_Asynch_Pseudo_Task & ACE_WIN32_Proactor::get_asynch_pseudo_task void    [protected]
 

Task to process pseudo-asynchronous operations.

Definition at line 70 of file WIN32_Proactor.cpp.

References pseudo_task_.

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, and ~ACE_WIN32_Proactor.

00071 {
00072   return this->pseudo_task_;
00073 }

ACE_HANDLE ACE_WIN32_Proactor::get_handle void    const [virtual]
 

Get the event handle.

Implements ACE_Proactor_Impl.

Definition at line 534 of file WIN32_Proactor.cpp.

References event_, ACE_Event::handle, and used_with_reactor_event_loop_.

Referenced by post_completion.

00535 {
00536   if (this->used_with_reactor_event_loop_)
00537     return this->event_.handle ();
00538   else
00539     return 0;
00540 }

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 524 of file WIN32_Proactor.cpp.

References ACE_Reactor_Mask, and close.

00526 {
00527   ACE_UNUSED_ARG (close_mask);
00528   ACE_UNUSED_ARG (handle);
00529 
00530   return this->close ();
00531 }

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 557 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.

00558 {
00559   ACE_OVERLAPPED *overlapped = 0;
00560   u_long bytes_transferred = 0;
00561 #if defined (ACE_WIN64)
00562           ULONG_PTR completion_key = 0;
00563 #else
00564           ULONG completion_key = 0;
00565 #endif /* ACE_WIN64 */
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                                        ACE_static_cast (size_t,
00629                                                         bytes_transferred),
00630                                        (void *) completion_key,
00631                                        result_err);
00632     }
00633   return 1;
00634 }

int ACE_WIN32_Proactor::handle_events void    [virtual]
 

Block indefinitely until at least one event is dispatched. 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 551 of file WIN32_Proactor.cpp.

References ACE_INFINITE.

Referenced by handle_events, and handle_signal.

00552 {
00553   return this->handle_events (ACE_INFINITE);
00554 }

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 543 of file WIN32_Proactor.cpp.

References handle_events, and ACE_Time_Value::msec.

00544 {
00545   // Decrement <wait_time> with the amount of time spent in the method
00546   ACE_Countdown_Time countdown (&wait_time);
00547   return this->handle_events (wait_time.msec ());
00548 }

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 501 of file WIN32_Proactor.cpp.

References handle_events, and ucontext_t.

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

void ACE_WIN32_Proactor::number_of_threads size_t    threads [virtual]
 

Set number of thread used as a parameter to CreatIoCompletionPort.

Implements ACE_Proactor_Impl.

Definition at line 749 of file WIN32_Proactor.cpp.

References number_of_threads_.

00750 {
00751   this->number_of_threads_ = ACE_static_cast (DWORD, threads);
00752 }

size_t ACE_WIN32_Proactor::number_of_threads void    const [virtual]
 

Get number of thread used as a parameter to CreatIoCompletionPort.

Implements ACE_Proactor_Impl.

Definition at line 743 of file WIN32_Proactor.cpp.

00744 {
00745   return ACE_static_cast (size_t, this->number_of_threads_);
00746 }

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 658 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.

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

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 713 of file WIN32_Proactor.cpp.

References ACE_NEW_RETURN, ACE_WIN32_Asynch_Result::post_completion, and ssize_t.

00714 {
00715   ACE_WIN32_Wakeup_Completion *wakeup_completion = 0;
00716 
00717   for (ssize_t ci = 0; ci < how_many; ci++)
00718     {
00719       ACE_NEW_RETURN (wakeup_completion,
00720                       ACE_WIN32_Wakeup_Completion (this->wakeup_handler_),
00721                       -1);
00722 
00723       if (wakeup_completion->post_completion (this) == -1)
00724         return -1;
00725     }
00726 
00727   return 0;
00728 }

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 119 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.

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

int ACE_WIN32_Proactor::wake_up_dispatch_threads void    [virtual]
 

Add wakeup dispatch threads (reinit).

Implements ACE_Proactor_Impl.

Definition at line 731 of file WIN32_Proactor.cpp.

00732 {
00733   return 0;
00734 }


Friends And Related Function Documentation

friend class ACE_WIN32_Asynch_Connect [friend]
 

Definition at line 52 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 264 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]
 

This event is used in conjunction with Reactor when we try to integrate the event loops of Reactor and the Proactor.

Definition at line 272 of file WIN32_Proactor.h.

Referenced by get_handle.

DWORD ACE_WIN32_Proactor::number_of_threads_ [protected]
 

This number is passed to the <CreatIOCompletionPort> system call.

Definition at line 268 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 284 of file WIN32_Proactor.h.

Referenced by get_asynch_pseudo_task.

int ACE_WIN32_Proactor::used_with_reactor_event_loop_ [protected]
 

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

Definition at line 276 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 280 of file WIN32_Proactor.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 13:01:06 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002