[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / dep / ACE_wrappers / ace / Asynch_IO.cpp
blob26bba31a3a993a4a75fa66e6e44b7ef32059743f
1 // $Id: Asynch_IO.cpp 82559 2008-08-07 20:23:07Z parsons $
3 #include "ace/Asynch_IO.h"
5 ACE_RCSID(ace, Asynch_IO, "$Id: Asynch_IO.cpp 82559 2008-08-07 20:23:07Z parsons $")
7 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
8 // This only works on platforms with Asynchronous IO
10 #include "ace/Proactor.h"
11 #include "ace/Message_Block.h"
12 #include "ace/INET_Addr.h"
13 #include "ace/Asynch_IO_Impl.h"
14 #include "ace/os_include/os_errno.h"
15 #include "ace/Truncate.h"
17 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
19 size_t
20 ACE_Asynch_Result::bytes_transferred (void) const
22 return this->implementation ()->bytes_transferred ();
25 const void *
26 ACE_Asynch_Result::act (void) const
28 return this->implementation ()->act ();
31 int
32 ACE_Asynch_Result::success (void) const
34 return this->implementation ()->success ();
37 const void *
38 ACE_Asynch_Result::completion_key (void) const
40 return this->implementation ()->completion_key ();
43 unsigned long
44 ACE_Asynch_Result::error (void) const
46 return this->implementation ()->error ();
49 ACE_HANDLE
50 ACE_Asynch_Result::event (void) const
52 return this->implementation ()->event ();
55 unsigned long
56 ACE_Asynch_Result::offset (void) const
58 return this->implementation ()->offset ();
61 unsigned long
62 ACE_Asynch_Result::offset_high (void) const
64 return this->implementation ()->offset_high ();
67 int
68 ACE_Asynch_Result::priority (void) const
70 return this->implementation ()->priority ();
73 int
74 ACE_Asynch_Result::signal_number (void) const
76 return this->implementation ()->signal_number ();
79 ACE_Asynch_Result::ACE_Asynch_Result (ACE_Asynch_Result_Impl *implementation)
80 : implementation_ (implementation)
84 ACE_Asynch_Result::~ACE_Asynch_Result (void)
86 // Proactor deletes the implementation when the <complete> finishes.
89 ACE_Asynch_Result_Impl *
90 ACE_Asynch_Result::implementation (void) const
92 return this->implementation_;
95 // *********************************************************************
97 int
98 ACE_Asynch_Operation::open (ACE_Handler &handler,
99 ACE_HANDLE handle,
100 const void *completion_key,
101 ACE_Proactor *proactor)
103 return this->implementation ()->open (handler.proxy (),
104 handle,
105 completion_key,
106 proactor);
110 ACE_Asynch_Operation::cancel (void)
112 if (0 == this->implementation ())
114 errno = EFAULT;
115 return -1;
117 return this->implementation ()->cancel ();
120 ACE_Proactor *
121 ACE_Asynch_Operation::proactor (void) const
123 if (0 == this->implementation ())
125 errno = EFAULT;
126 return 0;
128 return this->implementation ()->proactor ();
131 ACE_Asynch_Operation::ACE_Asynch_Operation (void)
135 ACE_Asynch_Operation::~ACE_Asynch_Operation (void)
139 ACE_Proactor *
140 ACE_Asynch_Operation::get_proactor (ACE_Proactor *user_proactor,
141 ACE_Handler &handler) const
143 if (user_proactor == 0)
145 // Grab the singleton proactor if <handler->proactor> is zero
146 user_proactor = handler.proactor ();
147 if (user_proactor == 0)
148 user_proactor = ACE_Proactor::instance ();
151 return user_proactor;
154 // ************************************************************
156 ACE_Asynch_Read_Stream::ACE_Asynch_Read_Stream (void)
157 : implementation_ (0)
161 ACE_Asynch_Read_Stream::~ACE_Asynch_Read_Stream (void)
163 // Delete the implementation.
164 delete this->implementation_;
165 this->implementation_ = 0;
169 ACE_Asynch_Read_Stream::open (ACE_Handler &handler,
170 ACE_HANDLE handle,
171 const void *completion_key,
172 ACE_Proactor *proactor)
174 // Get a proactor for/from the user.
175 proactor = this->get_proactor (proactor, handler);
177 // Now let us get the implementation initialized.
178 if ((this->implementation_ = proactor->create_asynch_read_stream ()) == 0)
179 return -1;
181 // Call the <open> method of the base class.
182 return ACE_Asynch_Operation::open (handler,
183 handle,
184 completion_key,
185 proactor);
189 ACE_Asynch_Read_Stream::read (ACE_Message_Block &message_block,
190 size_t bytes_to_read,
191 const void *act,
192 int priority,
193 int signal_number)
195 if (0 == this->implementation_)
197 errno = EFAULT;
198 return -1;
200 return this->implementation_->read (message_block,
201 bytes_to_read,
202 act,
203 priority,
204 signal_number);
207 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
209 ACE_Asynch_Read_Stream::readv (ACE_Message_Block &message_block,
210 size_t bytes_to_read,
211 const void *act,
212 int priority,
213 int signal_number)
215 if (0 == this->implementation_)
217 errno = EFAULT;
218 return -1;
220 return this->implementation_->readv (message_block,
221 bytes_to_read,
222 act,
223 priority,
224 signal_number);
226 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
228 ACE_Asynch_Operation_Impl *
229 ACE_Asynch_Read_Stream::implementation (void) const
231 return this->implementation_;
234 // ************************************************************
236 size_t
237 ACE_Asynch_Read_Stream::Result::bytes_to_read (void) const
239 return this->implementation ()->bytes_to_read ();
242 ACE_Message_Block &
243 ACE_Asynch_Read_Stream::Result::message_block (void) const
245 return this->implementation ()->message_block ();
248 ACE_HANDLE
249 ACE_Asynch_Read_Stream::Result::handle (void) const
251 return this->implementation ()->handle ();
254 ACE_Asynch_Read_Stream::Result::Result (ACE_Asynch_Read_Stream_Result_Impl *implementation)
255 : ACE_Asynch_Result (implementation),
256 implementation_ (implementation)
260 ACE_Asynch_Read_Stream::Result::~Result (void)
262 // Proactor will delete the implementation after <complete> is
263 // finished.
266 ACE_Asynch_Read_Stream_Result_Impl *
267 ACE_Asynch_Read_Stream::Result::implementation (void) const
269 return this->implementation_;
272 // ***************************************************
274 ACE_Asynch_Write_Stream::ACE_Asynch_Write_Stream (void)
275 : implementation_ (0)
279 ACE_Asynch_Write_Stream::~ACE_Asynch_Write_Stream (void)
281 // Delete the implementation.
282 delete this->implementation_;
283 this->implementation_ = 0;
287 ACE_Asynch_Write_Stream::open (ACE_Handler &handler,
288 ACE_HANDLE handle,
289 const void *completion_key,
290 ACE_Proactor *proactor)
292 // Get a proactor for/from the user.
293 proactor = this->get_proactor (proactor, handler);
295 // Now let us get the implementation initialized.
296 if ((this->implementation_ = proactor->create_asynch_write_stream ()) == 0)
297 return -1;
299 // Call the <open> method of the base class.
300 return ACE_Asynch_Operation::open (handler,
301 handle,
302 completion_key,
303 proactor);
307 ACE_Asynch_Write_Stream::write (ACE_Message_Block &message_block,
308 size_t bytes_to_write,
309 const void *act,
310 int priority,
311 int signal_number)
313 if (0 == this->implementation_)
315 errno = EFAULT;
316 return -1;
318 return this->implementation_->write (message_block,
319 bytes_to_write,
320 act,
321 priority,
322 signal_number);
325 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
327 ACE_Asynch_Write_Stream::writev (ACE_Message_Block &message_block,
328 size_t bytes_to_write,
329 const void *act,
330 int priority,
331 int signal_number)
333 if (0 == this->implementation_)
335 errno = EFAULT;
336 return -1;
338 return this->implementation_->writev (message_block,
339 bytes_to_write,
340 act,
341 priority,
342 signal_number);
344 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
346 ACE_Asynch_Operation_Impl *
347 ACE_Asynch_Write_Stream::implementation (void) const
349 return this->implementation_;
352 // ************************************************************
354 size_t
355 ACE_Asynch_Write_Stream::Result::bytes_to_write (void) const
357 return this->implementation ()->bytes_to_write ();
360 ACE_Message_Block &
361 ACE_Asynch_Write_Stream::Result::message_block (void) const
363 return this->implementation ()->message_block ();
366 ACE_HANDLE
367 ACE_Asynch_Write_Stream::Result::handle (void) const
369 return this->implementation ()->handle ();
372 ACE_Asynch_Write_Stream::Result::Result (ACE_Asynch_Write_Stream_Result_Impl *implementation)
373 : ACE_Asynch_Result (implementation),
374 implementation_ (implementation)
378 ACE_Asynch_Write_Stream::Result::~Result (void)
380 // Proactor will delte the implementation when the <complete> call
381 // finishes.
384 ACE_Asynch_Write_Stream_Result_Impl *
385 ACE_Asynch_Write_Stream::Result::implementation (void) const
387 return this->implementation_;
390 // ************************************************************
392 ACE_Asynch_Read_File::ACE_Asynch_Read_File (void)
393 : implementation_ (0)
397 ACE_Asynch_Read_File::~ACE_Asynch_Read_File (void)
399 // Delete the implementation.
400 delete this->implementation_;
401 this->implementation_ = 0;
405 ACE_Asynch_Read_File::open (ACE_Handler &handler,
406 ACE_HANDLE handle,
407 const void *completion_key,
408 ACE_Proactor *proactor)
410 // Get a proactor for/from the user.
411 proactor = this->get_proactor (proactor, handler);
413 // Now let us get the implementation initialized.
414 if ((this->implementation_ = proactor->create_asynch_read_file ()) == 0)
415 return -1;
417 // Call the <open> method of the base class.
418 return ACE_Asynch_Operation::open (handler,
419 handle,
420 completion_key,
421 proactor);
425 ACE_Asynch_Read_File::read (ACE_Message_Block &message_block,
426 size_t bytes_to_read,
427 unsigned long offset,
428 unsigned long offset_high,
429 const void *act,
430 int priority,
431 int signal_number)
433 if (0 == this->implementation_)
435 errno = EFAULT;
436 return -1;
438 return this->implementation_->read (message_block,
439 bytes_to_read,
440 offset,
441 offset_high,
442 act,
443 priority,
444 signal_number);
447 #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
449 ACE_Asynch_Read_File::readv (ACE_Message_Block &message_block,
450 size_t bytes_to_read,
451 unsigned long offset,
452 unsigned long offset_high,
453 const void *act,
454 int priority,
455 int signal_number)
457 if (0 == this->implementation_)
459 errno = EFAULT;
460 return -1;
462 return this->implementation_->readv (message_block,
463 bytes_to_read,
464 offset,
465 offset_high,
466 act,
467 priority,
468 signal_number);
470 #endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
472 ACE_Asynch_Operation_Impl *
473 ACE_Asynch_Read_File::implementation (void) const
475 return this->implementation_;
478 // ************************************************************
480 ACE_Asynch_Read_File::Result::Result (ACE_Asynch_Read_File_Result_Impl *implementation)
481 : ACE_Asynch_Read_Stream::Result (implementation),
482 implementation_ (implementation)
486 ACE_Asynch_Read_File::Result::~Result (void)
488 // Proactor will delete the implementation when <complete> call
489 // completes.
492 ACE_Asynch_Read_File_Result_Impl *
493 ACE_Asynch_Read_File::Result::implementation (void) const
495 return this->implementation_;
498 // ************************************************************
500 ACE_Asynch_Write_File::ACE_Asynch_Write_File (void)
501 : implementation_ (0)
505 ACE_Asynch_Write_File::~ACE_Asynch_Write_File (void)
507 // Delete the implementation.
508 delete this->implementation_;
509 this->implementation_ = 0;
513 ACE_Asynch_Write_File::open (ACE_Handler &handler,
514 ACE_HANDLE handle,
515 const void *completion_key,
516 ACE_Proactor *proactor)
518 // Get a proactor for/from the user.
519 proactor = this->get_proactor (proactor, handler);
521 // Now let us get the implementation initialized.
522 if ((this->implementation_ = proactor->create_asynch_write_file ()) == 0)
523 return -1;
525 // Call the <open> method of the base class.
526 return ACE_Asynch_Operation::open (handler,
527 handle,
528 completion_key,
529 proactor);
533 ACE_Asynch_Write_File::write (ACE_Message_Block &message_block,
534 size_t bytes_to_write,
535 unsigned long offset,
536 unsigned long offset_high,
537 const void *act,
538 int priority,
539 int signal_number)
541 if (0 == this->implementation_)
543 errno = EFAULT;
544 return -1;
546 return this->implementation_->write (message_block,
547 bytes_to_write,
548 offset,
549 offset_high,
550 act,
551 priority,
552 signal_number);
555 #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
557 ACE_Asynch_Write_File::writev (ACE_Message_Block &message_block,
558 size_t bytes_to_write,
559 unsigned long offset,
560 unsigned long offset_high,
561 const void *act,
562 int priority,
563 int signal_number)
565 if (0 == this->implementation_)
567 errno = EFAULT;
568 return -1;
570 return this->implementation_->writev (message_block,
571 bytes_to_write,
572 offset,
573 offset_high,
574 act,
575 priority,
576 signal_number);
578 #endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
580 ACE_Asynch_Operation_Impl *
581 ACE_Asynch_Write_File::implementation (void) const
583 return this->implementation_;
586 // ************************************************************
588 ACE_Asynch_Write_File::Result::Result (ACE_Asynch_Write_File_Result_Impl *implementation)
589 : ACE_Asynch_Write_Stream::Result (implementation),
590 implementation_ (implementation)
594 ACE_Asynch_Write_File::Result::~Result (void)
596 // Proactor will delete the implementation when the <complete> call
597 // completes.
600 ACE_Asynch_Write_File_Result_Impl *
601 ACE_Asynch_Write_File::Result::implementation (void) const
603 return this->implementation_;
606 // *********************************************************************
608 ACE_Asynch_Accept::ACE_Asynch_Accept (void)
609 : implementation_ (0)
613 ACE_Asynch_Accept::~ACE_Asynch_Accept (void)
615 // Delete the implementation.
616 delete this->implementation_;
617 this->implementation_ = 0;
621 ACE_Asynch_Accept::open (ACE_Handler &handler,
622 ACE_HANDLE handle,
623 const void *completion_key,
624 ACE_Proactor *proactor)
626 // Get a proactor for/from the user.
627 proactor = this->get_proactor (proactor, handler);
629 // Now let us get the implementation initialized.
630 if ((this->implementation_ = proactor->create_asynch_accept ()) == 0)
631 return -1;
633 // Call the <open> method of the base class.
634 return ACE_Asynch_Operation::open (handler,
635 handle,
636 completion_key,
637 proactor);
641 ACE_Asynch_Accept::accept (ACE_Message_Block &message_block,
642 size_t bytes_to_read,
643 ACE_HANDLE accept_handle,
644 const void *act,
645 int priority,
646 int signal_number,
647 int addr_family)
649 if (0 == this->implementation_)
651 errno = EFAULT;
652 return -1;
654 return this->implementation_->accept (message_block,
655 bytes_to_read,
656 accept_handle,
657 act,
658 priority,
659 signal_number,
660 addr_family);
663 ACE_Asynch_Operation_Impl *
664 ACE_Asynch_Accept::implementation (void) const
666 return this->implementation_;
669 // ************************************************************
671 size_t
672 ACE_Asynch_Accept::Result::bytes_to_read (void) const
674 return this->implementation ()->bytes_to_read ();
677 ACE_Message_Block &
678 ACE_Asynch_Accept::Result::message_block (void) const
680 return this->implementation ()->message_block ();
683 ACE_HANDLE
684 ACE_Asynch_Accept::Result::listen_handle (void) const
686 return this->implementation ()->listen_handle ();
689 ACE_HANDLE
690 ACE_Asynch_Accept::Result::accept_handle (void) const
692 return this->implementation ()->accept_handle ();
695 ACE_Asynch_Accept::Result::Result (ACE_Asynch_Accept_Result_Impl *implementation)
696 : ACE_Asynch_Result (implementation),
697 implementation_ (implementation)
701 ACE_Asynch_Accept::Result::~Result (void)
703 // Proactor will delete the implementation when the <complete> call
704 // completes.
707 ACE_Asynch_Accept_Result_Impl *
708 ACE_Asynch_Accept::Result::implementation (void) const
710 return this->implementation_;
715 // *********************************************************************
717 ACE_Asynch_Connect::ACE_Asynch_Connect (void)
718 : implementation_ (0)
722 ACE_Asynch_Connect::~ACE_Asynch_Connect (void)
724 // Delete the implementation.
725 delete this->implementation_;
726 this->implementation_ = 0;
730 ACE_Asynch_Connect::open (ACE_Handler &handler,
731 ACE_HANDLE handle,
732 const void *completion_key,
733 ACE_Proactor *proactor)
735 // Get a proactor for/from the user.
736 proactor = this->get_proactor (proactor, handler);
738 // Now let us get the implementation initialized.
739 if ((this->implementation_ = proactor->create_asynch_connect ()) == 0)
740 return -1;
742 // Call the <open> method of the base class.
743 return ACE_Asynch_Operation::open (handler,
744 handle,
745 completion_key,
746 proactor);
750 ACE_Asynch_Connect::connect (ACE_HANDLE connect_handle,
751 const ACE_Addr & remote_sap,
752 const ACE_Addr & local_sap,
753 int reuse_addr,
754 const void *act,
755 int priority,
756 int signal_number)
758 if (0 == this->implementation_)
760 errno = EFAULT;
761 return -1;
763 return this->implementation_->connect (connect_handle,
764 remote_sap,
765 local_sap,
766 reuse_addr,
767 act,
768 priority,
769 signal_number);
772 ACE_Asynch_Operation_Impl *
773 ACE_Asynch_Connect::implementation (void) const
775 return this->implementation_;
778 // ************************************************************
780 ACE_Asynch_Connect::Result::Result (ACE_Asynch_Connect_Result_Impl *implementation)
781 : ACE_Asynch_Result (implementation),
782 implementation_ (implementation)
786 ACE_Asynch_Connect::Result::~Result (void)
788 // Proactor will delete the implementation when the <complete> call
789 // completes.
792 ACE_HANDLE
793 ACE_Asynch_Connect::Result::connect_handle (void) const
795 return this->implementation ()->connect_handle ();
799 ACE_Asynch_Connect_Result_Impl *
800 ACE_Asynch_Connect::Result::implementation (void) const
802 return this->implementation_;
805 // ************************************************************
807 ACE_Asynch_Transmit_File::ACE_Asynch_Transmit_File (void)
808 : implementation_ (0)
812 ACE_Asynch_Transmit_File::~ACE_Asynch_Transmit_File (void)
814 // Delete the implementation.
815 delete this->implementation_;
816 this->implementation_ = 0;
820 ACE_Asynch_Transmit_File::open (ACE_Handler &handler,
821 ACE_HANDLE handle,
822 const void *completion_key,
823 ACE_Proactor *proactor)
825 // Get a proactor for/from the user.
826 proactor = this->get_proactor (proactor, handler);
828 // Now let us get the implementation initialized.
829 if ((this->implementation_ = proactor->create_asynch_transmit_file ()) == 0)
830 return -1;
832 // Call the <open> method of the base class.
833 return ACE_Asynch_Operation::open (handler,
834 handle,
835 completion_key,
836 proactor);
840 ACE_Asynch_Transmit_File::transmit_file (ACE_HANDLE file,
841 Header_And_Trailer *header_and_trailer,
842 size_t bytes_to_write,
843 unsigned long offset,
844 unsigned long offset_high,
845 size_t bytes_per_send,
846 unsigned long flags,
847 const void *act,
848 int priority,
849 int signal_number)
851 if (0 == this->implementation_)
853 errno = EFAULT;
854 return -1;
856 return this->implementation_->transmit_file (file,
857 header_and_trailer,
858 bytes_to_write,
859 offset,
860 offset_high,
861 bytes_per_send,
862 flags,
863 act,
864 priority,
865 signal_number);
868 ACE_Asynch_Operation_Impl *
869 ACE_Asynch_Transmit_File::implementation (void) const
871 return this->implementation_;
874 // ****************************************************************************
876 ACE_HANDLE
877 ACE_Asynch_Transmit_File::Result::socket (void) const
879 return this->implementation ()->socket ();
882 ACE_HANDLE
883 ACE_Asynch_Transmit_File::Result::file (void) const
885 return this->implementation ()->file ();
888 ACE_Asynch_Transmit_File::Header_And_Trailer *
889 ACE_Asynch_Transmit_File::Result::header_and_trailer (void) const
891 return this->implementation ()->header_and_trailer ();
894 size_t
895 ACE_Asynch_Transmit_File::Result::bytes_to_write (void) const
897 return this->implementation ()->bytes_to_write ();
900 size_t
901 ACE_Asynch_Transmit_File::Result::bytes_per_send (void) const
903 return this->implementation ()->bytes_per_send ();
906 unsigned long
907 ACE_Asynch_Transmit_File::Result::flags (void) const
909 return this->implementation ()->flags ();
912 ACE_Asynch_Transmit_File::Result::Result (ACE_Asynch_Transmit_File_Result_Impl *implementation)
913 : ACE_Asynch_Result (implementation),
914 implementation_ (implementation)
918 ACE_Asynch_Transmit_File::Result::~Result (void)
922 ACE_Asynch_Transmit_File_Result_Impl *
923 ACE_Asynch_Transmit_File::Result::implementation (void) const
925 return this->implementation_;
928 // ************************************************************
930 ACE_Asynch_Transmit_File::Header_And_Trailer::Header_And_Trailer (ACE_Message_Block *header,
931 size_t header_bytes,
932 ACE_Message_Block *trailer,
933 size_t trailer_bytes)
934 : header_ (header),
935 header_bytes_ (header_bytes),
936 trailer_ (trailer),
937 trailer_bytes_ (trailer_bytes)
941 ACE_Asynch_Transmit_File::Header_And_Trailer::~Header_And_Trailer (void)
945 void
946 ACE_Asynch_Transmit_File::Header_And_Trailer::header_and_trailer (ACE_Message_Block *header,
947 size_t header_bytes,
948 ACE_Message_Block *trailer,
949 size_t trailer_bytes)
951 this->header (header);
952 this->header_bytes (header_bytes);
953 this->trailer (trailer);
954 this->trailer_bytes (trailer_bytes);
957 ACE_Message_Block *
958 ACE_Asynch_Transmit_File::Header_And_Trailer::header (void) const
960 return this->header_;
963 void
964 ACE_Asynch_Transmit_File::Header_And_Trailer::header (ACE_Message_Block *message_block)
966 this->header_ = message_block;
969 size_t
970 ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (void) const
972 return this->header_bytes_;
975 void
976 ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (size_t bytes)
978 this->header_bytes_ = bytes;
981 ACE_Message_Block *
982 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (void) const
984 return this->trailer_;
987 void
988 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (ACE_Message_Block *message_block)
990 this->trailer_ = message_block;
993 size_t
994 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (void) const
996 return this->trailer_bytes_;
999 void
1000 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (size_t bytes)
1002 this->trailer_bytes_ = bytes;
1005 ACE_LPTRANSMIT_FILE_BUFFERS
1006 ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void)
1008 // If both are zero, return zero
1009 if (this->header_ == 0 && this->trailer_ == 0)
1011 return 0;
1013 else
1015 // Something is valid
1017 // If header is valid, set the fields
1018 if (this->header_ != 0)
1020 this->transmit_buffers_.Head = this->header_->rd_ptr ();
1021 #if defined (ACE_WIN64) || defined (ACE_WIN32)
1022 this->transmit_buffers_.HeadLength =
1023 ACE_Utils::truncate_cast<DWORD> (this->header_bytes_);
1024 #else
1025 this->transmit_buffers_.HeadLength = this->header_bytes_;
1026 #endif /* ACE_WIN64 || ACE_WIN32 */
1028 else
1030 this->transmit_buffers_.Head = 0;
1031 this->transmit_buffers_.HeadLength = 0;
1034 // If trailer is valid, set the fields
1035 if (this->trailer_ != 0)
1037 this->transmit_buffers_.Tail = this->trailer_->rd_ptr ();
1038 #if defined(ACE_WIN64) || defined (ACE_WIN32)
1039 this->transmit_buffers_.TailLength =
1040 ACE_Utils::truncate_cast<DWORD> (this->trailer_bytes_);
1041 #else
1042 this->transmit_buffers_.TailLength = this->trailer_bytes_;
1043 #endif /* ACE_WIN64 || ACE_WIN32 */
1045 else
1047 this->transmit_buffers_.Tail = 0;
1048 this->transmit_buffers_.TailLength = 0;
1051 // Return the transmit buffers
1052 return &this->transmit_buffers_;
1056 // *********************************************************************
1058 ACE_Handler::ACE_Handler (void)
1059 : proactor_ (0), handle_ (ACE_INVALID_HANDLE)
1061 ACE_Handler::Proxy *p;
1062 ACE_NEW (p, ACE_Handler::Proxy (this));
1063 this->proxy_.reset (p);
1066 ACE_Handler::ACE_Handler (ACE_Proactor *d)
1067 : proactor_ (d), handle_ (ACE_INVALID_HANDLE)
1069 ACE_Handler::Proxy *p;
1070 ACE_NEW (p, ACE_Handler::Proxy (this));
1071 this->proxy_.reset (p);
1074 ACE_Handler::~ACE_Handler (void)
1076 ACE_Handler::Proxy *p = this->proxy_.get ();
1077 if (p)
1078 p->reset ();
1081 void
1082 ACE_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result & /* result */)
1086 void
1087 ACE_Handler::handle_write_stream (const ACE_Asynch_Write_Stream::Result & /* result */)
1091 void
1092 ACE_Handler::handle_write_dgram (const ACE_Asynch_Write_Dgram::Result & /* result */)
1096 void
1097 ACE_Handler::handle_read_dgram (const ACE_Asynch_Read_Dgram::Result & /* result */)
1101 void
1102 ACE_Handler::handle_accept (const ACE_Asynch_Accept::Result & /* result */)
1106 void
1107 ACE_Handler::handle_connect (const ACE_Asynch_Connect::Result & /* result */)
1111 void
1112 ACE_Handler::handle_transmit_file (const ACE_Asynch_Transmit_File::Result & /* result */)
1116 void
1117 ACE_Handler::handle_read_file (const ACE_Asynch_Read_File::Result & /* result */)
1121 void
1122 ACE_Handler::handle_write_file (const ACE_Asynch_Write_File::Result & /* result */)
1126 void
1127 ACE_Handler::handle_time_out (const ACE_Time_Value & /* tv */,
1128 const void * /* act */)
1132 void
1133 ACE_Handler::handle_wakeup (void)
1137 ACE_Proactor *
1138 ACE_Handler::proactor (void)
1140 return this->proactor_;
1143 void
1144 ACE_Handler::proactor (ACE_Proactor *p)
1146 this->proactor_ = p;
1149 ACE_HANDLE
1150 ACE_Handler::handle (void) const
1152 return this->handle_;
1155 void
1156 ACE_Handler::handle (ACE_HANDLE h)
1158 this->handle_ = h;
1161 ACE_Refcounted_Auto_Ptr<ACE_Handler::Proxy, ACE_SYNCH_MUTEX> &
1162 ACE_Handler::proxy (void)
1164 return this->proxy_;
1167 // ************************************************************
1169 ACE_Service_Handler::ACE_Service_Handler (void)
1173 ACE_Service_Handler::~ACE_Service_Handler (void)
1177 void
1178 ACE_Service_Handler::addresses (const ACE_INET_Addr & /* remote_address */,
1179 const ACE_INET_Addr & /* local_address */ )
1183 void
1184 ACE_Service_Handler::act (const void *)
1188 void
1189 ACE_Service_Handler::open (ACE_HANDLE,
1190 ACE_Message_Block &)
1195 // ************************************************************
1197 ACE_Asynch_Read_Dgram::ACE_Asynch_Read_Dgram (void)
1198 : implementation_ (0)
1202 ACE_Asynch_Read_Dgram::~ACE_Asynch_Read_Dgram (void)
1204 // Delete the implementation.
1205 delete this->implementation_;
1206 this->implementation_ = 0;
1210 ACE_Asynch_Read_Dgram::open (ACE_Handler &handler,
1211 ACE_HANDLE handle,
1212 const void *completion_key,
1213 ACE_Proactor *proactor)
1215 // Get a proactor for/from the user.
1216 proactor = this->get_proactor (proactor, handler);
1218 // Now let us get the implementation initialized.
1219 if ((this->implementation_ = proactor->create_asynch_read_dgram ()) == 0)
1220 return -1;
1222 // Call the <open> method of the base class.
1223 return ACE_Asynch_Operation::open (handler,
1224 handle,
1225 completion_key,
1226 proactor);
1229 ssize_t
1230 ACE_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block,
1231 size_t &number_of_bytes_recvd,
1232 int flags,
1233 int protocol_family,
1234 const void *act,
1235 int priority,
1236 int signal_number)
1238 if (0 == this->implementation_)
1240 errno = EFAULT;
1241 return -1;
1243 return this->implementation_->recv (message_block,
1244 number_of_bytes_recvd,
1245 flags,
1246 protocol_family,
1247 act,
1248 priority,
1249 signal_number);
1252 ACE_Asynch_Operation_Impl *
1253 ACE_Asynch_Read_Dgram::implementation (void) const
1255 return this->implementation_;
1258 // ************************************************************
1261 ACE_Asynch_Read_Dgram::Result::remote_address (ACE_Addr& addr) const
1263 return this->implementation ()->remote_address (addr);
1266 ACE_Message_Block*
1267 ACE_Asynch_Read_Dgram::Result::message_block (void) const
1269 return this->implementation ()->message_block ();
1273 ACE_Asynch_Read_Dgram::Result::flags (void) const
1275 return this->implementation ()->flags ();
1278 size_t
1279 ACE_Asynch_Read_Dgram::Result::bytes_to_read (void) const
1281 return this->implementation ()->bytes_to_read ();
1284 ACE_HANDLE
1285 ACE_Asynch_Read_Dgram::Result::handle (void) const
1287 return this->implementation ()->handle();
1290 ACE_Asynch_Read_Dgram::Result::Result (ACE_Asynch_Read_Dgram_Result_Impl *implementation)
1291 : ACE_Asynch_Result (implementation),
1292 implementation_ (implementation)
1296 ACE_Asynch_Read_Dgram::Result::~Result (void)
1300 ACE_Asynch_Read_Dgram_Result_Impl *
1301 ACE_Asynch_Read_Dgram::Result::implementation (void) const
1303 return this->implementation_;
1306 // ************************************************************
1309 ACE_Asynch_Write_Dgram::ACE_Asynch_Write_Dgram (void)
1310 : implementation_ (0)
1314 ACE_Asynch_Write_Dgram::~ACE_Asynch_Write_Dgram (void)
1316 // Delete the implementation.
1317 delete this->implementation_;
1318 this->implementation_ = 0;
1322 ACE_Asynch_Write_Dgram::open (ACE_Handler &handler,
1323 ACE_HANDLE handle,
1324 const void *completion_key,
1325 ACE_Proactor *proactor)
1327 // Get a proactor for/from the user.
1328 proactor = this->get_proactor (proactor, handler);
1330 // Now let us get the implementation initialized.
1331 if ((this->implementation_ = proactor->create_asynch_write_dgram ()) == 0)
1332 return -1;
1334 // Call the <open> method of the base class.
1335 return ACE_Asynch_Operation::open (handler,
1336 handle,
1337 completion_key,
1338 proactor);
1341 ssize_t
1342 ACE_Asynch_Write_Dgram::send (ACE_Message_Block *message_block,
1343 size_t &number_of_bytes_sent,
1344 int flags,
1345 const ACE_Addr& remote_addr,
1346 const void *act,
1347 int priority,
1348 int signal_number)
1350 if (0 == this->implementation_)
1352 errno = EFAULT;
1353 return -1;
1355 return this->implementation_->send (message_block,
1356 number_of_bytes_sent,
1357 flags,
1358 remote_addr,
1359 act,
1360 priority,
1361 signal_number);
1364 ACE_Asynch_Operation_Impl *
1365 ACE_Asynch_Write_Dgram::implementation (void) const
1367 return this->implementation_;
1370 // ************************************************************
1372 size_t
1373 ACE_Asynch_Write_Dgram::Result::bytes_to_write (void) const
1375 return this->implementation ()->bytes_to_write ();
1378 ACE_Message_Block*
1379 ACE_Asynch_Write_Dgram::Result::message_block () const
1381 return this->implementation ()->message_block ();
1385 ACE_Asynch_Write_Dgram::Result::flags (void) const
1387 return this->implementation ()->flags ();
1390 ACE_HANDLE
1391 ACE_Asynch_Write_Dgram::Result::handle (void) const
1393 return this->implementation ()->handle ();
1396 ACE_Asynch_Write_Dgram_Result_Impl *
1397 ACE_Asynch_Write_Dgram::Result::implementation (void) const
1399 return this->implementation_;
1402 ACE_Asynch_Write_Dgram::Result::Result (ACE_Asynch_Write_Dgram_Result_Impl *implementation)
1403 : ACE_Asynch_Result (implementation),
1404 implementation_ (implementation)
1408 ACE_Asynch_Write_Dgram::Result::~Result (void)
1412 ACE_END_VERSIONED_NAMESPACE_DECL
1414 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */