Inheritance diagram for ACE_AIOCB_Notify_Pipe_Manager:


Public Methods | |
| ACE_AIOCB_Notify_Pipe_Manager (ACE_POSIX_AIOCB_Proactor *posix_aiocb_proactor) | |
| Constructor. You need the posix proactor because you need to call <application_specific_code>. More... | |
| virtual | ~ACE_AIOCB_Notify_Pipe_Manager (void) |
| Destructor. More... | |
| int | notify () |
| Send the result pointer through the notification pipe. More... | |
| virtual void | handle_read_stream (const ACE_Asynch_Read_Stream::Result &result) |
| This is the call back method when <Asynch_Read> from the pipe is complete. More... | |
Private Methods | |
| ACE_AIOCB_Notify_Pipe_Manager (void) | |
| Default constructor. Shouldnt be called. More... | |
Private Attributes | |
| ACE_POSIX_AIOCB_Proactor * | posix_aiocb_proactor_ |
| The implementation proactor class. More... | |
| ACE_Message_Block | message_block_ |
| Message block to get ACE_POSIX_Asynch_Result pointer from the pipe. More... | |
| ACE_Pipe | pipe_ |
| Pipe for the communication between Proactor and the Asynch_Accept/Asynch_Connect and other post_completions. More... | |
| ACE_POSIX_Asynch_Read_Stream | read_stream_ |
| To do asynch_read on the pipe. More... | |
This class acts as the Handler for the <Asynch_Read> operations issued on the notify pipe. This class is very useful in implementing <Asynch_Accept> operation class for the <AIOCB_Proactor>. This is also useful for implementing <post_completion> for <AIOCB_Proactor>.
<AIOCB_Proactor> class issues a <Asynch_Read> on the pipe, using this class as the Handler. <POSIX_Asynch_Result *>'s are sent through the notify pipe. When <POSIX_Asynch_Result *>'s show up on the notify pipe, the <POSIX_AIOCB_Proactor> dispatches the completion of the <Asynch_Read_Stream> and calls the <handle_read_stream> of this class. This class calls <complete> on the <POSIX_Asynch_Result *> and thus calls the application handler. Handling the MessageBlock: We give this message block to read the result pointer through the notify pipe. We expect that to read 4 bytes from the notify pipe, for each <accept> call. Before giving this message block to another <accept>, we update <wr_ptr> and put it in its initial position.
Definition at line 602 of file POSIX_Proactor.cpp.
|
|
Constructor. You need the posix proactor because you need to call <application_specific_code>.
Definition at line 637 of file POSIX_Proactor.cpp. References ACE_ERROR, ACE_NONBLOCK, LM_ERROR, ACE_POSIX_Asynch_Operation::open, ACE_Pipe::open, pipe_, posix_aiocb_proactor_, ACE_POSIX_Asynch_Read_Stream::read, read_stream_, ACE_Flag_Manip::set_flags, and ACE_POSIX_AIOCB_Proactor::set_notify_handle.
00638 : posix_aiocb_proactor_ (posix_aiocb_proactor), 00639 message_block_ (sizeof (2)), 00640 read_stream_ (posix_aiocb_proactor) 00641 { 00642 // Open the pipe. 00643 this->pipe_.open (); 00644 00645 // Set write side in NONBLOCK mode 00646 ACE::set_flags (this->pipe_.write_handle (), ACE_NONBLOCK); 00647 00648 // Let AIOCB_Proactor know about our handle 00649 posix_aiocb_proactor_->set_notify_handle (this->pipe_.read_handle ()); 00650 00651 // Open the read stream. 00652 if (this->read_stream_.open (*this, 00653 this->pipe_.read_handle (), 00654 0, // Completion Key 00655 0) // Proactor 00656 == -1) 00657 ACE_ERROR ((LM_ERROR, 00658 "%N:%l:%p\n", 00659 "ACE_AIOCB_Notify_Pipe_Manager::ACE_AIOCB_Notify_Pipe_Manager:" 00660 "Open on Read Stream failed")); 00661 00662 // Issue an asynch_read on the read_stream of the notify pipe. 00663 if (this->read_stream_.read (this->message_block_, 00664 1, // enough to read 1 byte 00665 0, // ACT 00666 0) // Priority 00667 == -1) 00668 ACE_ERROR ((LM_ERROR, 00669 "%N:%l:%p\n", 00670 "ACE_AIOCB_Notify_Pipe_Manager::ACE_AIOCB_Notify_Pipe_Manager:" 00671 "Read from pipe failed")); 00672 } |
|
|
Destructor.
Definition at line 674 of file POSIX_Proactor.cpp. References ACE_POSIX_Asynch_Operation::cancel, ACE_OS::closesocket, pipe_, ACE_Pipe::read_handle, read_stream_, and ACE_Pipe::write_handle.
00675 {
00676 // 1. try to cancel pending aio
00677 this->read_stream_.cancel ();
00678
00679 // 2. close both handles
00680 // Destuctor of ACE_Pipe does not close handles.
00681 // We can not use ACE_Pipe::close() as it
00682 // closes read_handle and than write_handle.
00683 // In some systems close() may wait for
00684 // completion for all asynch. pending requests.
00685 // So we should close write_handle firstly
00686 // to force read completion ( if 1. does not help )
00687 // and then read_handle and not vice versa
00688
00689 ACE_HANDLE h = this->pipe_.write_handle ();
00690 if (h != ACE_INVALID_HANDLE)
00691 ACE_OS::closesocket (h);
00692
00693 h = this->pipe_.read_handle ();
00694 if ( h != ACE_INVALID_HANDLE)
00695 ACE_OS::closesocket (h);
00696
00697 }
|
|
|
Default constructor. Shouldnt be called.
|
|
|
This is the call back method when <Asynch_Read> from the pipe is complete.
Reimplemented from ACE_Handler. Definition at line 726 of file POSIX_Proactor.cpp. References ACE_ERROR, ACE_LIB_TEXT, and LM_ERROR.
00727 {
00728 // 1. Start new read to avoid pipe overflow
00729
00730 // Set the message block properly. Put the <wr_ptr> back in the
00731 // initial position.
00732 if (this->message_block_.length () > 0)
00733 this->message_block_.wr_ptr (this->message_block_.rd_ptr ());
00734
00735 // One accept has completed. Issue a read to handle any
00736 // <post_completion>s in the future.
00737 if (-1 == this->read_stream_.read (this->message_block_,
00738 1, // enough to read 1 byte
00739 0, // ACT
00740 0)) // Priority
00741 ACE_ERROR ((LM_ERROR,
00742 ACE_LIB_TEXT ("%N:%l:(%P | %t):%p\n"),
00743 ACE_LIB_TEXT ("ACE_AIOCB_Notify_Pipe_Manager::handle_read_stream:")
00744 ACE_LIB_TEXT ("Read from pipe failed")));
00745
00746
00747 // 2. Do the upcalls
00748 // this->posix_aiocb_proactor_->process_result_queue ();
00749 }
|
|
|
Send the result pointer through the notification pipe.
Definition at line 701 of file POSIX_Proactor.cpp. References ACE_ERROR, ACE_LIB_TEXT, EWOULDBLOCK, LM_ERROR, and ACE::send. Referenced by ACE_POSIX_AIOCB_Proactor::notify_completion.
00702 {
00703 // Send the result pointer through the pipe.
00704 char char_send = 0;
00705 int ret_val = ACE::send (this->pipe_.write_handle (),
00706 &char_send,
00707 sizeof (char_send));
00708
00709 if (ret_val < 0)
00710 {
00711 if (errno != EWOULDBLOCK)
00712 #if 0
00713 ACE_ERROR ((LM_ERROR,
00714 ACE_LIB_TEXT ("(%P %t):%p\n"),
00715 ACE_LIB_TEXT ("ACE_AIOCB_Notify_Pipe_Manager::notify")
00716 ACE_LIB_TEXT ("Error:Writing on to notify pipe failed")));
00717 #endif /* 0 */
00718 return -1;
00719 }
00720
00721 return 0;
00722 }
|
|
|
Message block to get ACE_POSIX_Asynch_Result pointer from the pipe.
Definition at line 624 of file POSIX_Proactor.cpp. |
|
|
Pipe for the communication between Proactor and the Asynch_Accept/Asynch_Connect and other post_completions.
Definition at line 628 of file POSIX_Proactor.cpp. Referenced by ACE_AIOCB_Notify_Pipe_Manager, and ~ACE_AIOCB_Notify_Pipe_Manager. |
|
|
The implementation proactor class.
Definition at line 621 of file POSIX_Proactor.cpp. Referenced by ACE_AIOCB_Notify_Pipe_Manager. |
|
|
To do asynch_read on the pipe.
Definition at line 631 of file POSIX_Proactor.cpp. Referenced by ACE_AIOCB_Notify_Pipe_Manager, and ~ACE_AIOCB_Notify_Pipe_Manager. |
1.2.14 written by Dimitri van Heesch,
© 1997-2002