diff options
author | alex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-06-20 05:11:11 +0000 |
---|---|---|
committer | alex <alex@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2000-06-20 05:11:11 +0000 |
commit | 3157499252e71eefd7e850779d6b611cbf3312b7 (patch) | |
tree | e9b7d240145a26b9d41e013a3b628fcb77c0dd96 | |
parent | 26c64d921c76a4833a698b147bdb34c84b8a8900 (diff) | |
download | ATCD-3157499252e71eefd7e850779d6b611cbf3312b7.tar.gz |
Incorporated Alex Libman <Alibman@baltimore.com> suggestions.
- MT safe'ing AIOCB proactor. It does not improve efficiency though.
- Enabling the completion call backs even if aio_return fails. We will
call the completion call back methods with 0 transferred data
parameter.
Thanks Alex for the great inputs!.
-rw-r--r-- | ace/POSIX_Asynch_IO.cpp | 78 | ||||
-rw-r--r-- | ace/POSIX_Asynch_IO.h | 162 | ||||
-rw-r--r-- | ace/POSIX_Proactor.cpp | 76 | ||||
-rw-r--r-- | ace/POSIX_Proactor.h | 50 |
4 files changed, 183 insertions, 183 deletions
diff --git a/ace/POSIX_Asynch_IO.cpp b/ace/POSIX_Asynch_IO.cpp index b59f840236e..b86dfd7f1af 100644 --- a/ace/POSIX_Asynch_IO.cpp +++ b/ace/POSIX_Asynch_IO.cpp @@ -170,18 +170,18 @@ int ACE_POSIX_Asynch_Operation::cancel (void) { int result = ::aio_cancel (this->handle_, 0); - + if (result == -1) return -1; - - // Check the return value and return 0/1/2 appropriately. + + // Check the return value and return 0/1/2 appropriately. if (result == AIO_CANCELED) return 0; else if (result == AIO_ALLDONE) return 1; else if (result == AIO_NOTCANCELED) return 2; - else + else ACE_ERROR_RETURN ((LM_ERROR, "(%P | %t):%p\n" "ACE_POSIX_Asynch_Operation::cancel: " @@ -321,7 +321,7 @@ ACE_POSIX_Asynch_Read_Stream_Result::~ACE_POSIX_Asynch_Read_Stream_Result (void) } // = Base class operations. These operations are here to kill -// dominance warnings. These methods call the base class methods. +// dominance warnings. These methods call the base class methods. u_long ACE_POSIX_Asynch_Read_Stream_Result::bytes_transferred (void) const @@ -529,9 +529,9 @@ ACE_POSIX_SIG_Asynch_Read_Stream::shared_read (ACE_POSIX_Asynch_Read_Stream_Resu // We want queuing of RT signal to notify completion. result->aio_sigevent.sigev_notify = SIGEV_SIGNAL; result->aio_sigevent.sigev_signo = result->signal_number (); - + // Keep ACE_POSIX_Asynch_Result, the base class pointer in the - // signal value. + // signal value. ACE_POSIX_Asynch_Result *base_result = result; result->aio_sigevent.sigev_value.sival_ptr = ACE_reinterpret_cast (void *, base_result); @@ -756,7 +756,7 @@ ACE_POSIX_AIOCB_Asynch_Write_Stream::shared_write (ACE_POSIX_Asynch_Write_Stream { // Setup AIOCB. result->aio_sigevent.sigev_notify = SIGEV_NONE; - + // Issure write. 1 means write. if (this->register_aio_with_proactor (result, 1) == -1) { @@ -848,7 +848,7 @@ ACE_POSIX_SIG_Asynch_Write_Stream::shared_write (ACE_POSIX_Asynch_Write_Stream_R result->aio_sigevent.sigev_signo = result->signal_number (); // Keep ACE_POSIX_Asynch_Result, the base class pointer in the - // signal value. + // signal value. ACE_POSIX_Asynch_Result *base_result = result; result->aio_sigevent.sigev_value.sival_ptr = ACE_reinterpret_cast (void *, base_result); @@ -1016,7 +1016,7 @@ ACE_POSIX_Asynch_Read_File_Result::signal_number (void) const // The following methods belong to // ACE_POSIX_Asynch_Read_Stream_Result. They are here to avoid -// dominace warnings. These methods route their call to the +// dominace warnings. These methods route their call to the // ACE_POSIX_Asynch_Read_Stream_Result base class. u_long @@ -1080,7 +1080,7 @@ ACE_POSIX_AIOCB_Asynch_Read_File::read (ACE_Message_Block &message_block, if (return_val == -1) delete result; - + return return_val; } @@ -1164,10 +1164,10 @@ ACE_POSIX_SIG_Asynch_Read_File::read (ACE_Message_Block &message_block, -1); ssize_t return_val = this->shared_read (result); - + if (return_val == -1) delete result; - + return return_val; } @@ -1332,17 +1332,17 @@ int ACE_POSIX_Asynch_Write_File_Result::priority (void) const { return ACE_POSIX_Asynch_Result::priority (); -} +} int ACE_POSIX_Asynch_Write_File_Result::signal_number (void) const { return ACE_POSIX_Asynch_Result::signal_number (); -} +} // The following methods belong to // ACE_POSIX_Asynch_Write_Stream_Result. They are here to avoid -// dominance warnings. These methods route their call to the +// dominance warnings. These methods route their call to the // ACE_POSIX_Asynch_Write_Stream_Result base class. u_long @@ -1403,10 +1403,10 @@ ACE_POSIX_AIOCB_Asynch_Write_File::write (ACE_Message_Block &message_block, -1); ssize_t return_val = this->shared_write (result); - + if (return_val == -1) delete result; - + return return_val; } @@ -1493,7 +1493,7 @@ ACE_POSIX_SIG_Asynch_Write_File::write (ACE_Message_Block &message_block, if (return_val == -1) delete result; - + return return_val; } @@ -1706,7 +1706,7 @@ protected: // Constructor. Give the reactor so that it can activate/deactivate // the handlers. Give also the proactor used here, so that the // handler can send the <POSIX_Asynch_Accept> result block through - // <post_completion>. + // <post_completion>. int register_accept_call_i (ACE_POSIX_Asynch_Accept_Result* result); // Worker method for registering this <accept> call with the local @@ -1724,7 +1724,7 @@ protected: ACE_POSIX_Proactor *posix_proactor_; // POSIX_Proactor. - + ACE_Unbounded_Queue<ACE_POSIX_Asynch_Accept_Result*> result_queue_; // Queue of Result pointers that correspond to all the <accept>'s // pending. @@ -1752,11 +1752,11 @@ public: // Constructor. Give the reactor so that it can activate/deactivate // the handlers. Give also the proactor used here, so that the // handler can send information through the notification pipe - // (<post_completion>). + // (<post_completion>). ~ACE_POSIX_AIOCB_Asynch_Accept_Handler (void); // Destructor. - + int register_accept_call (ACE_POSIX_Asynch_Accept_Result* result); // Register this <accept> call with the local handler. @@ -1825,7 +1825,7 @@ ACE_POSIX_Asynch_Accept_Handler::register_accept_call_i (ACE_POSIX_Asynch_Accept "Reactor::resume_handler failed\n"), -1); } - + return 0; } @@ -1860,7 +1860,7 @@ ACE_POSIX_Asynch_Accept_Handler::deregister_accept_call (void) "%N:%l:(%P | %t):%p\n", "ACE_POSIX_Asynch_Accept_Handler::" "deregister_accept_call:suspend handler failed"), - 0); + 0); } // Return the result pointer. @@ -1930,7 +1930,7 @@ ACE_POSIX_AIOCB_Asynch_Accept_Handler::handle_input (ACE_HANDLE /* fd */) "ACE_POSIX_AIOCB_Asynch_Accept_Handler::" "handle_input:<post_completion> failed"), -1); - + return 0; } @@ -1953,11 +1953,11 @@ ACE_POSIX_SIG_Asynch_Accept_Handler::register_accept_call (ACE_POSIX_Asynch_Acce // and thru the auxillary thread in the deregister fun. So let us // mutex it. ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->lock_, -1); - + // Do the work. if (this->register_accept_call_i (result) == -1) return -1; - + return 0; } @@ -1967,7 +1967,7 @@ ACE_POSIX_SIG_Asynch_Accept_Handler::handle_input (ACE_HANDLE /* fd */) // An <accept> has been sensed on the <listen_handle>. We should be // able to just go ahead and do the <accept> now on this <fd>. This // should be the same as the <listen_handle>. - + // Deregister this info pertaining to this <accept> call. ACE_POSIX_Asynch_Accept_Result* result = this->deregister_accept_call (); if (result == 0) @@ -1976,7 +1976,7 @@ ACE_POSIX_SIG_Asynch_Accept_Handler::handle_input (ACE_HANDLE /* fd */) "ACE_POSIX_SIG_Asynch_Accept_Handler::" "handle_input:deregister_accept_call failed"), -1); - + // Issue <accept> now. // @@ We shouldnt block here since we have already done poll/select // thru reactor. But are we sure? @@ -1989,7 +1989,7 @@ ACE_POSIX_SIG_Asynch_Accept_Handler::handle_input (ACE_HANDLE /* fd */) -1); // Accept has completed. - + // Store the new handle. result->aio_fildes = new_handle; @@ -2000,7 +2000,7 @@ ACE_POSIX_SIG_Asynch_Accept_Handler::handle_input (ACE_HANDLE /* fd */) "ACE_POSIX_SIG_Asynch_Accept_Handler::" "handle_input:<post_completion> failed"), -1); - + return 0; } @@ -2049,7 +2049,7 @@ ACE_POSIX_AIOCB_Asynch_Accept::accept (ACE_Message_Block &message_block, // Register this <accept> call with the local handler. if (this->accept_handler_->register_accept_call (result) == -1) return -1; - + return 0; } @@ -2262,11 +2262,11 @@ ACE_POSIX_SIG_Asynch_Accept::thread_function (void* arg_reactor) // For this reactor, this thread is the owner. reactor->owner (ACE_OS::thr_self ()); - // Handle events. Wait for any connection events. + // Handle events. Wait for any connection events. int result = 0; while (result != -1) result = reactor->handle_events (); - + return 0; } @@ -2693,7 +2693,7 @@ ACE_POSIX_AIOCB_Asynch_Transmit_Handler::handle_write_stream (const ACE_Asynch_W // Failure. ACE_ERROR ((LM_ERROR, "Asynch_Transmit_File failed.\n")); - + ACE_SEH_TRY { this->result_->complete (this->bytes_transferred_, @@ -2708,7 +2708,7 @@ ACE_POSIX_AIOCB_Asynch_Transmit_Handler::handle_write_stream (const ACE_Asynch_W delete this; } } - + // Write stream successful. // Partial write to socket. @@ -3209,7 +3209,7 @@ ACE_Proactor * ACE_POSIX_AIOCB_Asynch_Transmit_File::proactor (void) const { return ACE_POSIX_Asynch_Operation::proactor (); -} +} // ********************************************************************* @@ -3322,7 +3322,7 @@ ACE_Proactor * ACE_POSIX_SIG_Asynch_Transmit_File::proactor (void) const { return ACE_POSIX_Asynch_Operation::proactor (); -} +} #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION) template class ACE_Unbounded_Queue<ACE_POSIX_Asynch_Accept_Result *>; diff --git a/ace/POSIX_Asynch_IO.h b/ace/POSIX_Asynch_IO.h index e102afc3e59..faf1ba2ae27 100644 --- a/ace/POSIX_Asynch_IO.h +++ b/ace/POSIX_Asynch_IO.h @@ -91,9 +91,9 @@ public: int signal_number (void) const; // POSIX4 real-time signal number to be used for the - // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By + // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By // default, SIGRTMIN is used to issue <aio_> calls. - + int post_completion (ACE_Proactor_Impl *proactor); // Post <this> to the Proactor. @@ -212,7 +212,7 @@ protected: // with the Proactor. // When Op is 0, read operation is started. 1 starts write // operation. Thanks to Alex Libman <alibman@baltimore.com> for - // suggesting this. + // suggesting this. ACE_POSIX_AIOCB_Proactor *posix_aiocb_proactor_; // It is easy to get this specific implementation proactor here, @@ -262,7 +262,7 @@ class ACE_Export ACE_POSIX_Asynch_Read_Stream_Result : public virtual ACE_Asynch friend class ACE_POSIX_AIOCB_Asynch_Read_Stream; friend class ACE_POSIX_SIG_Asynch_Read_Stream; // Factory classes willl have special permissions. - + friend class ACE_POSIX_Proactor; // The Proactor constructs the Result class for faking results. @@ -276,7 +276,7 @@ public: ACE_HANDLE handle (void) const; // I/O handle used for reading. - + // = Base class operations. These operations are here to kill // dominance warnings. These methods call the base class methods. @@ -315,7 +315,7 @@ public: int signal_number (void) const; // POSIX4 real-time signal number to be used for the - // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By + // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By // default, SIGRTMIN is used to issue <aio_> calls. This is a no-op // on non-POSIX4 systems and returns 0. @@ -333,7 +333,7 @@ protected: int signal_number); // Constructor is protected since creation is limited to // ACE_Asynch_Read_Stream factory. - + virtual void complete (u_long bytes_transferred, int success, const void *completion_key, @@ -379,10 +379,10 @@ public: virtual ~ACE_POSIX_AIOCB_Asynch_Read_Stream (void); // Destructor. - - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int open (ACE_Handler &handler, ACE_HANDLE handle, @@ -396,7 +396,7 @@ public: int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. @@ -432,9 +432,9 @@ public: virtual ~ACE_POSIX_SIG_Asynch_Read_Stream (void); // Destructor. - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int open (ACE_Handler &handler, ACE_HANDLE handle, @@ -448,7 +448,7 @@ public: int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. @@ -489,9 +489,9 @@ public: ACE_HANDLE handle (void) const; // I/O handle used for writing. - + // = Base class operations. These operations are here to kill - // dominance warnings. These methods call the base class methods. + // dominance warnings. These methods call the base class methods. u_long bytes_transferred (void) const; // Number of bytes transferred by the operation. @@ -528,7 +528,7 @@ public: int signal_number (void) const; // POSIX4 real-time signal number to be used for the - // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By + // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By // default, SIGRTMIN is used to issue <aio_> calls. This is a no-op // on non-POSIX4 systems and returns 0. @@ -594,9 +594,9 @@ public: virtual ~ACE_POSIX_AIOCB_Asynch_Write_Stream (void); // Destrcutor. - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int open (ACE_Handler &handler, ACE_HANDLE handle, @@ -610,7 +610,7 @@ public: int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. @@ -645,9 +645,9 @@ public: virtual ~ACE_POSIX_SIG_Asynch_Write_Stream (void); // Destructor. - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int open (ACE_Handler &handler, ACE_HANDLE handle, @@ -661,7 +661,7 @@ public: int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. @@ -729,12 +729,12 @@ public: int signal_number (void) const; // POSIX4 real-time signal number to be used for the - // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By + // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By // default, SIGRTMIN is used to issue <aio_> calls. This is a no-op // on non-POSIX4 systems and returns 0. - + // = The following methods belong to - // ACE_POSIX_Asynch_Read_Stream_Result. They are here to avoid + // ACE_POSIX_Asynch_Read_Stream_Result. They are here to avoid // dominance warnings. These methods route their call to the // ACE_POSIX_Asynch_Read_Stream_Result base class. @@ -813,11 +813,11 @@ public: virtual ~ACE_POSIX_AIOCB_Asynch_Read_File (void); // Destructor. - - - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + + + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int open (ACE_Handler &handler, ACE_HANDLE handle, @@ -831,7 +831,7 @@ public: int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. @@ -882,9 +882,9 @@ public: virtual ~ACE_POSIX_SIG_Asynch_Read_File (void); // Destructor. - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int open (ACE_Handler &handler, ACE_HANDLE handle, @@ -898,7 +898,7 @@ public: int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. @@ -966,7 +966,7 @@ public: ACE_HANDLE event (void) const; // This returns ACE_INVALID_HANDLE on POSIX4 platforms. - + u_long offset (void) const; u_long offset_high (void) const; // This really make sense only when doing file I/O. @@ -974,20 +974,20 @@ public: // @@ On POSIX4-Unix, offset_high should be supported using // aiocb64. // - + int priority (void) const; // The priority of the asynchronous operation. int signal_number (void) const; // POSIX4 real-time signal number to be used for the - // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By + // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By // default, SIGRTMIN is used to issue <aio_> calls. This is a no-op // on non-POSIX4 systems and returns 0. - + // = The following methods belong to // ACE_POSIX_Asynch_Write_Stream_Result. They are here to avoid - // dominace warnings. These methods route their call to the - // ACE_POSIX_Asynch_Write_Stream_Result base class. + // dominace warnings. These methods route their call to the + // ACE_POSIX_Asynch_Write_Stream_Result base class. u_long bytes_to_write (void) const; // The number of bytes which were requested at the start of the @@ -1001,7 +1001,7 @@ public: int post_completion (ACE_Proactor_Impl *proactor); // Post <this> to the Proactor. - + protected: ACE_POSIX_Asynch_Write_File_Result (ACE_Handler &handler, ACE_HANDLE handle, @@ -1055,10 +1055,10 @@ public: virtual ~ACE_POSIX_AIOCB_Asynch_Write_File (void); // Destructor. - - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int open (ACE_Handler &handler, ACE_HANDLE handle, @@ -1072,7 +1072,7 @@ public: int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. @@ -1124,9 +1124,9 @@ public: virtual ~ACE_POSIX_SIG_Asynch_Write_File (void); // Destrcutor. - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int open (ACE_Handler &handler, ACE_HANDLE handle, @@ -1140,7 +1140,7 @@ public: int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. @@ -1225,14 +1225,14 @@ public: // int priority (void) const; - // The priority of the asynchronous operation. + // The priority of the asynchronous operation. int signal_number (void) const; // POSIX4 real-time signal number to be used for the - // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By + // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By // default, SIGRTMIN is used to issue <aio_> calls. This is a no-op // on non-POSIX4 systems and returns 0. - + int post_completion (ACE_Proactor_Impl *proactor); // Post <this> to the Proactor. @@ -1310,17 +1310,17 @@ public: virtual ~ACE_POSIX_AIOCB_Asynch_Accept (void); // Destructor. - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. - + private: static void* thread_function (void* reactor); // The thread function that does handle events. @@ -1376,15 +1376,15 @@ public: virtual ~ACE_POSIX_SIG_Asynch_Accept (void); // Destructor. - - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route + + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route // the call to the ACE_POSIX_Asynch_Operation base class. - + int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. @@ -1484,10 +1484,10 @@ public: int signal_number (void) const; // POSIX4 real-time signal number to be used for the - // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By + // operation. <signal_number> ranges from SIGRTMIN to SIGRTMAX. By // default, SIGRTMIN is used to issue <aio_> calls. This is a no-op // on non-POSIX4 systems and returns 0. - + int post_completion (ACE_Proactor_Impl *proactor); // Post <this> to the Proactor. @@ -1570,10 +1570,10 @@ public: virtual ~ACE_POSIX_AIOCB_Asynch_Transmit_File (void); // Destructor. - - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int open (ACE_Handler &handler, ACE_HANDLE handle, @@ -1587,7 +1587,7 @@ public: int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. }; @@ -1627,10 +1627,10 @@ public: virtual ~ACE_POSIX_SIG_Asynch_Transmit_File (void); // Destructor. - - // = Methods belong to ACE_POSIX_Asynch_Operation base class. These - // methods are defined here to avoid dominace warnings. They route - // the call to the ACE_POSIX_Asynch_Operation base class. + + // = Methods belong to ACE_POSIX_Asynch_Operation base class. These + // methods are defined here to avoid dominace warnings. They route + // the call to the ACE_POSIX_Asynch_Operation base class. int open (ACE_Handler &handler, ACE_HANDLE handle, @@ -1644,7 +1644,7 @@ public: int cancel (void); // // @@ Not implemented. Returns 0. - + ACE_Proactor* proactor (void) const; // Return the underlying proactor. }; diff --git a/ace/POSIX_Proactor.cpp b/ace/POSIX_Proactor.cpp index 01d10f8f3fe..77220da3abd 100644 --- a/ace/POSIX_Proactor.cpp +++ b/ace/POSIX_Proactor.cpp @@ -15,14 +15,14 @@ class ACE_Export ACE_POSIX_Wakeup_Completion : public ACE_POSIX_Asynch_Result { // = TITLE - // - // This is result object is used by the <end_event_loop> of the + // + // This is result object is used by the <end_event_loop> of the // ACE_Proactor interface to wake up all the threads blocking // for completions. - // + // // = DESCRIPTION - // - + // + public: ACE_POSIX_Wakeup_Completion (ACE_Handler &handler, const void *act = 0, @@ -30,11 +30,11 @@ public: int priority = 0, int signal_number = ACE_SIGRTMIN); // Constructor. - + virtual ~ACE_POSIX_Wakeup_Completion (void); // Destructor. - - + + virtual void complete (u_long bytes_transferred = 0, int success = 1, const void *completion_key = 0, @@ -348,13 +348,13 @@ ACE_POSIX_Proactor::post_wakeup_completions (int how_many) ACE_NEW_RETURN (wakeup_completion, ACE_POSIX_Wakeup_Completion (this->wakeup_handler_), -1); - + if (wakeup_completion->post_completion (this) == -1) return -1; } - + return 0; -} +} class ACE_Export ACE_AIOCB_Notify_Pipe_Manager : public ACE_Handler { @@ -642,11 +642,11 @@ ACE_POSIX_AIOCB_Proactor::handle_events (unsigned long milli_seconds) "%N:%l:(%P | %t)::%p\n", "ACE_POSIX_AIOCB_Proactor::handle_events:" "aio_suspend failed")); - + return 0; } } - + // Retrive the result pointer. ACE_POSIX_Asynch_Result *asynch_result = 0; size_t ai; @@ -656,15 +656,15 @@ ACE_POSIX_AIOCB_Proactor::handle_events (unsigned long milli_seconds) // !!! Protected area. { ACE_Guard<ACE_Thread_Mutex> locker (this->mtx_AIOCB_); - + for (ai = 0; ai < this->aiocb_list_max_size_; ai++) { // Dont process null blocks. if (aiocb_list_ [ai] == 0) continue; - + // = Analyze error and return values. - + // Get the error status of the aio_ operation. error_status = aio_error (aiocb_list_[ai]); if (error_status == -1) @@ -674,11 +674,11 @@ ACE_POSIX_AIOCB_Proactor::handle_events (unsigned long milli_seconds) "ACE_POSIX_AIOCB_Proactor::handle_events:" "<aio_error> has failed"), -1); - - // Continue the loop if <aio_> operation is still in progress. + + // Continue the loop if <aio_> operation is still in progress. if (error_status == EINPROGRESS) continue; - + // Handle cancel'ed asynchronous operation. We dont have to call // <aio_return> in this case, since return_status is going to be // -1. We will pass 0 for the <bytes_transferred> in this case @@ -693,45 +693,45 @@ ACE_POSIX_AIOCB_Proactor::handle_events (unsigned long milli_seconds) // operation has finished (successfully or unsuccessfully!!!) // Get the return_status of the <aio_> operation. return_status = aio_return (aiocb_list_[ai]); - + if (return_status == -1) { ACE_DEBUG ((LM_ERROR, "%N:%l:(%P | %t)::%p\n", "ACE_POSIX_AIOCB_Proactor::handle_events:" "<aio_return> failed to transfer any data\n")); - + return_status = 0; } - + break; } } - + // Something should have completed. ACE_ASSERT (ai != this->aiocb_list_max_size_); - + // Retrive the result pointer. asynch_result = this->result_list_ [ai]; - + // ACE_reinterpret_cast (ACE_POSIX_Asynch_Result *, // this->aiocb_list_[ai]); // ACE_dynamic_cast (ACE_POSIX_Asynch_Result *, // this->aiocb_list_[ai]); - + // Invalidate entry in the aiocb list. this->aiocb_list_[ai] = 0; this->result_list_ [ai] = 0; this->aiocb_list_cur_size_--; } // !! End of protected area. - + // Call the application code. this->application_specific_code (asynch_result, return_status, // Bytes transferred. 1, // Success 0, // No completion key. error_status); // Error - + // Success return 1; } @@ -756,8 +756,8 @@ ACE_POSIX_AIOCB_Proactor::register_aio_with_proactor (ACE_POSIX_Asynch_Result *r ACE_TRACE ("ACE_POSIX_AIOCB_Proactor::register_aio_with_proactor"); // Protect the atomic action , which is: find free slot , start IO , - // save ptr in the lists - + // save ptr in the lists + ACE_Guard<ACE_Thread_Mutex> locker (this->mtx_AIOCB_); if (result == 0) @@ -805,7 +805,7 @@ ACE_POSIX_AIOCB_Proactor::register_aio_with_proactor (ACE_POSIX_Asynch_Result *r -1); } } - else + else { // write if (aio_write (result) == -1) @@ -816,9 +816,9 @@ ACE_POSIX_AIOCB_Proactor::register_aio_with_proactor (ACE_POSIX_Asynch_Result *r -1); } } - + // Store the pointers. - this->aiocb_list_[ai] = result; + this->aiocb_list_[ai] = result; this->result_list_ [ai] = result; this->aiocb_list_cur_size_ ++; @@ -1181,10 +1181,10 @@ ACE_POSIX_SIG_Proactor::handle_events (unsigned long milli_seconds) if (sig_info.si_code == SI_ASYNCIO) { // Analyze error and return values. - + int error_status = 0; int return_status = 0; - + // Check the error status error_status = aio_error (asynch_result); @@ -1213,7 +1213,7 @@ ACE_POSIX_SIG_Proactor::handle_events (unsigned long milli_seconds) { return_status = 0; } - else + else { // Get the return_status of the <aio_> operation. return_status = aio_return (asynch_result); @@ -1229,9 +1229,9 @@ ACE_POSIX_SIG_Proactor::handle_events (unsigned long milli_seconds) return_status = 0; } } - + // error status and return status are obtained. Dispatch the - // completion . + // completion . this->application_specific_code (asynch_result, return_status, 1, // Result : True. diff --git a/ace/POSIX_Proactor.h b/ace/POSIX_Proactor.h index f83cce01695..e0cadae2417 100644 --- a/ace/POSIX_Proactor.h +++ b/ace/POSIX_Proactor.h @@ -50,7 +50,7 @@ class ACE_Export ACE_POSIX_Proactor : public ACE_Proactor_Impl friend class ACE_POSIX_SIG_Asynch_Accept_Handler; // For <POSIX_SIG_Asynch_Accept> operation, this handler class does // the actual work, has to register the real-time signal with the - // Proactor. + // Proactor. public: virtual ~ACE_POSIX_Proactor (void); @@ -62,7 +62,7 @@ public: virtual int register_handle (ACE_HANDLE handle, const void *completion_key); // This function is a no-op function for Unix systems. Returns 0. - + virtual int post_completion (ACE_POSIX_Asynch_Result *result) = 0; // Post a result to the completion port of the Proactor. If errors // occur, the result will be deleted by this method. If successful, @@ -72,14 +72,14 @@ public: // user once this method is called. int wake_up_dispatch_threads (void); - // @@ This is a no-op on POSIX platforms. Returns 0. + // @@ This is a no-op on POSIX platforms. Returns 0. int close_dispatch_threads (int wait); - // @@ This is a no-op on POSIX platforms. Returns 0. + // @@ This is a no-op on POSIX platforms. Returns 0. size_t number_of_threads (void) const; void number_of_threads (size_t threads); - // @@ This is a no-op on POSIX platforms. Returns 0. + // @@ This is a no-op on POSIX platforms. Returns 0. virtual ACE_HANDLE get_handle (void) const; // This is a no-op in POSIX. Returns ACE_INVALID_HANDLE. @@ -150,7 +150,7 @@ public: ACE_HANDLE event = ACE_INVALID_HANDLE, int priority = 0, int signal_number = ACE_SIGRTMIN); - + virtual ACE_Asynch_Result_Impl *create_asynch_timer (ACE_Handler &handler, const void *act, const ACE_Time_Value &tv, @@ -158,8 +158,8 @@ public: int priority = 0, int signal_number = ACE_SIGRTMIN); // Create a timer result object which can be used with the Timer - // mechanism of the Proactor. - + // mechanism of the Proactor. + protected: ACE_POSIX_Proactor (void); // Constructor. @@ -178,12 +178,12 @@ protected: virtual int post_wakeup_completions (int how_many); // 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>. + // <run_event_loop>. protected: ACE_Handler wakeup_handler_; // Handler to handle the wakeups. This works in conjunction with the - // <ACE_Proactor::run_event_loop>. + // <ACE_Proactor::run_event_loop>. }; // Forward declarations. @@ -202,14 +202,14 @@ class ACE_Export ACE_POSIX_AIOCB_Proactor : public ACE_POSIX_Proactor friend class ACE_AIOCB_Notify_Pipe_Manager; // Handler needs to call application specific code. - + friend class ACE_POSIX_AIOCB_Asynch_Operation; // This class does the registering of Asynch Operations with the // Proactor which is necessary in the AIOCB strategy. // friend class ACE_POSIX_AIOCB_Asynch_Accept_Handler; // For <Asynch_Accept> operation class, this helper class takes care - // of doing the <Asynch_Accept>. + // of doing the <Asynch_Accept>. public: ACE_POSIX_AIOCB_Proactor (void); @@ -229,7 +229,7 @@ public: // 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. + // set accordingly. virtual int post_completion (ACE_POSIX_Asynch_Result *result); // Post a result to the completion port of the Proactor. @@ -262,8 +262,8 @@ protected: u_long error); // We will call the base class's application_specific_code from // here. - int register_aio_with_proactor (ACE_POSIX_Asynch_Result *result, int operation); + // If the ptr is o, just check whether there is any slot free and // return 0 if yes, else return -1. If a valid ptr is passed, keep it // in a free slot. @@ -271,7 +271,7 @@ protected: ACE_AIOCB_Notify_Pipe_Manager* aiocb_notify_pipe_manager_; // This class takes care of doing <accept> when we use // AIO_CONTROL_BLOCKS strategy. - + aiocb *aiocb_list_ [ACE_RTSIG_MAX]; // Use an array to keep track of all the aio's issued // currently. We'll limit the array size to Maximum RT signals that @@ -279,7 +279,7 @@ protected: // operations can be pending at a time. ACE_POSIX_Asynch_Result *result_list_ [ACE_RTSIG_MAX]; - // @@ Keeping an extra copy of the <aiocb_list> here so that we can + // @@ Keeping an extra copy of the <aiocb_list> here so that we can // avoid dynamic cast when we use the result object calling back // the hook methods. @@ -302,7 +302,7 @@ class ACE_Export ACE_POSIX_SIG_Proactor : public ACE_POSIX_Proactor // used to get the notify/get the completions. // The real-time signals that are going to be used with this // Proactor should be given apriori in the constructor, so that - // those signals can be masked from asynchornous delivery. + // those signals can be masked from asynchornous delivery. // // = DESCRIPTION // @@ -331,7 +331,7 @@ public: // 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. + // set accordingly. virtual int handle_events (void); // Block indefinitely until at least one event is dispatched. @@ -339,7 +339,7 @@ public: // 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. - + virtual int post_completion (ACE_POSIX_Asynch_Result *result); // Post a result to the completion port of the Proactor. @@ -376,7 +376,7 @@ protected: static void null_handler (int signal_number, siginfo_t *info, void *context); // Dummy signal handler. This wont get called at all, since we are // going to be masking the signal in all the threads. - + int mask_all (void) const; // To mask all the signals in a thread. @@ -398,12 +398,12 @@ class ACE_Export ACE_POSIX_Asynch_Timer : public ACE_POSIX_Asynch_Result // This class is posted to the completion port when a timer // expires. When the <complete method> of this object is // called, the <handler>'s <handle_timeout> method will be - // called. - + // called. + friend class ACE_POSIX_Proactor; friend class ACE_POSIX_SIG_Proactor; - // The factory method for this class is with the POSIX_Proactor - // class. + // The factory method for this class is with the POSIX_Proactor + // class. protected: ACE_POSIX_Asynch_Timer (ACE_Handler &handler, @@ -413,7 +413,7 @@ protected: int priority = 0, int signal_number = ACE_SIGRTMIN); // Constructor. - + virtual ~ACE_POSIX_Asynch_Timer (void) {} // Destructor. |