Use =default for skeleton copy constructor
[ACE_TAO.git] / ACE / ace / Asynch_IO.cpp
blob5502dd2191c2c2949adb676de8da822b97346053
1 #include "ace/Asynch_IO.h"
3 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
4 // This only works on platforms with Asynchronous IO
6 #include "ace/Proactor.h"
7 #include "ace/Message_Block.h"
8 #include "ace/INET_Addr.h"
9 #include "ace/Asynch_IO_Impl.h"
10 #include "ace/os_include/os_errno.h"
11 #include "ace/Truncate.h"
13 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
15 size_t
16 ACE_Asynch_Result::bytes_transferred () const
18 return this->implementation ()->bytes_transferred ();
21 const void *
22 ACE_Asynch_Result::act () const
24 return this->implementation ()->act ();
27 int
28 ACE_Asynch_Result::success () const
30 return this->implementation ()->success ();
33 const void *
34 ACE_Asynch_Result::completion_key () const
36 return this->implementation ()->completion_key ();
39 unsigned long
40 ACE_Asynch_Result::error () const
42 return this->implementation ()->error ();
45 ACE_HANDLE
46 ACE_Asynch_Result::event () const
48 return this->implementation ()->event ();
51 unsigned long
52 ACE_Asynch_Result::offset () const
54 return this->implementation ()->offset ();
57 unsigned long
58 ACE_Asynch_Result::offset_high () const
60 return this->implementation ()->offset_high ();
63 int
64 ACE_Asynch_Result::priority () const
66 return this->implementation ()->priority ();
69 int
70 ACE_Asynch_Result::signal_number () const
72 return this->implementation ()->signal_number ();
75 ACE_Asynch_Result::ACE_Asynch_Result (ACE_Asynch_Result_Impl *implementation)
76 : implementation_ (implementation)
80 ACE_Asynch_Result::~ACE_Asynch_Result ()
82 // Proactor deletes the implementation when the <complete> finishes.
85 ACE_Asynch_Result_Impl *
86 ACE_Asynch_Result::implementation () const
88 return this->implementation_;
91 // *********************************************************************
93 int
94 ACE_Asynch_Operation::open (ACE_Handler &handler,
95 ACE_HANDLE handle,
96 const void *completion_key,
97 ACE_Proactor *proactor)
99 return this->implementation ()->open (handler.proxy (),
100 handle,
101 completion_key,
102 proactor);
106 ACE_Asynch_Operation::cancel ()
108 if (0 == this->implementation ())
110 errno = EFAULT;
111 return -1;
113 return this->implementation ()->cancel ();
116 ACE_Proactor *
117 ACE_Asynch_Operation::proactor () const
119 if (0 == this->implementation ())
121 errno = EFAULT;
122 return 0;
124 return this->implementation ()->proactor ();
127 ACE_Proactor *
128 ACE_Asynch_Operation::get_proactor (ACE_Proactor *user_proactor,
129 ACE_Handler &handler) const
131 if (user_proactor == 0)
133 // Grab the singleton proactor if <handler->proactor> is zero
134 user_proactor = handler.proactor ();
135 if (user_proactor == 0)
136 user_proactor = ACE_Proactor::instance ();
139 return user_proactor;
142 // ************************************************************
144 ACE_Asynch_Read_Stream::ACE_Asynch_Read_Stream ()
145 : implementation_ (0)
149 ACE_Asynch_Read_Stream::~ACE_Asynch_Read_Stream ()
151 // Delete the implementation.
152 delete this->implementation_;
153 this->implementation_ = 0;
157 ACE_Asynch_Read_Stream::open (ACE_Handler &handler,
158 ACE_HANDLE handle,
159 const void *completion_key,
160 ACE_Proactor *proactor)
162 // Get a proactor for/from the user.
163 proactor = this->get_proactor (proactor, handler);
165 // Now let us get the implementation initialized.
166 if ((this->implementation_ = proactor->create_asynch_read_stream ()) == 0)
167 return -1;
169 // Call the <open> method of the base class.
170 return ACE_Asynch_Operation::open (handler,
171 handle,
172 completion_key,
173 proactor);
177 ACE_Asynch_Read_Stream::read (ACE_Message_Block &message_block,
178 size_t bytes_to_read,
179 const void *act,
180 int priority,
181 int signal_number)
183 if (0 == this->implementation_)
185 errno = EFAULT;
186 return -1;
188 return this->implementation_->read (message_block,
189 bytes_to_read,
190 act,
191 priority,
192 signal_number);
195 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
197 ACE_Asynch_Read_Stream::readv (ACE_Message_Block &message_block,
198 size_t bytes_to_read,
199 const void *act,
200 int priority,
201 int signal_number)
203 if (0 == this->implementation_)
205 errno = EFAULT;
206 return -1;
208 return this->implementation_->readv (message_block,
209 bytes_to_read,
210 act,
211 priority,
212 signal_number);
214 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
216 ACE_Asynch_Operation_Impl *
217 ACE_Asynch_Read_Stream::implementation () const
219 return this->implementation_;
222 // ************************************************************
224 size_t
225 ACE_Asynch_Read_Stream::Result::bytes_to_read () const
227 return this->implementation ()->bytes_to_read ();
230 ACE_Message_Block &
231 ACE_Asynch_Read_Stream::Result::message_block () const
233 return this->implementation ()->message_block ();
236 ACE_HANDLE
237 ACE_Asynch_Read_Stream::Result::handle () const
239 return this->implementation ()->handle ();
242 ACE_Asynch_Read_Stream::Result::Result (ACE_Asynch_Read_Stream_Result_Impl *implementation)
243 : ACE_Asynch_Result (implementation),
244 implementation_ (implementation)
248 ACE_Asynch_Read_Stream::Result::~Result ()
250 // Proactor will delete the implementation after <complete> is
251 // finished.
254 ACE_Asynch_Read_Stream_Result_Impl *
255 ACE_Asynch_Read_Stream::Result::implementation () const
257 return this->implementation_;
260 // ***************************************************
262 ACE_Asynch_Write_Stream::ACE_Asynch_Write_Stream ()
263 : implementation_ (0)
267 ACE_Asynch_Write_Stream::~ACE_Asynch_Write_Stream ()
269 // Delete the implementation.
270 delete this->implementation_;
271 this->implementation_ = 0;
275 ACE_Asynch_Write_Stream::open (ACE_Handler &handler,
276 ACE_HANDLE handle,
277 const void *completion_key,
278 ACE_Proactor *proactor)
280 // Get a proactor for/from the user.
281 proactor = this->get_proactor (proactor, handler);
283 // Now let us get the implementation initialized.
284 if ((this->implementation_ = proactor->create_asynch_write_stream ()) == 0)
285 return -1;
287 // Call the <open> method of the base class.
288 return ACE_Asynch_Operation::open (handler,
289 handle,
290 completion_key,
291 proactor);
295 ACE_Asynch_Write_Stream::write (ACE_Message_Block &message_block,
296 size_t bytes_to_write,
297 const void *act,
298 int priority,
299 int signal_number)
301 if (0 == this->implementation_)
303 errno = EFAULT;
304 return -1;
306 return this->implementation_->write (message_block,
307 bytes_to_write,
308 act,
309 priority,
310 signal_number);
313 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
315 ACE_Asynch_Write_Stream::writev (ACE_Message_Block &message_block,
316 size_t bytes_to_write,
317 const void *act,
318 int priority,
319 int signal_number)
321 if (0 == this->implementation_)
323 errno = EFAULT;
324 return -1;
326 return this->implementation_->writev (message_block,
327 bytes_to_write,
328 act,
329 priority,
330 signal_number);
332 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
334 ACE_Asynch_Operation_Impl *
335 ACE_Asynch_Write_Stream::implementation () const
337 return this->implementation_;
340 // ************************************************************
342 size_t
343 ACE_Asynch_Write_Stream::Result::bytes_to_write () const
345 return this->implementation ()->bytes_to_write ();
348 ACE_Message_Block &
349 ACE_Asynch_Write_Stream::Result::message_block () const
351 return this->implementation ()->message_block ();
354 ACE_HANDLE
355 ACE_Asynch_Write_Stream::Result::handle () const
357 return this->implementation ()->handle ();
360 ACE_Asynch_Write_Stream::Result::Result (ACE_Asynch_Write_Stream_Result_Impl *implementation)
361 : ACE_Asynch_Result (implementation),
362 implementation_ (implementation)
366 ACE_Asynch_Write_Stream::Result::~Result ()
368 // Proactor will delte the implementation when the <complete> call
369 // finishes.
372 ACE_Asynch_Write_Stream_Result_Impl *
373 ACE_Asynch_Write_Stream::Result::implementation () const
375 return this->implementation_;
378 // ************************************************************
380 ACE_Asynch_Read_File::ACE_Asynch_Read_File ()
381 : implementation_ (0)
385 ACE_Asynch_Read_File::~ACE_Asynch_Read_File ()
387 // Delete the implementation.
388 delete this->implementation_;
389 this->implementation_ = 0;
393 ACE_Asynch_Read_File::open (ACE_Handler &handler,
394 ACE_HANDLE handle,
395 const void *completion_key,
396 ACE_Proactor *proactor)
398 // Get a proactor for/from the user.
399 proactor = this->get_proactor (proactor, handler);
401 // Now let us get the implementation initialized.
402 if ((this->implementation_ = proactor->create_asynch_read_file ()) == 0)
403 return -1;
405 // Call the <open> method of the base class.
406 return ACE_Asynch_Operation::open (handler,
407 handle,
408 completion_key,
409 proactor);
413 ACE_Asynch_Read_File::read (ACE_Message_Block &message_block,
414 size_t bytes_to_read,
415 unsigned long offset,
416 unsigned long offset_high,
417 const void *act,
418 int priority,
419 int signal_number)
421 if (0 == this->implementation_)
423 errno = EFAULT;
424 return -1;
426 return this->implementation_->read (message_block,
427 bytes_to_read,
428 offset,
429 offset_high,
430 act,
431 priority,
432 signal_number);
435 #if defined (ACE_WIN32)
437 ACE_Asynch_Read_File::readv (ACE_Message_Block &message_block,
438 size_t bytes_to_read,
439 unsigned long offset,
440 unsigned long offset_high,
441 const void *act,
442 int priority,
443 int signal_number)
445 if (0 == this->implementation_)
447 errno = EFAULT;
448 return -1;
450 return this->implementation_->readv (message_block,
451 bytes_to_read,
452 offset,
453 offset_high,
454 act,
455 priority,
456 signal_number);
458 #endif /* defined (ACE_WIN32) */
460 ACE_Asynch_Operation_Impl *
461 ACE_Asynch_Read_File::implementation () const
463 return this->implementation_;
466 // ************************************************************
468 ACE_Asynch_Read_File::Result::Result (ACE_Asynch_Read_File_Result_Impl *implementation)
469 : ACE_Asynch_Read_Stream::Result (implementation),
470 implementation_ (implementation)
474 ACE_Asynch_Read_File::Result::~Result ()
476 // Proactor will delete the implementation when <complete> call
477 // completes.
480 ACE_Asynch_Read_File_Result_Impl *
481 ACE_Asynch_Read_File::Result::implementation () const
483 return this->implementation_;
486 // ************************************************************
488 ACE_Asynch_Write_File::ACE_Asynch_Write_File ()
489 : implementation_ (0)
493 ACE_Asynch_Write_File::~ACE_Asynch_Write_File ()
495 // Delete the implementation.
496 delete this->implementation_;
497 this->implementation_ = 0;
501 ACE_Asynch_Write_File::open (ACE_Handler &handler,
502 ACE_HANDLE handle,
503 const void *completion_key,
504 ACE_Proactor *proactor)
506 // Get a proactor for/from the user.
507 proactor = this->get_proactor (proactor, handler);
509 // Now let us get the implementation initialized.
510 if ((this->implementation_ = proactor->create_asynch_write_file ()) == 0)
511 return -1;
513 // Call the <open> method of the base class.
514 return ACE_Asynch_Operation::open (handler,
515 handle,
516 completion_key,
517 proactor);
521 ACE_Asynch_Write_File::write (ACE_Message_Block &message_block,
522 size_t bytes_to_write,
523 unsigned long offset,
524 unsigned long offset_high,
525 const void *act,
526 int priority,
527 int signal_number)
529 if (0 == this->implementation_)
531 errno = EFAULT;
532 return -1;
534 return this->implementation_->write (message_block,
535 bytes_to_write,
536 offset,
537 offset_high,
538 act,
539 priority,
540 signal_number);
543 #if defined (ACE_WIN32)
545 ACE_Asynch_Write_File::writev (ACE_Message_Block &message_block,
546 size_t bytes_to_write,
547 unsigned long offset,
548 unsigned long offset_high,
549 const void *act,
550 int priority,
551 int signal_number)
553 if (0 == this->implementation_)
555 errno = EFAULT;
556 return -1;
558 return this->implementation_->writev (message_block,
559 bytes_to_write,
560 offset,
561 offset_high,
562 act,
563 priority,
564 signal_number);
566 #endif /* defined (ACE_WIN32) */
568 ACE_Asynch_Operation_Impl *
569 ACE_Asynch_Write_File::implementation () const
571 return this->implementation_;
574 // ************************************************************
576 ACE_Asynch_Write_File::Result::Result (ACE_Asynch_Write_File_Result_Impl *implementation)
577 : ACE_Asynch_Write_Stream::Result (implementation),
578 implementation_ (implementation)
582 ACE_Asynch_Write_File::Result::~Result ()
584 // Proactor will delete the implementation when the <complete> call
585 // completes.
588 ACE_Asynch_Write_File_Result_Impl *
589 ACE_Asynch_Write_File::Result::implementation () const
591 return this->implementation_;
594 // *********************************************************************
596 ACE_Asynch_Accept::ACE_Asynch_Accept ()
597 : implementation_ (0)
601 ACE_Asynch_Accept::~ACE_Asynch_Accept ()
603 // Delete the implementation.
604 delete this->implementation_;
605 this->implementation_ = 0;
609 ACE_Asynch_Accept::open (ACE_Handler &handler,
610 ACE_HANDLE handle,
611 const void *completion_key,
612 ACE_Proactor *proactor)
614 // Get a proactor for/from the user.
615 proactor = this->get_proactor (proactor, handler);
617 // Now let us get the implementation initialized.
618 if ((this->implementation_ = proactor->create_asynch_accept ()) == 0)
619 return -1;
621 // Call the <open> method of the base class.
622 return ACE_Asynch_Operation::open (handler,
623 handle,
624 completion_key,
625 proactor);
629 ACE_Asynch_Accept::accept (ACE_Message_Block &message_block,
630 size_t bytes_to_read,
631 ACE_HANDLE accept_handle,
632 const void *act,
633 int priority,
634 int signal_number,
635 int addr_family)
637 if (0 == this->implementation_)
639 errno = EFAULT;
640 return -1;
642 return this->implementation_->accept (message_block,
643 bytes_to_read,
644 accept_handle,
645 act,
646 priority,
647 signal_number,
648 addr_family);
651 ACE_Asynch_Operation_Impl *
652 ACE_Asynch_Accept::implementation () const
654 return this->implementation_;
657 // ************************************************************
659 size_t
660 ACE_Asynch_Accept::Result::bytes_to_read () const
662 return this->implementation ()->bytes_to_read ();
665 ACE_Message_Block &
666 ACE_Asynch_Accept::Result::message_block () const
668 return this->implementation ()->message_block ();
671 ACE_HANDLE
672 ACE_Asynch_Accept::Result::listen_handle () const
674 return this->implementation ()->listen_handle ();
677 ACE_HANDLE
678 ACE_Asynch_Accept::Result::accept_handle () const
680 return this->implementation ()->accept_handle ();
683 ACE_Asynch_Accept::Result::Result (ACE_Asynch_Accept_Result_Impl *implementation)
684 : ACE_Asynch_Result (implementation),
685 implementation_ (implementation)
689 ACE_Asynch_Accept::Result::~Result ()
691 // Proactor will delete the implementation when the <complete> call
692 // completes.
695 ACE_Asynch_Accept_Result_Impl *
696 ACE_Asynch_Accept::Result::implementation () const
698 return this->implementation_;
702 // *********************************************************************
704 ACE_Asynch_Connect::ACE_Asynch_Connect ()
705 : implementation_ (0)
709 ACE_Asynch_Connect::~ACE_Asynch_Connect ()
711 // Delete the implementation.
712 delete this->implementation_;
713 this->implementation_ = 0;
717 ACE_Asynch_Connect::open (ACE_Handler &handler,
718 ACE_HANDLE handle,
719 const void *completion_key,
720 ACE_Proactor *proactor)
722 // Get a proactor for/from the user.
723 proactor = this->get_proactor (proactor, handler);
725 // Now let us get the implementation initialized.
726 if ((this->implementation_ = proactor->create_asynch_connect ()) == 0)
727 return -1;
729 // Call the <open> method of the base class.
730 return ACE_Asynch_Operation::open (handler,
731 handle,
732 completion_key,
733 proactor);
737 ACE_Asynch_Connect::connect (ACE_HANDLE connect_handle,
738 const ACE_Addr & remote_sap,
739 const ACE_Addr & local_sap,
740 int reuse_addr,
741 const void *act,
742 int priority,
743 int signal_number)
745 if (0 == this->implementation_)
747 errno = EFAULT;
748 return -1;
750 return this->implementation_->connect (connect_handle,
751 remote_sap,
752 local_sap,
753 reuse_addr,
754 act,
755 priority,
756 signal_number);
759 ACE_Asynch_Operation_Impl *
760 ACE_Asynch_Connect::implementation () const
762 return this->implementation_;
765 // ************************************************************
767 ACE_Asynch_Connect::Result::Result (ACE_Asynch_Connect_Result_Impl *implementation)
768 : ACE_Asynch_Result (implementation),
769 implementation_ (implementation)
773 ACE_Asynch_Connect::Result::~Result ()
775 // Proactor will delete the implementation when the <complete> call
776 // completes.
779 ACE_HANDLE
780 ACE_Asynch_Connect::Result::connect_handle () const
782 return this->implementation ()->connect_handle ();
786 ACE_Asynch_Connect_Result_Impl *
787 ACE_Asynch_Connect::Result::implementation () const
789 return this->implementation_;
792 // ************************************************************
794 ACE_Asynch_Transmit_File::ACE_Asynch_Transmit_File ()
795 : implementation_ (0)
799 ACE_Asynch_Transmit_File::~ACE_Asynch_Transmit_File ()
801 // Delete the implementation.
802 delete this->implementation_;
803 this->implementation_ = 0;
807 ACE_Asynch_Transmit_File::open (ACE_Handler &handler,
808 ACE_HANDLE handle,
809 const void *completion_key,
810 ACE_Proactor *proactor)
812 // Get a proactor for/from the user.
813 proactor = this->get_proactor (proactor, handler);
815 // Now let us get the implementation initialized.
816 if ((this->implementation_ = proactor->create_asynch_transmit_file ()) == 0)
817 return -1;
819 // Call the <open> method of the base class.
820 return ACE_Asynch_Operation::open (handler,
821 handle,
822 completion_key,
823 proactor);
827 ACE_Asynch_Transmit_File::transmit_file (ACE_HANDLE file,
828 Header_And_Trailer *header_and_trailer,
829 size_t bytes_to_write,
830 unsigned long offset,
831 unsigned long offset_high,
832 size_t bytes_per_send,
833 unsigned long flags,
834 const void *act,
835 int priority,
836 int signal_number)
838 if (0 == this->implementation_)
840 errno = EFAULT;
841 return -1;
843 return this->implementation_->transmit_file (file,
844 header_and_trailer,
845 bytes_to_write,
846 offset,
847 offset_high,
848 bytes_per_send,
849 flags,
850 act,
851 priority,
852 signal_number);
855 ACE_Asynch_Operation_Impl *
856 ACE_Asynch_Transmit_File::implementation () const
858 return this->implementation_;
861 // ****************************************************************************
863 ACE_HANDLE
864 ACE_Asynch_Transmit_File::Result::socket () const
866 return this->implementation ()->socket ();
869 ACE_HANDLE
870 ACE_Asynch_Transmit_File::Result::file () const
872 return this->implementation ()->file ();
875 ACE_Asynch_Transmit_File::Header_And_Trailer *
876 ACE_Asynch_Transmit_File::Result::header_and_trailer () const
878 return this->implementation ()->header_and_trailer ();
881 size_t
882 ACE_Asynch_Transmit_File::Result::bytes_to_write () const
884 return this->implementation ()->bytes_to_write ();
887 size_t
888 ACE_Asynch_Transmit_File::Result::bytes_per_send () const
890 return this->implementation ()->bytes_per_send ();
893 unsigned long
894 ACE_Asynch_Transmit_File::Result::flags () const
896 return this->implementation ()->flags ();
899 ACE_Asynch_Transmit_File::Result::Result (ACE_Asynch_Transmit_File_Result_Impl *implementation)
900 : ACE_Asynch_Result (implementation),
901 implementation_ (implementation)
905 ACE_Asynch_Transmit_File::Result::~Result ()
909 ACE_Asynch_Transmit_File_Result_Impl *
910 ACE_Asynch_Transmit_File::Result::implementation () const
912 return this->implementation_;
915 // ************************************************************
917 ACE_Asynch_Transmit_File::Header_And_Trailer::Header_And_Trailer (ACE_Message_Block *header,
918 size_t header_bytes,
919 ACE_Message_Block *trailer,
920 size_t trailer_bytes)
921 : header_ (header),
922 header_bytes_ (header_bytes),
923 trailer_ (trailer),
924 trailer_bytes_ (trailer_bytes)
928 ACE_Asynch_Transmit_File::Header_And_Trailer::~Header_And_Trailer ()
932 void
933 ACE_Asynch_Transmit_File::Header_And_Trailer::header_and_trailer (ACE_Message_Block *header,
934 size_t header_bytes,
935 ACE_Message_Block *trailer,
936 size_t trailer_bytes)
938 this->header (header);
939 this->header_bytes (header_bytes);
940 this->trailer (trailer);
941 this->trailer_bytes (trailer_bytes);
944 ACE_Message_Block *
945 ACE_Asynch_Transmit_File::Header_And_Trailer::header () const
947 return this->header_;
950 void
951 ACE_Asynch_Transmit_File::Header_And_Trailer::header (ACE_Message_Block *message_block)
953 this->header_ = message_block;
956 size_t
957 ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes () const
959 return this->header_bytes_;
962 void
963 ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (size_t bytes)
965 this->header_bytes_ = bytes;
968 ACE_Message_Block *
969 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer () const
971 return this->trailer_;
974 void
975 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (ACE_Message_Block *message_block)
977 this->trailer_ = message_block;
980 size_t
981 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes () const
983 return this->trailer_bytes_;
986 void
987 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (size_t bytes)
989 this->trailer_bytes_ = bytes;
992 ACE_LPTRANSMIT_FILE_BUFFERS
993 ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers ()
995 // If both are zero, return zero
996 if (this->header_ == 0 && this->trailer_ == 0)
998 return 0;
1000 else
1002 // Something is valid
1004 // If header is valid, set the fields
1005 if (this->header_ != 0)
1007 this->transmit_buffers_.Head = this->header_->rd_ptr ();
1008 #if defined (ACE_WIN64) || defined (ACE_WIN32)
1009 this->transmit_buffers_.HeadLength =
1010 ACE_Utils::truncate_cast<DWORD> (this->header_bytes_);
1011 #else
1012 this->transmit_buffers_.HeadLength = this->header_bytes_;
1013 #endif /* ACE_WIN64 || ACE_WIN32 */
1015 else
1017 this->transmit_buffers_.Head = 0;
1018 this->transmit_buffers_.HeadLength = 0;
1021 // If trailer is valid, set the fields
1022 if (this->trailer_ != 0)
1024 this->transmit_buffers_.Tail = this->trailer_->rd_ptr ();
1025 #if defined(ACE_WIN64) || defined (ACE_WIN32)
1026 this->transmit_buffers_.TailLength =
1027 ACE_Utils::truncate_cast<DWORD> (this->trailer_bytes_);
1028 #else
1029 this->transmit_buffers_.TailLength = this->trailer_bytes_;
1030 #endif /* ACE_WIN64 || ACE_WIN32 */
1032 else
1034 this->transmit_buffers_.Tail = 0;
1035 this->transmit_buffers_.TailLength = 0;
1038 // Return the transmit buffers
1039 return &this->transmit_buffers_;
1043 // *********************************************************************
1045 ACE_Handler::ACE_Handler ()
1046 : proactor_ (0), handle_ (ACE_INVALID_HANDLE)
1048 ACE_Handler::Proxy *p;
1049 ACE_NEW (p, ACE_Handler::Proxy (this));
1050 this->proxy_.reset (p);
1053 ACE_Handler::ACE_Handler (ACE_Proactor *d)
1054 : proactor_ (d), handle_ (ACE_INVALID_HANDLE)
1056 ACE_Handler::Proxy *p;
1057 ACE_NEW (p, ACE_Handler::Proxy (this));
1058 this->proxy_.reset (p);
1061 ACE_Handler::~ACE_Handler ()
1063 ACE_Handler::Proxy *p = this->proxy_.get ();
1064 if (p)
1065 p->reset ();
1068 void
1069 ACE_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result & /* result */)
1073 void
1074 ACE_Handler::handle_write_stream (const ACE_Asynch_Write_Stream::Result & /* result */)
1078 void
1079 ACE_Handler::handle_write_dgram (const ACE_Asynch_Write_Dgram::Result & /* result */)
1083 void
1084 ACE_Handler::handle_read_dgram (const ACE_Asynch_Read_Dgram::Result & /* result */)
1088 void
1089 ACE_Handler::handle_accept (const ACE_Asynch_Accept::Result & /* result */)
1093 void
1094 ACE_Handler::handle_connect (const ACE_Asynch_Connect::Result & /* result */)
1098 void
1099 ACE_Handler::handle_transmit_file (const ACE_Asynch_Transmit_File::Result & /* result */)
1103 void
1104 ACE_Handler::handle_read_file (const ACE_Asynch_Read_File::Result & /* result */)
1108 void
1109 ACE_Handler::handle_write_file (const ACE_Asynch_Write_File::Result & /* result */)
1113 void
1114 ACE_Handler::handle_time_out (const ACE_Time_Value & /* tv */,
1115 const void * /* act */)
1119 void
1120 ACE_Handler::handle_wakeup ()
1124 ACE_Proactor *
1125 ACE_Handler::proactor ()
1127 return this->proactor_;
1130 void
1131 ACE_Handler::proactor (ACE_Proactor *p)
1133 this->proactor_ = p;
1136 ACE_HANDLE
1137 ACE_Handler::handle () const
1139 return this->handle_;
1142 void
1143 ACE_Handler::handle (ACE_HANDLE h)
1145 this->handle_ = h;
1148 ACE_Refcounted_Auto_Ptr<ACE_Handler::Proxy, ACE_SYNCH_MUTEX> &
1149 ACE_Handler::proxy ()
1151 return this->proxy_;
1154 // ************************************************************
1156 ACE_Service_Handler::ACE_Service_Handler ()
1160 ACE_Service_Handler::~ACE_Service_Handler ()
1164 void
1165 ACE_Service_Handler::addresses (const ACE_INET_Addr & /* remote_address */,
1166 const ACE_INET_Addr & /* local_address */ )
1170 void
1171 ACE_Service_Handler::act (const void *)
1175 void
1176 ACE_Service_Handler::open (ACE_HANDLE,
1177 ACE_Message_Block &)
1182 // ************************************************************
1184 ACE_Asynch_Read_Dgram::ACE_Asynch_Read_Dgram ()
1185 : implementation_ (0)
1189 ACE_Asynch_Read_Dgram::~ACE_Asynch_Read_Dgram ()
1191 // Delete the implementation.
1192 delete this->implementation_;
1193 this->implementation_ = 0;
1197 ACE_Asynch_Read_Dgram::open (ACE_Handler &handler,
1198 ACE_HANDLE handle,
1199 const void *completion_key,
1200 ACE_Proactor *proactor)
1202 // Get a proactor for/from the user.
1203 proactor = this->get_proactor (proactor, handler);
1205 // Now let us get the implementation initialized.
1206 if ((this->implementation_ = proactor->create_asynch_read_dgram ()) == 0)
1207 return -1;
1209 // Call the <open> method of the base class.
1210 return ACE_Asynch_Operation::open (handler,
1211 handle,
1212 completion_key,
1213 proactor);
1216 ssize_t
1217 ACE_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block,
1218 size_t &number_of_bytes_recvd,
1219 int flags,
1220 int protocol_family,
1221 const void *act,
1222 int priority,
1223 int signal_number)
1225 if (0 == this->implementation_)
1227 errno = EFAULT;
1228 return -1;
1230 return this->implementation_->recv (message_block,
1231 number_of_bytes_recvd,
1232 flags,
1233 protocol_family,
1234 act,
1235 priority,
1236 signal_number);
1239 ACE_Asynch_Operation_Impl *
1240 ACE_Asynch_Read_Dgram::implementation () const
1242 return this->implementation_;
1245 // ************************************************************
1248 ACE_Asynch_Read_Dgram::Result::remote_address (ACE_Addr& addr) const
1250 return this->implementation ()->remote_address (addr);
1253 ACE_Message_Block*
1254 ACE_Asynch_Read_Dgram::Result::message_block () const
1256 return this->implementation ()->message_block ();
1260 ACE_Asynch_Read_Dgram::Result::flags () const
1262 return this->implementation ()->flags ();
1265 size_t
1266 ACE_Asynch_Read_Dgram::Result::bytes_to_read () const
1268 return this->implementation ()->bytes_to_read ();
1271 ACE_HANDLE
1272 ACE_Asynch_Read_Dgram::Result::handle () const
1274 return this->implementation ()->handle();
1277 ACE_Asynch_Read_Dgram::Result::Result (ACE_Asynch_Read_Dgram_Result_Impl *implementation)
1278 : ACE_Asynch_Result (implementation),
1279 implementation_ (implementation)
1283 ACE_Asynch_Read_Dgram::Result::~Result ()
1287 ACE_Asynch_Read_Dgram_Result_Impl *
1288 ACE_Asynch_Read_Dgram::Result::implementation () const
1290 return this->implementation_;
1293 // ************************************************************
1296 ACE_Asynch_Write_Dgram::ACE_Asynch_Write_Dgram ()
1297 : implementation_ (0)
1301 ACE_Asynch_Write_Dgram::~ACE_Asynch_Write_Dgram ()
1303 // Delete the implementation.
1304 delete this->implementation_;
1305 this->implementation_ = 0;
1309 ACE_Asynch_Write_Dgram::open (ACE_Handler &handler,
1310 ACE_HANDLE handle,
1311 const void *completion_key,
1312 ACE_Proactor *proactor)
1314 // Get a proactor for/from the user.
1315 proactor = this->get_proactor (proactor, handler);
1317 // Now let us get the implementation initialized.
1318 if ((this->implementation_ = proactor->create_asynch_write_dgram ()) == 0)
1319 return -1;
1321 // Call the <open> method of the base class.
1322 return ACE_Asynch_Operation::open (handler,
1323 handle,
1324 completion_key,
1325 proactor);
1328 ssize_t
1329 ACE_Asynch_Write_Dgram::send (ACE_Message_Block *message_block,
1330 size_t &number_of_bytes_sent,
1331 int flags,
1332 const ACE_Addr& remote_addr,
1333 const void *act,
1334 int priority,
1335 int signal_number)
1337 if (0 == this->implementation_)
1339 errno = EFAULT;
1340 return -1;
1342 return this->implementation_->send (message_block,
1343 number_of_bytes_sent,
1344 flags,
1345 remote_addr,
1346 act,
1347 priority,
1348 signal_number);
1351 ACE_Asynch_Operation_Impl *
1352 ACE_Asynch_Write_Dgram::implementation () const
1354 return this->implementation_;
1357 // ************************************************************
1359 size_t
1360 ACE_Asynch_Write_Dgram::Result::bytes_to_write () const
1362 return this->implementation ()->bytes_to_write ();
1365 ACE_Message_Block*
1366 ACE_Asynch_Write_Dgram::Result::message_block () const
1368 return this->implementation ()->message_block ();
1372 ACE_Asynch_Write_Dgram::Result::flags () const
1374 return this->implementation ()->flags ();
1377 ACE_HANDLE
1378 ACE_Asynch_Write_Dgram::Result::handle () const
1380 return this->implementation ()->handle ();
1383 ACE_Asynch_Write_Dgram_Result_Impl *
1384 ACE_Asynch_Write_Dgram::Result::implementation () const
1386 return this->implementation_;
1389 ACE_Asynch_Write_Dgram::Result::Result (ACE_Asynch_Write_Dgram_Result_Impl *implementation)
1390 : ACE_Asynch_Result (implementation),
1391 implementation_ (implementation)
1395 ACE_Asynch_Write_Dgram::Result::~Result ()
1399 ACE_END_VERSIONED_NAMESPACE_DECL
1401 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */