Asynch_IO.cpp

Go to the documentation of this file.
00001 // $Id: Asynch_IO.cpp 80826 2008-03-04 14:51:23Z wotte $
00002 
00003 #include "ace/Asynch_IO.h"
00004 
00005 ACE_RCSID(ace, Asynch_IO, "$Id: Asynch_IO.cpp 80826 2008-03-04 14:51:23Z wotte $")
00006 
00007 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO) || defined (ACE_HAS_AIO_CALLS)
00008 // This only works on platforms with Asynchronous IO
00009 
00010 #include "ace/Proactor.h"
00011 #include "ace/Message_Block.h"
00012 #include "ace/INET_Addr.h"
00013 #include "ace/Asynch_IO_Impl.h"
00014 #include "ace/os_include/os_errno.h"
00015 
00016 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00017 
00018 size_t
00019 ACE_Asynch_Result::bytes_transferred (void) const
00020 {
00021   return this->implementation ()->bytes_transferred ();
00022 }
00023 
00024 const void *
00025 ACE_Asynch_Result::act (void) const
00026 {
00027   return this->implementation ()->act ();
00028 }
00029 
00030 int
00031 ACE_Asynch_Result::success (void) const
00032 {
00033   return this->implementation ()->success ();
00034 }
00035 
00036 const void *
00037 ACE_Asynch_Result::completion_key (void) const
00038 {
00039   return this->implementation ()->completion_key ();
00040 }
00041 
00042 unsigned long
00043 ACE_Asynch_Result::error (void) const
00044 {
00045   return this->implementation ()->error ();
00046 }
00047 
00048 ACE_HANDLE
00049 ACE_Asynch_Result::event (void) const
00050 {
00051   return this->implementation ()->event ();
00052 }
00053 
00054 unsigned long
00055 ACE_Asynch_Result::offset (void) const
00056 {
00057   return this->implementation ()->offset ();
00058 }
00059 
00060 unsigned long
00061 ACE_Asynch_Result::offset_high (void) const
00062 {
00063   return this->implementation ()->offset_high ();
00064 }
00065 
00066 int
00067 ACE_Asynch_Result::priority (void) const
00068 {
00069   return this->implementation ()->priority ();
00070 }
00071 
00072 int
00073 ACE_Asynch_Result::signal_number (void) const
00074 {
00075   return this->implementation ()->signal_number ();
00076 }
00077 
00078 ACE_Asynch_Result::ACE_Asynch_Result (ACE_Asynch_Result_Impl *implementation)
00079   : implementation_ (implementation)
00080 {
00081 }
00082 
00083 ACE_Asynch_Result::~ACE_Asynch_Result (void)
00084 {
00085   // Proactor deletes the implementation when the <complete> finishes.
00086 }
00087 
00088 ACE_Asynch_Result_Impl *
00089 ACE_Asynch_Result::implementation (void) const
00090 {
00091   return this->implementation_;
00092 }
00093 
00094 // *********************************************************************
00095 
00096 int
00097 ACE_Asynch_Operation::open (ACE_Handler &handler,
00098                             ACE_HANDLE handle,
00099                             const void *completion_key,
00100                             ACE_Proactor *proactor)
00101 {
00102   return this->implementation ()->open (handler.proxy (),
00103                                         handle,
00104                                         completion_key,
00105                                         proactor);
00106 }
00107 
00108 int
00109 ACE_Asynch_Operation::cancel (void)
00110 {
00111   if (0 == this->implementation ())
00112     {
00113       errno = EFAULT;
00114       return -1;
00115     }
00116   return this->implementation ()->cancel ();
00117 }
00118 
00119 ACE_Proactor *
00120 ACE_Asynch_Operation::proactor (void) const
00121 {
00122   if (0 == this->implementation ())
00123     {
00124       errno = EFAULT;
00125       return 0;
00126     }
00127   return this->implementation ()->proactor ();
00128 }
00129 
00130 ACE_Asynch_Operation::ACE_Asynch_Operation (void)
00131 {
00132 }
00133 
00134 ACE_Asynch_Operation::~ACE_Asynch_Operation (void)
00135 {
00136 }
00137 
00138 ACE_Proactor *
00139 ACE_Asynch_Operation::get_proactor (ACE_Proactor *user_proactor,
00140                                     ACE_Handler &handler) const
00141 {
00142   if (user_proactor == 0)
00143     {
00144       // Grab the singleton proactor if <handler->proactor> is zero
00145       user_proactor = handler.proactor ();
00146       if (user_proactor == 0)
00147         user_proactor = ACE_Proactor::instance ();
00148     }
00149 
00150   return user_proactor;
00151 }
00152 
00153 // ************************************************************
00154 
00155 ACE_Asynch_Read_Stream::ACE_Asynch_Read_Stream (void)
00156   : implementation_ (0)
00157 {
00158 }
00159 
00160 ACE_Asynch_Read_Stream::~ACE_Asynch_Read_Stream (void)
00161 {
00162   // Delete the implementation.
00163   delete this->implementation_;
00164   this->implementation_ = 0;
00165 }
00166 
00167 int
00168 ACE_Asynch_Read_Stream::open (ACE_Handler &handler,
00169                               ACE_HANDLE handle,
00170                               const void *completion_key,
00171                               ACE_Proactor *proactor)
00172 {
00173   // Get a proactor for/from the user.
00174   proactor = this->get_proactor (proactor, handler);
00175 
00176   // Now let us get the implementation initialized.
00177   if ((this->implementation_ = proactor->create_asynch_read_stream ()) == 0)
00178     return -1;
00179 
00180   // Call the <open> method of the base class.
00181   return ACE_Asynch_Operation::open (handler,
00182                                      handle,
00183                                      completion_key,
00184                                      proactor);
00185 }
00186 
00187 int
00188 ACE_Asynch_Read_Stream::read (ACE_Message_Block &message_block,
00189                               size_t bytes_to_read,
00190                               const void *act,
00191                               int priority,
00192                               int signal_number)
00193 {
00194   if (0 == this->implementation_)
00195     {
00196       errno = EFAULT;
00197       return -1;
00198     }
00199   return this->implementation_->read (message_block,
00200                                       bytes_to_read,
00201                                       act,
00202                                       priority,
00203                                       signal_number);
00204 }
00205 
00206 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
00207 int
00208 ACE_Asynch_Read_Stream::readv (ACE_Message_Block &message_block,
00209                                size_t bytes_to_read,
00210                                const void *act,
00211                                int priority,
00212                                int signal_number)
00213 {
00214   if (0 == this->implementation_)
00215     {
00216       errno = EFAULT;
00217       return -1;
00218     }
00219   return this->implementation_->readv (message_block,
00220                                        bytes_to_read,
00221                                        act,
00222                                        priority,
00223                                        signal_number);
00224 }
00225 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
00226 
00227 ACE_Asynch_Operation_Impl *
00228 ACE_Asynch_Read_Stream::implementation (void) const
00229 {
00230   return this->implementation_;
00231 }
00232 
00233 // ************************************************************
00234 
00235 size_t
00236 ACE_Asynch_Read_Stream::Result::bytes_to_read (void) const
00237 {
00238   return this->implementation ()->bytes_to_read ();
00239 }
00240 
00241 ACE_Message_Block &
00242 ACE_Asynch_Read_Stream::Result::message_block (void) const
00243 {
00244   return this->implementation ()->message_block ();
00245 }
00246 
00247 ACE_HANDLE
00248 ACE_Asynch_Read_Stream::Result::handle (void) const
00249 {
00250   return this->implementation ()->handle ();
00251 }
00252 
00253 ACE_Asynch_Read_Stream::Result::Result (ACE_Asynch_Read_Stream_Result_Impl *implementation)
00254   : ACE_Asynch_Result (implementation),
00255     implementation_ (implementation)
00256 {
00257 }
00258 
00259 ACE_Asynch_Read_Stream::Result::~Result (void)
00260 {
00261   // Proactor will delete the implementation after <complete> is
00262   // finished.
00263 }
00264 
00265 ACE_Asynch_Read_Stream_Result_Impl *
00266 ACE_Asynch_Read_Stream::Result::implementation (void) const
00267 {
00268   return this->implementation_;
00269 }
00270 
00271 // ***************************************************
00272 
00273 ACE_Asynch_Write_Stream::ACE_Asynch_Write_Stream (void)
00274   : implementation_ (0)
00275 {
00276 }
00277 
00278 ACE_Asynch_Write_Stream::~ACE_Asynch_Write_Stream (void)
00279 {
00280   // Delete the implementation.
00281   delete this->implementation_;
00282   this->implementation_ = 0;
00283 }
00284 
00285 int
00286 ACE_Asynch_Write_Stream::open (ACE_Handler &handler,
00287                                ACE_HANDLE handle,
00288                                const void *completion_key,
00289                                ACE_Proactor *proactor)
00290 {
00291   // Get a proactor for/from the user.
00292   proactor = this->get_proactor (proactor, handler);
00293 
00294   // Now let us get the implementation initialized.
00295   if ((this->implementation_ = proactor->create_asynch_write_stream ()) == 0)
00296     return -1;
00297 
00298   // Call the <open> method of the base class.
00299   return ACE_Asynch_Operation::open (handler,
00300                                      handle,
00301                                      completion_key,
00302                                      proactor);
00303 }
00304 
00305 int
00306 ACE_Asynch_Write_Stream::write (ACE_Message_Block &message_block,
00307                                 size_t bytes_to_write,
00308                                 const void *act,
00309                                 int priority,
00310                                 int signal_number)
00311 {
00312   if (0 == this->implementation_)
00313     {
00314       errno = EFAULT;
00315       return -1;
00316     }
00317   return this->implementation_->write (message_block,
00318                                        bytes_to_write,
00319                                        act,
00320                                        priority,
00321                                        signal_number);
00322 }
00323 
00324 #if defined (ACE_HAS_WIN32_OVERLAPPED_IO)
00325 int
00326 ACE_Asynch_Write_Stream::writev (ACE_Message_Block &message_block,
00327                                  size_t bytes_to_write,
00328                                  const void *act,
00329                                  int priority,
00330                                  int signal_number)
00331 {
00332   if (0 == this->implementation_)
00333     {
00334       errno = EFAULT;
00335       return -1;
00336     }
00337   return this->implementation_->writev (message_block,
00338                                         bytes_to_write,
00339                                         act,
00340                                         priority,
00341                                         signal_number);
00342 }
00343 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO */
00344 
00345 ACE_Asynch_Operation_Impl *
00346 ACE_Asynch_Write_Stream::implementation (void) const
00347 {
00348   return this->implementation_;
00349 }
00350 
00351 // ************************************************************
00352 
00353 size_t
00354 ACE_Asynch_Write_Stream::Result::bytes_to_write (void) const
00355 {
00356   return this->implementation ()->bytes_to_write ();
00357 }
00358 
00359 ACE_Message_Block &
00360 ACE_Asynch_Write_Stream::Result::message_block (void) const
00361 {
00362   return this->implementation ()->message_block ();
00363 }
00364 
00365 ACE_HANDLE
00366 ACE_Asynch_Write_Stream::Result::handle (void) const
00367 {
00368   return this->implementation ()->handle ();
00369 }
00370 
00371 ACE_Asynch_Write_Stream::Result::Result (ACE_Asynch_Write_Stream_Result_Impl *implementation)
00372   : ACE_Asynch_Result (implementation),
00373     implementation_ (implementation)
00374 {
00375 }
00376 
00377 ACE_Asynch_Write_Stream::Result::~Result (void)
00378 {
00379   // Proactor will delte the implementation when the <complete> call
00380   // finishes.
00381 }
00382 
00383 ACE_Asynch_Write_Stream_Result_Impl *
00384 ACE_Asynch_Write_Stream::Result::implementation (void) const
00385 {
00386   return this->implementation_;
00387 }
00388 
00389 // ************************************************************
00390 
00391 ACE_Asynch_Read_File::ACE_Asynch_Read_File (void)
00392   : implementation_ (0)
00393 {
00394 }
00395 
00396 ACE_Asynch_Read_File::~ACE_Asynch_Read_File (void)
00397 {
00398   // Delete the implementation.
00399   delete this->implementation_;
00400   this->implementation_ = 0;
00401 }
00402 
00403 int
00404 ACE_Asynch_Read_File::open (ACE_Handler &handler,
00405                             ACE_HANDLE handle,
00406                             const void *completion_key,
00407                             ACE_Proactor *proactor)
00408 {
00409   // Get a proactor for/from the user.
00410   proactor = this->get_proactor (proactor, handler);
00411 
00412   // Now let us get the implementation initialized.
00413   if ((this->implementation_ = proactor->create_asynch_read_file ()) == 0)
00414     return -1;
00415 
00416   // Call the <open> method of the base class.
00417   return ACE_Asynch_Operation::open (handler,
00418                                      handle,
00419                                      completion_key,
00420                                      proactor);
00421 }
00422 
00423 int
00424 ACE_Asynch_Read_File::read (ACE_Message_Block &message_block,
00425                             size_t bytes_to_read,
00426                             unsigned long offset,
00427                             unsigned long offset_high,
00428                             const void *act,
00429                             int priority,
00430                             int signal_number)
00431 {
00432   if (0 == this->implementation_)
00433     {
00434       errno = EFAULT;
00435       return -1;
00436     }
00437   return this->implementation_->read (message_block,
00438                                       bytes_to_read,
00439                                       offset,
00440                                       offset_high,
00441                                       act,
00442                                       priority,
00443                                       signal_number);
00444 }
00445 
00446 #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
00447 int
00448 ACE_Asynch_Read_File::readv (ACE_Message_Block &message_block,
00449                              size_t bytes_to_read,
00450                              unsigned long offset,
00451                              unsigned long offset_high,
00452                              const void *act,
00453                              int priority,
00454                              int signal_number)
00455 {
00456   if (0 == this->implementation_)
00457     {
00458       errno = EFAULT;
00459       return -1;
00460     }
00461   return this->implementation_->readv (message_block,
00462                                        bytes_to_read,
00463                                        offset,
00464                                        offset_high,
00465                                        act,
00466                                        priority,
00467                                        signal_number);
00468 }
00469 #endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
00470 
00471 ACE_Asynch_Operation_Impl *
00472 ACE_Asynch_Read_File::implementation (void) const
00473 {
00474   return this->implementation_;
00475 }
00476 
00477 // ************************************************************
00478 
00479 ACE_Asynch_Read_File::Result::Result (ACE_Asynch_Read_File_Result_Impl *implementation)
00480   : ACE_Asynch_Read_Stream::Result (implementation),
00481     implementation_ (implementation)
00482 {
00483 }
00484 
00485 ACE_Asynch_Read_File::Result::~Result (void)
00486 {
00487   // Proactor will delete the implementation when <complete> call
00488   // completes.
00489 }
00490 
00491 ACE_Asynch_Read_File_Result_Impl *
00492 ACE_Asynch_Read_File::Result::implementation (void) const
00493 {
00494   return this->implementation_;
00495 }
00496 
00497 // ************************************************************
00498 
00499 ACE_Asynch_Write_File::ACE_Asynch_Write_File (void)
00500   : implementation_ (0)
00501 {
00502 }
00503 
00504 ACE_Asynch_Write_File::~ACE_Asynch_Write_File (void)
00505 {
00506   // Delete the implementation.
00507   delete this->implementation_;
00508   this->implementation_ = 0;
00509 }
00510 
00511 int
00512 ACE_Asynch_Write_File::open (ACE_Handler &handler,
00513                              ACE_HANDLE handle,
00514                              const void *completion_key,
00515                              ACE_Proactor *proactor)
00516 {
00517   // Get a proactor for/from the user.
00518   proactor = this->get_proactor (proactor, handler);
00519 
00520   // Now let us get the implementation initialized.
00521   if ((this->implementation_ = proactor->create_asynch_write_file ()) == 0)
00522     return -1;
00523 
00524   // Call the <open> method of the base class.
00525   return ACE_Asynch_Operation::open (handler,
00526                                      handle,
00527                                      completion_key,
00528                                      proactor);
00529 }
00530 
00531 int
00532 ACE_Asynch_Write_File::write (ACE_Message_Block &message_block,
00533                               size_t bytes_to_write,
00534                               unsigned long offset,
00535                               unsigned long offset_high,
00536                               const void *act,
00537                               int priority,
00538                               int signal_number)
00539 {
00540   if (0 == this->implementation_)
00541     {
00542       errno = EFAULT;
00543       return -1;
00544     }
00545   return this->implementation_->write (message_block,
00546                                        bytes_to_write,
00547                                        offset,
00548                                        offset_high,
00549                                        act,
00550                                        priority,
00551                                        signal_number);
00552 }
00553 
00554 #if (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
00555 int
00556 ACE_Asynch_Write_File::writev (ACE_Message_Block &message_block,
00557                                size_t bytes_to_write,
00558                                unsigned long offset,
00559                                unsigned long offset_high,
00560                                const void *act,
00561                                int priority,
00562                                int signal_number)
00563 {
00564   if (0 == this->implementation_)
00565     {
00566       errno = EFAULT;
00567       return -1;
00568     }
00569   return this->implementation_->writev (message_block,
00570                                         bytes_to_write,
00571                                         offset,
00572                                         offset_high,
00573                                         act,
00574                                         priority,
00575                                         signal_number);
00576 }
00577 #endif /* (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) */
00578 
00579 ACE_Asynch_Operation_Impl *
00580 ACE_Asynch_Write_File::implementation (void) const
00581 {
00582   return this->implementation_;
00583 }
00584 
00585 // ************************************************************
00586 
00587 ACE_Asynch_Write_File::Result::Result (ACE_Asynch_Write_File_Result_Impl *implementation)
00588   : ACE_Asynch_Write_Stream::Result (implementation),
00589     implementation_ (implementation)
00590 {
00591 }
00592 
00593 ACE_Asynch_Write_File::Result::~Result (void)
00594 {
00595   // Proactor will delete the implementation when the <complete> call
00596   // completes.
00597 }
00598 
00599 ACE_Asynch_Write_File_Result_Impl *
00600 ACE_Asynch_Write_File::Result::implementation (void) const
00601 {
00602   return this->implementation_;
00603 }
00604 
00605 // *********************************************************************
00606 
00607 ACE_Asynch_Accept::ACE_Asynch_Accept (void)
00608   : implementation_ (0)
00609 {
00610 }
00611 
00612 ACE_Asynch_Accept::~ACE_Asynch_Accept (void)
00613 {
00614   // Delete the implementation.
00615   delete this->implementation_;
00616   this->implementation_ = 0;
00617 }
00618 
00619 int
00620 ACE_Asynch_Accept::open (ACE_Handler &handler,
00621                          ACE_HANDLE handle,
00622                          const void *completion_key,
00623                          ACE_Proactor *proactor)
00624 {
00625   // Get a proactor for/from the user.
00626   proactor = this->get_proactor (proactor, handler);
00627 
00628   // Now let us get the implementation initialized.
00629   if ((this->implementation_ = proactor->create_asynch_accept ()) == 0)
00630     return -1;
00631 
00632   // Call the <open> method of the base class.
00633   return ACE_Asynch_Operation::open (handler,
00634                                      handle,
00635                                      completion_key,
00636                                      proactor);
00637 }
00638 
00639 int
00640 ACE_Asynch_Accept::accept (ACE_Message_Block &message_block,
00641                            size_t bytes_to_read,
00642                            ACE_HANDLE accept_handle,
00643                            const void *act,
00644                            int priority,
00645                            int signal_number,
00646                            int addr_family)
00647 {
00648   if (0 == this->implementation_)
00649     {
00650       errno = EFAULT;
00651       return -1;
00652     }
00653   return this->implementation_->accept (message_block,
00654                                         bytes_to_read,
00655                                         accept_handle,
00656                                         act,
00657                                         priority,
00658                                         signal_number,
00659                                         addr_family);
00660 }
00661 
00662 ACE_Asynch_Operation_Impl *
00663 ACE_Asynch_Accept::implementation (void)  const
00664 {
00665   return this->implementation_;
00666 }
00667 
00668 // ************************************************************
00669 
00670 size_t
00671 ACE_Asynch_Accept::Result::bytes_to_read (void) const
00672 {
00673   return this->implementation ()->bytes_to_read ();
00674 }
00675 
00676 ACE_Message_Block &
00677 ACE_Asynch_Accept::Result::message_block (void) const
00678 {
00679   return this->implementation ()->message_block ();
00680 }
00681 
00682 ACE_HANDLE
00683 ACE_Asynch_Accept::Result::listen_handle (void) const
00684 {
00685   return this->implementation ()->listen_handle ();
00686 }
00687 
00688 ACE_HANDLE
00689 ACE_Asynch_Accept::Result::accept_handle (void) const
00690 {
00691   return this->implementation ()->accept_handle ();
00692 }
00693 
00694 ACE_Asynch_Accept::Result::Result (ACE_Asynch_Accept_Result_Impl *implementation)
00695   : ACE_Asynch_Result (implementation),
00696     implementation_ (implementation)
00697 {
00698 }
00699 
00700 ACE_Asynch_Accept::Result::~Result (void)
00701 {
00702   // Proactor will delete the implementation when the <complete> call
00703   // completes.
00704 }
00705 
00706 ACE_Asynch_Accept_Result_Impl *
00707 ACE_Asynch_Accept::Result::implementation (void) const
00708 {
00709   return this->implementation_;
00710 }
00711 
00712 
00713 
00714 // *********************************************************************
00715 
00716 ACE_Asynch_Connect::ACE_Asynch_Connect (void)
00717   : implementation_ (0)
00718 {
00719 }
00720 
00721 ACE_Asynch_Connect::~ACE_Asynch_Connect (void)
00722 {
00723   // Delete the implementation.
00724   delete this->implementation_;
00725   this->implementation_ = 0;
00726 }
00727 
00728 int
00729 ACE_Asynch_Connect::open (ACE_Handler &handler,
00730                           ACE_HANDLE handle,
00731                           const void *completion_key,
00732                           ACE_Proactor *proactor)
00733 {
00734   // Get a proactor for/from the user.
00735   proactor = this->get_proactor (proactor, handler);
00736 
00737   // Now let us get the implementation initialized.
00738   if ((this->implementation_ = proactor->create_asynch_connect ()) == 0)
00739     return -1;
00740 
00741   // Call the <open> method of the base class.
00742   return ACE_Asynch_Operation::open (handler,
00743                                      handle,
00744                                      completion_key,
00745                                      proactor);
00746 }
00747 
00748 int
00749 ACE_Asynch_Connect::connect (ACE_HANDLE connect_handle,
00750                              const ACE_Addr & remote_sap,
00751                              const ACE_Addr & local_sap,
00752                              int  reuse_addr,
00753                              const void *act,
00754                              int priority,
00755                              int signal_number)
00756 {
00757   if (0 == this->implementation_)
00758     {
00759       errno = EFAULT;
00760       return -1;
00761     }
00762   return this->implementation_->connect (connect_handle,
00763                                          remote_sap,
00764                                          local_sap,
00765                                          reuse_addr,
00766                                          act,
00767                                          priority,
00768                                          signal_number);
00769 }
00770 
00771 ACE_Asynch_Operation_Impl *
00772 ACE_Asynch_Connect::implementation (void)  const
00773 {
00774   return this->implementation_;
00775 }
00776 
00777 // ************************************************************
00778 
00779 ACE_Asynch_Connect::Result::Result (ACE_Asynch_Connect_Result_Impl *implementation)
00780   : ACE_Asynch_Result (implementation),
00781     implementation_ (implementation)
00782 {
00783 }
00784 
00785 ACE_Asynch_Connect::Result::~Result (void)
00786 {
00787   // Proactor will delete the implementation when the <complete> call
00788   // completes.
00789 }
00790 
00791 ACE_HANDLE
00792 ACE_Asynch_Connect::Result::connect_handle (void) const
00793 {
00794   return this->implementation ()->connect_handle ();
00795 }
00796 
00797 
00798 ACE_Asynch_Connect_Result_Impl *
00799 ACE_Asynch_Connect::Result::implementation (void) const
00800 {
00801   return this->implementation_;
00802 }
00803 
00804 // ************************************************************
00805 
00806 ACE_Asynch_Transmit_File::ACE_Asynch_Transmit_File (void)
00807   : implementation_ (0)
00808 {
00809 }
00810 
00811 ACE_Asynch_Transmit_File::~ACE_Asynch_Transmit_File (void)
00812 {
00813   // Delete the implementation.
00814   delete this->implementation_;
00815   this->implementation_ = 0;
00816 }
00817 
00818 int
00819 ACE_Asynch_Transmit_File::open (ACE_Handler &handler,
00820                                 ACE_HANDLE handle,
00821                                 const void *completion_key,
00822                                 ACE_Proactor *proactor)
00823 {
00824   // Get a proactor for/from the user.
00825   proactor = this->get_proactor (proactor, handler);
00826 
00827   // Now let us get the implementation initialized.
00828   if ((this->implementation_ = proactor->create_asynch_transmit_file ()) == 0)
00829     return -1;
00830 
00831   // Call the <open> method of the base class.
00832   return ACE_Asynch_Operation::open (handler,
00833                                      handle,
00834                                      completion_key,
00835                                      proactor);
00836 }
00837 
00838 int
00839 ACE_Asynch_Transmit_File::transmit_file (ACE_HANDLE file,
00840                                          Header_And_Trailer *header_and_trailer,
00841                                          size_t bytes_to_write,
00842                                          unsigned long offset,
00843                                          unsigned long offset_high,
00844                                          size_t bytes_per_send,
00845                                          unsigned long flags,
00846                                          const void *act,
00847                                          int priority,
00848                                          int signal_number)
00849 {
00850   if (0 == this->implementation_)
00851     {
00852       errno = EFAULT;
00853       return -1;
00854     }
00855   return this->implementation_->transmit_file (file,
00856                                                header_and_trailer,
00857                                                bytes_to_write,
00858                                                offset,
00859                                                offset_high,
00860                                                bytes_per_send,
00861                                                flags,
00862                                                act,
00863                                                priority,
00864                                                signal_number);
00865 }
00866 
00867 ACE_Asynch_Operation_Impl *
00868 ACE_Asynch_Transmit_File::implementation (void) const
00869 {
00870   return this->implementation_;
00871 }
00872 
00873 // ****************************************************************************
00874 
00875 ACE_HANDLE
00876 ACE_Asynch_Transmit_File::Result::socket (void) const
00877 {
00878   return this->implementation ()->socket ();
00879 }
00880 
00881 ACE_HANDLE
00882 ACE_Asynch_Transmit_File::Result::file (void) const
00883 {
00884   return this->implementation ()->file ();
00885 }
00886 
00887 ACE_Asynch_Transmit_File::Header_And_Trailer *
00888 ACE_Asynch_Transmit_File::Result::header_and_trailer (void) const
00889 {
00890   return this->implementation ()->header_and_trailer ();
00891 }
00892 
00893 size_t
00894 ACE_Asynch_Transmit_File::Result::bytes_to_write (void) const
00895 {
00896   return this->implementation ()->bytes_to_write ();
00897 }
00898 
00899 size_t
00900 ACE_Asynch_Transmit_File::Result::bytes_per_send (void) const
00901 {
00902   return this->implementation ()->bytes_per_send ();
00903 }
00904 
00905 unsigned long
00906 ACE_Asynch_Transmit_File::Result::flags (void) const
00907 {
00908   return this->implementation ()->flags ();
00909 }
00910 
00911 ACE_Asynch_Transmit_File::Result::Result (ACE_Asynch_Transmit_File_Result_Impl *implementation)
00912   : ACE_Asynch_Result (implementation),
00913     implementation_ (implementation)
00914 {
00915 }
00916 
00917 ACE_Asynch_Transmit_File::Result::~Result (void)
00918 {
00919 }
00920 
00921 ACE_Asynch_Transmit_File_Result_Impl *
00922 ACE_Asynch_Transmit_File::Result::implementation (void) const
00923 {
00924   return this->implementation_;
00925 }
00926 
00927 // ************************************************************
00928 
00929 ACE_Asynch_Transmit_File::Header_And_Trailer::Header_And_Trailer (ACE_Message_Block *header,
00930                                                                   size_t header_bytes,
00931                                                                   ACE_Message_Block *trailer,
00932                                                                   size_t trailer_bytes)
00933   : header_ (header),
00934     header_bytes_ (header_bytes),
00935     trailer_ (trailer),
00936     trailer_bytes_ (trailer_bytes)
00937 {
00938 }
00939 
00940 ACE_Asynch_Transmit_File::Header_And_Trailer::~Header_And_Trailer (void)
00941 {
00942 }
00943 
00944 void
00945 ACE_Asynch_Transmit_File::Header_And_Trailer::header_and_trailer (ACE_Message_Block *header,
00946                                                                   size_t header_bytes,
00947                                                                   ACE_Message_Block *trailer,
00948                                                                   size_t trailer_bytes)
00949 {
00950   this->header (header);
00951   this->header_bytes (header_bytes);
00952   this->trailer (trailer);
00953   this->trailer_bytes (trailer_bytes);
00954 }
00955 
00956 ACE_Message_Block *
00957 ACE_Asynch_Transmit_File::Header_And_Trailer::header (void) const
00958 {
00959   return this->header_;
00960 }
00961 
00962 void
00963 ACE_Asynch_Transmit_File::Header_And_Trailer::header (ACE_Message_Block *message_block)
00964 {
00965   this->header_ = message_block;
00966 }
00967 
00968 size_t
00969 ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (void) const
00970 {
00971   return this->header_bytes_;
00972 }
00973 
00974 void
00975 ACE_Asynch_Transmit_File::Header_And_Trailer::header_bytes (size_t bytes)
00976 {
00977   this->header_bytes_ = bytes;
00978 }
00979 
00980 ACE_Message_Block *
00981 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (void) const
00982 {
00983   return this->trailer_;
00984 }
00985 
00986 void
00987 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer (ACE_Message_Block *message_block)
00988 {
00989   this->trailer_ = message_block;
00990 }
00991 
00992 size_t
00993 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (void) const
00994 {
00995   return this->trailer_bytes_;
00996 }
00997 
00998 void
00999 ACE_Asynch_Transmit_File::Header_And_Trailer::trailer_bytes (size_t bytes)
01000 {
01001   this->trailer_bytes_ = bytes;
01002 }
01003 
01004 ACE_LPTRANSMIT_FILE_BUFFERS
01005 ACE_Asynch_Transmit_File::Header_And_Trailer::transmit_buffers (void)
01006 {
01007   // If both are zero, return zero
01008   if (this->header_ == 0 && this->trailer_ == 0)
01009     return 0;
01010   else
01011     {
01012       // Something is valid
01013 
01014       // If header is valid, set the fields
01015       if (this->header_ != 0)
01016         {
01017           this->transmit_buffers_.Head = this->header_->rd_ptr ();
01018 #if defined(ACE_WIN64)
01019           this->transmit_buffers_.HeadLength =
01020             static_cast<DWORD> (this->header_bytes_);
01021 #else
01022           this->transmit_buffers_.HeadLength = this->header_bytes_;
01023 #endif /* ACE_WIN64 */
01024         }
01025       else
01026         {
01027           this->transmit_buffers_.Head = 0;
01028           this->transmit_buffers_.HeadLength = 0;
01029         }
01030 
01031       // If trailer is valid, set the fields
01032       if (this->trailer_ != 0)
01033         {
01034           this->transmit_buffers_.Tail = this->trailer_->rd_ptr ();
01035 #if defined(ACE_WIN64)
01036           this->transmit_buffers_.TailLength =
01037             static_cast<DWORD> (this->trailer_bytes_);
01038 #else
01039           this->transmit_buffers_.TailLength = this->trailer_bytes_;
01040 #endif /* ACE_WIN64 */
01041         }
01042       else
01043         {
01044           this->transmit_buffers_.Tail = 0;
01045           this->transmit_buffers_.TailLength = 0;
01046         }
01047 
01048       // Return the transmit buffers
01049       return &this->transmit_buffers_;
01050     }
01051 }
01052 
01053 // *********************************************************************
01054 
01055 ACE_Handler::ACE_Handler (void)
01056   : proactor_ (0), handle_ (ACE_INVALID_HANDLE)
01057 {
01058   ACE_Handler::Proxy *p;
01059   ACE_NEW (p, ACE_Handler::Proxy (this));
01060   this->proxy_.reset (p);
01061 }
01062 
01063 ACE_Handler::ACE_Handler (ACE_Proactor *d)
01064   : proactor_ (d), handle_ (ACE_INVALID_HANDLE)
01065 {
01066   ACE_Handler::Proxy *p;
01067   ACE_NEW (p, ACE_Handler::Proxy (this));
01068   this->proxy_.reset (p);
01069 }
01070 
01071 ACE_Handler::~ACE_Handler (void)
01072 {
01073   ACE_Handler::Proxy *p = this->proxy_.get ();
01074   if (p)
01075     p->reset ();
01076 }
01077 
01078 void
01079 ACE_Handler::handle_read_stream (const ACE_Asynch_Read_Stream::Result & /* result */)
01080 {
01081 }
01082 
01083 void
01084 ACE_Handler::handle_write_stream (const ACE_Asynch_Write_Stream::Result & /* result */)
01085 {
01086 }
01087 
01088 void
01089 ACE_Handler::handle_write_dgram (const ACE_Asynch_Write_Dgram::Result & /* result */)
01090 {
01091 }
01092 
01093 void
01094 ACE_Handler::handle_read_dgram (const ACE_Asynch_Read_Dgram::Result & /* result */)
01095 {
01096 }
01097 
01098 void
01099 ACE_Handler::handle_accept (const ACE_Asynch_Accept::Result & /* result */)
01100 {
01101 }
01102 
01103 void
01104 ACE_Handler::handle_connect (const ACE_Asynch_Connect::Result & /* result */)
01105 {
01106 }
01107 
01108 void
01109 ACE_Handler::handle_transmit_file (const ACE_Asynch_Transmit_File::Result & /* result */)
01110 {
01111 }
01112 
01113 void
01114 ACE_Handler::handle_read_file (const ACE_Asynch_Read_File::Result & /* result */)
01115 {
01116 }
01117 
01118 void
01119 ACE_Handler::handle_write_file (const ACE_Asynch_Write_File::Result & /* result */)
01120 {
01121 }
01122 
01123 void
01124 ACE_Handler::handle_time_out (const ACE_Time_Value & /* tv */,
01125                               const void *           /* act */)
01126 {
01127 }
01128 
01129 void
01130 ACE_Handler::handle_wakeup (void)
01131 {
01132 }
01133 
01134 ACE_Proactor *
01135 ACE_Handler::proactor (void)
01136 {
01137   return this->proactor_;
01138 }
01139 
01140 void
01141 ACE_Handler::proactor (ACE_Proactor *p)
01142 {
01143   this->proactor_ = p;
01144 }
01145 
01146 ACE_HANDLE
01147 ACE_Handler::handle (void) const
01148 {
01149   return this->handle_;
01150 }
01151 
01152 void
01153 ACE_Handler::handle (ACE_HANDLE h)
01154 {
01155   this->handle_ = h;
01156 }
01157 
01158 ACE_Refcounted_Auto_Ptr<ACE_Handler::Proxy, ACE_SYNCH_MUTEX> &
01159 ACE_Handler::proxy (void)
01160 {
01161   return this->proxy_;
01162 }
01163 
01164 // ************************************************************
01165 
01166 ACE_Service_Handler::ACE_Service_Handler (void)
01167 {
01168 }
01169 
01170 ACE_Service_Handler::~ACE_Service_Handler (void)
01171 {
01172 }
01173 
01174 void
01175 ACE_Service_Handler::addresses (const ACE_INET_Addr & /* remote_address */,
01176                                 const ACE_INET_Addr & /* local_address */ )
01177 {
01178 }
01179 
01180 void
01181 ACE_Service_Handler::act (const void *)
01182 {
01183 }
01184 
01185 void
01186 ACE_Service_Handler::open (ACE_HANDLE,
01187                            ACE_Message_Block &)
01188 {
01189 }
01190 
01191 
01192 // ************************************************************
01193 
01194 ACE_Asynch_Read_Dgram::ACE_Asynch_Read_Dgram (void)
01195   : implementation_ (0)
01196 {
01197 }
01198 
01199 ACE_Asynch_Read_Dgram::~ACE_Asynch_Read_Dgram (void)
01200 {
01201   // Delete the implementation.
01202   delete this->implementation_;
01203   this->implementation_ = 0;
01204 }
01205 
01206 int
01207 ACE_Asynch_Read_Dgram::open (ACE_Handler &handler,
01208                              ACE_HANDLE handle,
01209                              const void *completion_key,
01210                              ACE_Proactor *proactor)
01211 {
01212   // Get a proactor for/from the user.
01213   proactor = this->get_proactor (proactor, handler);
01214 
01215   // Now let us get the implementation initialized.
01216   if ((this->implementation_ = proactor->create_asynch_read_dgram ()) == 0)
01217     return -1;
01218 
01219   // Call the <open> method of the base class.
01220   return ACE_Asynch_Operation::open (handler,
01221                                      handle,
01222                                      completion_key,
01223                                      proactor);
01224 }
01225 
01226 ssize_t
01227 ACE_Asynch_Read_Dgram::recv (ACE_Message_Block *message_block,
01228                              size_t &number_of_bytes_recvd,
01229                              int flags,
01230                              int protocol_family,
01231                              const void *act,
01232                              int priority,
01233                              int signal_number)
01234 {
01235   if (0 == this->implementation_)
01236     {
01237       errno = EFAULT;
01238       return -1;
01239     }
01240   return this->implementation_->recv (message_block,
01241                                       number_of_bytes_recvd,
01242                                       flags,
01243                                       protocol_family,
01244                                       act,
01245                                       priority,
01246                                       signal_number);
01247 }
01248 
01249 ACE_Asynch_Operation_Impl *
01250 ACE_Asynch_Read_Dgram::implementation (void) const
01251 {
01252   return this->implementation_;
01253 }
01254 
01255 // ************************************************************
01256 
01257 int
01258 ACE_Asynch_Read_Dgram::Result::remote_address (ACE_Addr& addr) const
01259 {
01260   return this->implementation ()->remote_address (addr);
01261 }
01262 
01263 ACE_Message_Block*
01264 ACE_Asynch_Read_Dgram::Result::message_block (void) const
01265 {
01266   return this->implementation ()->message_block ();
01267 }
01268 
01269 int
01270 ACE_Asynch_Read_Dgram::Result::flags (void) const
01271 {
01272   return this->implementation ()->flags ();
01273 }
01274 
01275 size_t
01276 ACE_Asynch_Read_Dgram::Result::bytes_to_read (void) const
01277 {
01278   return this->implementation ()->bytes_to_read ();
01279 }
01280 
01281 ACE_HANDLE
01282 ACE_Asynch_Read_Dgram::Result::handle (void) const
01283 {
01284   return this->implementation ()->handle();
01285 }
01286 
01287 ACE_Asynch_Read_Dgram::Result::Result (ACE_Asynch_Read_Dgram_Result_Impl *implementation)
01288 : ACE_Asynch_Result (implementation),
01289   implementation_ (implementation)
01290 {
01291 }
01292 
01293 ACE_Asynch_Read_Dgram::Result::~Result (void)
01294 {
01295 }
01296 
01297 ACE_Asynch_Read_Dgram_Result_Impl *
01298 ACE_Asynch_Read_Dgram::Result::implementation (void) const
01299 {
01300   return this->implementation_;
01301 }
01302 
01303 // ************************************************************
01304 
01305 
01306 ACE_Asynch_Write_Dgram::ACE_Asynch_Write_Dgram (void)
01307   : implementation_ (0)
01308 {
01309 }
01310 
01311 ACE_Asynch_Write_Dgram::~ACE_Asynch_Write_Dgram (void)
01312 {
01313   // Delete the implementation.
01314   delete this->implementation_;
01315   this->implementation_ = 0;
01316 }
01317 
01318 int
01319 ACE_Asynch_Write_Dgram::open (ACE_Handler &handler,
01320                               ACE_HANDLE handle,
01321                               const void *completion_key,
01322                               ACE_Proactor *proactor)
01323 {
01324   // Get a proactor for/from the user.
01325   proactor = this->get_proactor (proactor, handler);
01326 
01327   // Now let us get the implementation initialized.
01328   if ((this->implementation_ = proactor->create_asynch_write_dgram ()) == 0)
01329     return -1;
01330 
01331   // Call the <open> method of the base class.
01332   return ACE_Asynch_Operation::open (handler,
01333                                      handle,
01334                                      completion_key,
01335                                      proactor);
01336 }
01337 
01338 ssize_t
01339 ACE_Asynch_Write_Dgram::send (ACE_Message_Block *message_block,
01340                               size_t &number_of_bytes_sent,
01341                               int flags,
01342                               const ACE_Addr& remote_addr,
01343                               const void *act,
01344                               int priority,
01345                               int signal_number)
01346 {
01347   if (0 == this->implementation_)
01348     {
01349       errno = EFAULT;
01350       return -1;
01351     }
01352   return this->implementation_->send (message_block,
01353                                       number_of_bytes_sent,
01354                                       flags,
01355                                       remote_addr,
01356                                       act,
01357                                       priority,
01358                                       signal_number);
01359 }
01360 
01361 ACE_Asynch_Operation_Impl *
01362 ACE_Asynch_Write_Dgram::implementation (void) const
01363 {
01364   return this->implementation_;
01365 }
01366 
01367 // ************************************************************
01368 
01369 size_t
01370 ACE_Asynch_Write_Dgram::Result::bytes_to_write (void) const
01371 {
01372   return this->implementation ()->bytes_to_write ();
01373 }
01374 
01375 ACE_Message_Block*
01376 ACE_Asynch_Write_Dgram::Result::message_block () const
01377 {
01378   return this->implementation ()->message_block ();
01379 }
01380 
01381 int
01382 ACE_Asynch_Write_Dgram::Result::flags (void) const
01383 {
01384   return this->implementation ()->flags ();
01385 }
01386 
01387 ACE_HANDLE
01388 ACE_Asynch_Write_Dgram::Result::handle (void) const
01389 {
01390   return this->implementation ()->handle ();
01391 }
01392 
01393 ACE_Asynch_Write_Dgram_Result_Impl *
01394 ACE_Asynch_Write_Dgram::Result::implementation (void) const
01395 {
01396   return this->implementation_;
01397 }
01398 
01399 ACE_Asynch_Write_Dgram::Result::Result (ACE_Asynch_Write_Dgram_Result_Impl *implementation)
01400 : ACE_Asynch_Result (implementation),
01401   implementation_ (implementation)
01402 {
01403 }
01404 
01405 ACE_Asynch_Write_Dgram::Result::~Result (void)
01406 {
01407 }
01408 
01409 ACE_END_VERSIONED_NAMESPACE_DECL
01410 
01411 #endif /* ACE_HAS_WIN32_OVERLAPPED_IO || ACE_HAS_AIO_CALLS */

Generated on Tue Feb 2 17:18:38 2010 for ACE by  doxygen 1.4.7