00001 #include "ace_pch.h"
00002
00003
00004 #include "ace/Proactor.h"
00005 #if ((defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)) || (defined (ACE_HAS_AIO_CALLS)))
00006
00007
00008
00009 #include "ace/Proactor_Impl.h"
00010 #include "ace/Object_Manager.h"
00011 #include "ace/Task_T.h"
00012 #if !defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_ACE_SVCCONF)
00013 # include "ace/Service_Config.h"
00014 # endif
00015
00016 ACE_RCSID(ace, Proactor, "$Id: Proactor.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:22 chad Exp $")
00017
00018 #include "ace/Task_T.h"
00019 #include "ace/Log_Msg.h"
00020 #include "ace/Framework_Component.h"
00021
00022 #if defined (ACE_HAS_AIO_CALLS)
00023 # include "ace/POSIX_Proactor.h"
00024 #else
00025 # include "ace/WIN32_Proactor.h"
00026 #endif
00027
00028 #if !defined (__ACE_INLINE__)
00029 #include "ace/Proactor.i"
00030 #endif
00031
00032
00033 ACE_Proactor *ACE_Proactor::proactor_ = 0;
00034
00035
00036
00037 int ACE_Proactor::delete_proactor_ = 0;
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 class ACE_Proactor_Timer_Handler : public ACE_Task <ACE_NULL_SYNCH>
00053 {
00054
00055
00056
00057 friend class ACE_Proactor;
00058
00059 public:
00060
00061 ACE_Proactor_Timer_Handler (ACE_Proactor &proactor);
00062
00063
00064 virtual ~ACE_Proactor_Timer_Handler (void);
00065
00066
00067
00068
00069 int destroy (void);
00070
00071 protected:
00072
00073
00074
00075 virtual int svc (void);
00076
00077
00078 ACE_Auto_Event timer_event_;
00079
00080
00081 ACE_Proactor &proactor_;
00082
00083
00084 int shutting_down_;
00085 };
00086
00087 ACE_Proactor_Timer_Handler::ACE_Proactor_Timer_Handler (ACE_Proactor &proactor)
00088 : ACE_Task <ACE_NULL_SYNCH> (&proactor.thr_mgr_),
00089 proactor_ (proactor),
00090 shutting_down_ (0)
00091 {
00092 }
00093
00094 ACE_Proactor_Timer_Handler::~ACE_Proactor_Timer_Handler (void)
00095 {
00096
00097 this->shutting_down_ = 1;
00098
00099
00100 this->timer_event_.signal ();
00101
00102
00103 this->thr_mgr ()->wait_grp (this->grp_id ());
00104 }
00105
00106 int
00107 ACE_Proactor_Timer_Handler::svc (void)
00108 {
00109 ACE_Time_Value absolute_time;
00110 ACE_Time_Value relative_time;
00111 int result = 0;
00112
00113 while (this->shutting_down_ == 0)
00114 {
00115
00116 if (this->proactor_.timer_queue ()->is_empty () == 0)
00117 {
00118
00119 absolute_time = this->proactor_.timer_queue ()->earliest_time ();
00120
00121
00122
00123 ACE_Time_Value cur_time = this->proactor_.timer_queue ()->gettimeofday ();
00124
00125
00126
00127 if (absolute_time > cur_time)
00128 relative_time = absolute_time - cur_time;
00129 else
00130 relative_time = 0;
00131
00132
00133 result = this->timer_event_.wait (&relative_time, 0);
00134 }
00135 else
00136
00137 result = this->timer_event_.wait ();
00138
00139
00140 if (result == -1)
00141 {
00142 switch (errno)
00143 {
00144 case ETIME:
00145
00146 this->proactor_.timer_queue ()->expire ();
00147 break;
00148 default:
00149
00150 ACE_ERROR_RETURN ((LM_ERROR,
00151 ACE_LIB_TEXT ("%N:%l:(%P | %t):%p\n"),
00152 ACE_LIB_TEXT ("ACE_Proactor_Timer_Handler::svc:wait failed")),
00153 -1);
00154 }
00155 }
00156 }
00157 return 0;
00158 }
00159
00160
00161
00162 ACE_Proactor_Handle_Timeout_Upcall::ACE_Proactor_Handle_Timeout_Upcall (void)
00163 : proactor_ (0)
00164 {
00165 }
00166
00167 int
00168 ACE_Proactor_Handle_Timeout_Upcall::timeout (TIMER_QUEUE &timer_queue,
00169 ACE_Handler *handler,
00170 const void *act,
00171 const ACE_Time_Value &time)
00172 {
00173 ACE_UNUSED_ARG (timer_queue);
00174
00175 if (this->proactor_ == 0)
00176 ACE_ERROR_RETURN ((LM_ERROR,
00177 ACE_LIB_TEXT ("(%t) No Proactor set in ACE_Proactor_Handle_Timeout_Upcall,")
00178 ACE_LIB_TEXT (" no completion port to post timeout to?!@\n")),
00179 -1);
00180
00181
00182 ACE_Asynch_Result_Impl *asynch_timer = this->proactor_->create_asynch_timer (*handler,
00183 act,
00184 time,
00185 ACE_INVALID_HANDLE,
00186 0,
00187 -1);
00188 if (asynch_timer == 0)
00189 ACE_ERROR_RETURN ((LM_ERROR,
00190 ACE_LIB_TEXT ("%N:%l:(%P | %t):%p\n"),
00191 ACE_LIB_TEXT ("ACE_Proactor_Handle_Timeout_Upcall::timeout:")
00192 ACE_LIB_TEXT ("create_asynch_timer failed")),
00193 -1);
00194
00195
00196 if (asynch_timer->post_completion (this->proactor_->implementation ()) == -1)
00197 ACE_ERROR_RETURN ((LM_ERROR,
00198 ACE_LIB_TEXT ("Failure in dealing with timers: ")
00199 ACE_LIB_TEXT ("PostQueuedCompletionStatus failed\n")),
00200 -1);
00201 return 0;
00202 }
00203
00204 int
00205 ACE_Proactor_Handle_Timeout_Upcall::cancellation (TIMER_QUEUE &timer_queue,
00206 ACE_Handler *handler)
00207 {
00208 ACE_UNUSED_ARG (timer_queue);
00209 ACE_UNUSED_ARG (handler);
00210
00211
00212 return 0;
00213 }
00214
00215 int
00216 ACE_Proactor_Handle_Timeout_Upcall::deletion (TIMER_QUEUE &timer_queue,
00217 ACE_Handler *handler,
00218 const void *arg)
00219 {
00220 ACE_UNUSED_ARG (timer_queue);
00221 ACE_UNUSED_ARG (handler);
00222 ACE_UNUSED_ARG (arg);
00223
00224
00225 return 0;
00226 }
00227
00228 int
00229 ACE_Proactor_Handle_Timeout_Upcall::proactor (ACE_Proactor &proactor)
00230 {
00231 if (this->proactor_ == 0)
00232 {
00233 this->proactor_ = &proactor;
00234 return 0;
00235 }
00236 else
00237 ACE_ERROR_RETURN ((LM_ERROR,
00238 ACE_LIB_TEXT ("ACE_Proactor_Handle_Timeout_Upcall is only suppose")
00239 ACE_LIB_TEXT (" to be used with ONE (and only one) Proactor\n")),
00240 -1);
00241 }
00242
00243
00244
00245 ACE_Proactor::ACE_Proactor (ACE_Proactor_Impl *implementation,
00246 int delete_implementation,
00247 TIMER_QUEUE *tq)
00248 : implementation_ (0),
00249 delete_implementation_ (delete_implementation),
00250 timer_handler_ (0),
00251 timer_queue_ (0),
00252 delete_timer_queue_ (0),
00253 end_event_loop_ (0),
00254 event_loop_thread_count_ (0)
00255 {
00256 this->implementation (implementation);
00257
00258 if (this->implementation () == 0)
00259 {
00260 #if defined (ACE_HAS_AIO_CALLS)
00261
00262 # if defined (ACE_POSIX_AIOCB_PROACTOR)
00263 ACE_NEW (implementation, ACE_POSIX_AIOCB_Proactor);
00264 # elif defined (ACE_POSIX_SIG_PROACTOR)
00265 ACE_NEW (implementation, ACE_POSIX_SIG_Proactor);
00266 # else
00267 # if defined(ACE_HAS_POSIX_REALTIME_SIGNALS)
00268 ACE_NEW (implementation, ACE_POSIX_SIG_Proactor);
00269 # else
00270 ACE_NEW (implementation, ACE_POSIX_AIOCB_Proactor);
00271 # endif
00272 # endif
00273 #elif (defined (ACE_WIN32) && !defined (ACE_HAS_WINCE))
00274
00275 ACE_NEW (implementation,
00276 ACE_WIN32_Proactor);
00277 #endif
00278 this->implementation (implementation);
00279 this->delete_implementation_ = 1;
00280 }
00281
00282
00283 this->timer_queue (tq);
00284
00285
00286 ACE_NEW (this->timer_handler_,
00287 ACE_Proactor_Timer_Handler (*this));
00288
00289
00290 if (this->timer_handler_->activate (THR_NEW_LWP) == -1)
00291 ACE_ERROR ((LM_ERROR,
00292 ACE_LIB_TEXT ("%N:%l:(%P | %t):%p\n"),
00293 ACE_LIB_TEXT ("Task::activate:could not create thread\n")));
00294 }
00295
00296 ACE_Proactor::~ACE_Proactor (void)
00297 {
00298 this->close ();
00299 }
00300
00301 ACE_Proactor *
00302 ACE_Proactor::instance (size_t )
00303 {
00304 ACE_TRACE ("ACE_Proactor::instance");
00305
00306 if (ACE_Proactor::proactor_ == 0)
00307 {
00308
00309 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00310 *ACE_Static_Object_Lock::instance (),
00311 0));
00312
00313 if (ACE_Proactor::proactor_ == 0)
00314 {
00315 ACE_NEW_RETURN (ACE_Proactor::proactor_,
00316 ACE_Proactor,
00317 0);
00318
00319 ACE_Proactor::delete_proactor_ = 1;
00320 ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Proactor, ACE_Proactor::proactor_);
00321 }
00322 }
00323 return ACE_Proactor::proactor_;
00324 }
00325
00326 ACE_Proactor *
00327 ACE_Proactor::instance (ACE_Proactor * r, int delete_proactor)
00328 {
00329 ACE_TRACE ("ACE_Proactor::instance");
00330
00331 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00332 *ACE_Static_Object_Lock::instance (), 0));
00333
00334 ACE_Proactor *t = ACE_Proactor::proactor_;
00335
00336 ACE_Proactor::delete_proactor_ = delete_proactor;
00337 ACE_Proactor::proactor_ = r;
00338 ACE_REGISTER_FRAMEWORK_COMPONENT(ACE_Proactor, ACE_Proactor::proactor_);
00339
00340 return t;
00341 }
00342
00343 void
00344 ACE_Proactor::close_singleton (void)
00345 {
00346 ACE_TRACE ("ACE_Proactor::close_singleton");
00347
00348 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00349 *ACE_Static_Object_Lock::instance ()));
00350
00351 if (ACE_Proactor::delete_proactor_)
00352 {
00353
00354 delete ACE_Proactor::proactor_;
00355 ACE_Proactor::proactor_ = 0;
00356 ACE_Proactor::delete_proactor_ = 0;
00357 }
00358 }
00359
00360 const ACE_TCHAR *
00361 ACE_Proactor::dll_name (void)
00362 {
00363 return ACE_LIB_TEXT ("ACE");
00364 }
00365
00366 const ACE_TCHAR *
00367 ACE_Proactor::name (void)
00368 {
00369 return ACE_LIB_TEXT ("ACE_Proactor");
00370 }
00371
00372 int
00373 ACE_Proactor::check_reconfiguration (ACE_Proactor *)
00374 {
00375 #if !defined (ACE_HAS_WINCE) && !defined (ACE_LACKS_ACE_SVCCONF)
00376 if (ACE_Service_Config::reconfig_occurred ())
00377 {
00378 ACE_Service_Config::reconfigure ();
00379 return 1;
00380 }
00381 #endif
00382 return 0;
00383 }
00384
00385 int
00386 ACE_Proactor::proactor_run_event_loop (PROACTOR_EVENT_HOOK eh)
00387 {
00388 ACE_TRACE ("ACE_Proactor::proactor_run_event_loop");
00389 int result = 0;
00390
00391 {
00392 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
00393
00394
00395
00396 if (this->end_event_loop_ != 0)
00397 return 0;
00398
00399
00400 this->event_loop_thread_count_ ++;
00401 }
00402
00403
00404 for (;;)
00405 {
00406
00407
00408 if (this->end_event_loop_ != 0)
00409 break;
00410
00411
00412 result = this->handle_events ();
00413
00414 if (eh != 0 && (*eh) (this))
00415 continue;
00416
00417 if (result == -1)
00418 break;
00419 }
00420
00421
00422
00423 {
00424
00425 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
00426
00427
00428 this->event_loop_thread_count_ --;
00429
00430 if (this->event_loop_thread_count_ > 0
00431 && this->end_event_loop_ != 0)
00432 this->proactor_post_wakeup_completions (1);
00433 }
00434
00435 return result;
00436 }
00437
00438
00439
00440 int
00441 ACE_Proactor::proactor_run_event_loop (ACE_Time_Value &tv,
00442 PROACTOR_EVENT_HOOK eh)
00443 {
00444 ACE_TRACE ("ACE_Proactor::proactor_run_event_loop");
00445 int result = 0;
00446
00447 {
00448 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
00449
00450
00451
00452 if (this->end_event_loop_ != 0
00453 || tv == ACE_Time_Value::zero)
00454 return 0;
00455
00456
00457 this->event_loop_thread_count_ ++;
00458 }
00459
00460
00461 for (;;)
00462 {
00463
00464
00465 if (this->end_event_loop_ != 0)
00466 break;
00467
00468
00469 result = this->handle_events (tv);
00470
00471 if (eh != 0 && (*eh) (this))
00472 continue;
00473
00474 if (result == -1)
00475 break;
00476 }
00477
00478
00479
00480 {
00481 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
00482
00483
00484 this->event_loop_thread_count_ --;
00485
00486 if (this->event_loop_thread_count_ > 0
00487 && this->end_event_loop_ != 0)
00488 this->proactor_post_wakeup_completions (1);
00489 }
00490
00491 return result;
00492 }
00493
00494 int
00495 ACE_Proactor::proactor_reset_event_loop(void)
00496 {
00497 ACE_TRACE ("ACE_Proactor::proactor_reset_event_loop");
00498
00499
00500 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
00501
00502 this->end_event_loop_ = 0;
00503 return 0;
00504 }
00505
00506 int
00507 ACE_Proactor::proactor_end_event_loop (void)
00508 {
00509 ACE_TRACE ("ACE_Proactor::proactor_end_event_loop");
00510
00511 int how_many = 0;
00512
00513 {
00514
00515
00516 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
00517
00518
00519 this->end_event_loop_ = 1;
00520
00521
00522 how_many = this->event_loop_thread_count_;
00523 if (how_many == 0)
00524 return 0;
00525 }
00526
00527
00528
00529 return this->proactor_post_wakeup_completions (how_many);
00530 }
00531
00532 int
00533 ACE_Proactor::proactor_event_loop_done (void)
00534 {
00535 ACE_TRACE ("ACE_Proactor::proactor_event_loop_done");
00536
00537 ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, mutex_, -1));
00538
00539 return this->end_event_loop_ != 0 ? 1 : 0 ;
00540 }
00541
00542 int
00543 ACE_Proactor::close (void)
00544 {
00545
00546 if (this->implementation ()->close () == -1)
00547 ACE_ERROR_RETURN ((LM_ERROR,
00548 ACE_LIB_TEXT ("%N:%l:(%P | %t):%p\n"),
00549 ACE_LIB_TEXT ("ACE_Proactor::close:implementation couldnt be closed")),
00550 -1);
00551
00552
00553 if (this->delete_implementation_)
00554 {
00555 delete this->implementation ();
00556 this->implementation_ = 0;
00557 }
00558
00559
00560 if (this->timer_handler_)
00561 {
00562 delete this->timer_handler_;
00563 this->timer_handler_ = 0;
00564 }
00565
00566
00567 if (this->delete_timer_queue_)
00568 {
00569 delete this->timer_queue_;
00570 this->timer_queue_ = 0;
00571 this->delete_timer_queue_ = 0;
00572 }
00573
00574 return 0;
00575 }
00576
00577 int
00578 ACE_Proactor::register_handle (ACE_HANDLE handle,
00579 const void *completion_key)
00580 {
00581 return this->implementation ()->register_handle (handle,
00582 completion_key);
00583 }
00584
00585 long
00586 ACE_Proactor::schedule_timer (ACE_Handler &handler,
00587 const void *act,
00588 const ACE_Time_Value &time)
00589 {
00590 return this->schedule_timer (handler,
00591 act,
00592 time,
00593 ACE_Time_Value::zero);
00594 }
00595
00596 long
00597 ACE_Proactor::schedule_repeating_timer (ACE_Handler &handler,
00598 const void *act,
00599 const ACE_Time_Value &interval)
00600 {
00601 return this->schedule_timer (handler,
00602 act,
00603 interval,
00604 interval);
00605 }
00606
00607 long
00608 ACE_Proactor::schedule_timer (ACE_Handler &handler,
00609 const void *act,
00610 const ACE_Time_Value &time,
00611 const ACE_Time_Value &interval)
00612 {
00613
00614 ACE_Time_Value absolute_time =
00615 this->timer_queue_->gettimeofday () + time;
00616
00617
00618 ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX,
00619 ace_mon,
00620 this->timer_queue_->mutex (),
00621 -1));
00622
00623
00624 long result = this->timer_queue_->schedule (&handler,
00625 act,
00626 absolute_time,
00627 interval);
00628 if (result != -1)
00629 {
00630
00631 if (this->timer_queue_->earliest_time () == absolute_time)
00632
00633
00634 if (this->timer_handler_->timer_event_.signal () == -1)
00635 {
00636
00637 this->timer_queue_->cancel (result);
00638 result = -1;
00639 }
00640 }
00641 return result;
00642 }
00643
00644 int
00645 ACE_Proactor::cancel_timer (long timer_id,
00646 const void **arg,
00647 int dont_call_handle_close)
00648 {
00649
00650
00651 return this->timer_queue_->cancel (timer_id,
00652 arg,
00653 dont_call_handle_close);
00654 }
00655
00656 int
00657 ACE_Proactor::cancel_timer (ACE_Handler &handler,
00658 int dont_call_handle_close)
00659 {
00660
00661
00662 return this->timer_queue_->cancel (&handler,
00663 dont_call_handle_close);
00664 }
00665
00666 int
00667 ACE_Proactor::handle_events (ACE_Time_Value &wait_time)
00668 {
00669 return implementation ()->handle_events (wait_time);
00670 }
00671
00672 int
00673 ACE_Proactor::handle_events (void)
00674 {
00675 return this->implementation ()->handle_events ();
00676 }
00677
00678 int
00679 ACE_Proactor::wake_up_dispatch_threads (void)
00680 {
00681 return 0;
00682 }
00683
00684 int
00685 ACE_Proactor::close_dispatch_threads (int)
00686 {
00687 return 0;
00688 }
00689
00690 size_t
00691 ACE_Proactor::number_of_threads (void) const
00692 {
00693 return this->implementation ()->number_of_threads ();
00694 }
00695
00696 void
00697 ACE_Proactor::number_of_threads (size_t threads)
00698 {
00699 this->implementation ()->number_of_threads (threads);
00700 }
00701
00702 ACE_Proactor::TIMER_QUEUE *
00703 ACE_Proactor::timer_queue (void) const
00704 {
00705 return this->timer_queue_;
00706 }
00707
00708 void
00709 ACE_Proactor::timer_queue (TIMER_QUEUE *tq)
00710 {
00711
00712 if (this->delete_timer_queue_)
00713 {
00714 delete this->timer_queue_;
00715 this->delete_timer_queue_ = 0;
00716 }
00717
00718
00719 if (tq == 0)
00720 {
00721 ACE_NEW (this->timer_queue_,
00722 TIMER_HEAP);
00723 this->delete_timer_queue_ = 1;
00724 }
00725 else
00726 {
00727 this->timer_queue_ = tq;
00728 this->delete_timer_queue_ = 0;
00729 }
00730
00731
00732 this->timer_queue_->upcall_functor ().proactor (*this);
00733 }
00734
00735 ACE_HANDLE
00736 ACE_Proactor::get_handle (void) const
00737 {
00738 return this->implementation ()->get_handle ();
00739 }
00740
00741 ACE_Proactor_Impl *
00742 ACE_Proactor::implementation (void) const
00743 {
00744 return this->implementation_;
00745 }
00746
00747
00748 ACE_Asynch_Read_Stream_Impl *
00749 ACE_Proactor::create_asynch_read_stream (void)
00750 {
00751 return this->implementation ()->create_asynch_read_stream ();
00752 }
00753
00754 ACE_Asynch_Write_Stream_Impl *
00755 ACE_Proactor::create_asynch_write_stream (void)
00756 {
00757 return this->implementation ()->create_asynch_write_stream ();
00758 }
00759
00760 ACE_Asynch_Read_Dgram_Impl *
00761 ACE_Proactor::create_asynch_read_dgram (void)
00762 {
00763 return this->implementation ()->create_asynch_read_dgram ();
00764 }
00765
00766 ACE_Asynch_Write_Dgram_Impl *
00767 ACE_Proactor::create_asynch_write_dgram (void)
00768 {
00769 return this->implementation ()->create_asynch_write_dgram ();
00770 }
00771
00772 ACE_Asynch_Read_File_Impl *
00773 ACE_Proactor::create_asynch_read_file (void)
00774 {
00775 return this->implementation ()->create_asynch_read_file ();
00776 }
00777
00778 ACE_Asynch_Write_File_Impl *
00779 ACE_Proactor::create_asynch_write_file (void)
00780 {
00781 return this->implementation ()->create_asynch_write_file ();
00782 }
00783
00784 ACE_Asynch_Accept_Impl *
00785 ACE_Proactor::create_asynch_accept (void)
00786 {
00787 return this->implementation ()->create_asynch_accept ();
00788 }
00789
00790 ACE_Asynch_Connect_Impl *
00791 ACE_Proactor::create_asynch_connect (void)
00792 {
00793 return this->implementation ()->create_asynch_connect ();
00794 }
00795
00796 ACE_Asynch_Transmit_File_Impl *
00797 ACE_Proactor::create_asynch_transmit_file (void)
00798 {
00799 return this->implementation ()->create_asynch_transmit_file ();
00800 }
00801
00802 ACE_Asynch_Read_Stream_Result_Impl *
00803 ACE_Proactor::create_asynch_read_stream_result (ACE_Handler &handler,
00804 ACE_HANDLE handle,
00805 ACE_Message_Block &message_block,
00806 u_long bytes_to_read,
00807 const void* act,
00808 ACE_HANDLE event,
00809 int priority,
00810 int signal_number)
00811 {
00812 return this->implementation ()->create_asynch_read_stream_result (handler,
00813 handle,
00814 message_block,
00815 bytes_to_read,
00816 act,
00817 event,
00818 priority,
00819 signal_number);
00820 }
00821
00822
00823 ACE_Asynch_Write_Stream_Result_Impl *
00824 ACE_Proactor::create_asynch_write_stream_result (ACE_Handler &handler,
00825 ACE_HANDLE handle,
00826 ACE_Message_Block &message_block,
00827 u_long bytes_to_write,
00828 const void* act,
00829 ACE_HANDLE event,
00830 int priority,
00831 int signal_number)
00832
00833 {
00834 return this->implementation ()->create_asynch_write_stream_result (handler,
00835 handle,
00836 message_block,
00837 bytes_to_write,
00838 act,
00839 event,
00840 priority,
00841 signal_number);
00842 }
00843
00844 ACE_Asynch_Read_File_Result_Impl *
00845 ACE_Proactor::create_asynch_read_file_result (ACE_Handler &handler,
00846 ACE_HANDLE handle,
00847 ACE_Message_Block &message_block,
00848 u_long bytes_to_read,
00849 const void* act,
00850 u_long offset,
00851 u_long offset_high,
00852 ACE_HANDLE event,
00853 int priority,
00854 int signal_number)
00855
00856 {
00857 return this->implementation ()->create_asynch_read_file_result (handler,
00858 handle,
00859 message_block,
00860 bytes_to_read,
00861 act,
00862 offset,
00863 offset_high,
00864 event,
00865 priority,
00866 signal_number);
00867 }
00868
00869 ACE_Asynch_Write_File_Result_Impl *
00870 ACE_Proactor::create_asynch_write_file_result (ACE_Handler &handler,
00871 ACE_HANDLE handle,
00872 ACE_Message_Block &message_block,
00873 u_long bytes_to_write,
00874 const void* act,
00875 u_long offset,
00876 u_long offset_high,
00877 ACE_HANDLE event,
00878 int priority,
00879 int signal_number)
00880
00881 {
00882 return this->implementation ()->create_asynch_write_file_result (handler,
00883 handle,
00884 message_block,
00885 bytes_to_write,
00886 act,
00887 offset,
00888 offset_high,
00889 event,
00890 priority,
00891 signal_number);
00892 }
00893
00894 ACE_Asynch_Read_Dgram_Result_Impl *
00895 ACE_Proactor::create_asynch_read_dgram_result (ACE_Handler &handler,
00896 ACE_HANDLE handle,
00897 ACE_Message_Block *message_block,
00898 size_t bytes_to_read,
00899 int flags,
00900 int protocol_family,
00901 const void* act,
00902 ACE_HANDLE event,
00903 int priority,
00904 int signal_number)
00905 {
00906 return this->implementation()->create_asynch_read_dgram_result (handler,
00907 handle,
00908 message_block,
00909 bytes_to_read,
00910 flags,
00911 protocol_family,
00912 act,
00913 event,
00914 priority,
00915 signal_number);
00916 }
00917
00918 ACE_Asynch_Write_Dgram_Result_Impl *
00919 ACE_Proactor::create_asynch_write_dgram_result (ACE_Handler &handler,
00920 ACE_HANDLE handle,
00921 ACE_Message_Block *message_block,
00922 size_t bytes_to_write,
00923 int flags,
00924 const void* act,
00925 ACE_HANDLE event,
00926 int priority,
00927 int signal_number)
00928 {
00929 return this->implementation()->create_asynch_write_dgram_result (handler,
00930 handle,
00931 message_block,
00932 bytes_to_write,
00933 flags,
00934 act,
00935 event,
00936 priority,
00937 signal_number);
00938 }
00939
00940 ACE_Asynch_Accept_Result_Impl *
00941 ACE_Proactor::create_asynch_accept_result (ACE_Handler &handler,
00942 ACE_HANDLE listen_handle,
00943 ACE_HANDLE accept_handle,
00944 ACE_Message_Block &message_block,
00945 u_long bytes_to_read,
00946 const void* act,
00947 ACE_HANDLE event,
00948 int priority,
00949 int signal_number)
00950
00951 {
00952 return this->implementation ()->create_asynch_accept_result (handler,
00953 listen_handle,
00954 accept_handle,
00955 message_block,
00956 bytes_to_read,
00957 act,
00958 event,
00959 priority,
00960 signal_number);
00961 }
00962
00963 ACE_Asynch_Connect_Result_Impl *
00964 ACE_Proactor::create_asynch_connect_result (ACE_Handler &handler,
00965 ACE_HANDLE connect_handle,
00966 const void* act,
00967 ACE_HANDLE event,
00968 int priority,
00969 int signal_number)
00970
00971 {
00972 return this->implementation ()->create_asynch_connect_result (handler,
00973 connect_handle,
00974 act,
00975 event,
00976 priority,
00977 signal_number);
00978 }
00979
00980 ACE_Asynch_Transmit_File_Result_Impl *
00981 ACE_Proactor::create_asynch_transmit_file_result (ACE_Handler &handler,
00982 ACE_HANDLE socket,
00983 ACE_HANDLE file,
00984 ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer,
00985 u_long bytes_to_write,
00986 u_long offset,
00987 u_long offset_high,
00988 u_long bytes_per_send,
00989 u_long flags,
00990 const void *act,
00991 ACE_HANDLE event,
00992 int priority,
00993 int signal_number)
00994
00995 {
00996 return this->implementation ()->create_asynch_transmit_file_result (handler,
00997 socket,
00998 file,
00999 header_and_trailer,
01000 bytes_to_write,
01001 offset,
01002 offset_high,
01003 bytes_per_send,
01004 flags,
01005 act,
01006 event,
01007 priority,
01008 signal_number);
01009 }
01010
01011 ACE_Asynch_Result_Impl *
01012 ACE_Proactor::create_asynch_timer (ACE_Handler &handler,
01013 const void *act,
01014 const ACE_Time_Value &tv,
01015 ACE_HANDLE event,
01016 int priority,
01017 int signal_number)
01018 {
01019 return this->implementation ()->create_asynch_timer (handler,
01020 act,
01021 tv,
01022 event,
01023 priority,
01024 signal_number);
01025 }
01026
01027 int
01028 ACE_Proactor::proactor_post_wakeup_completions (int how_many)
01029 {
01030 return this->implementation ()->post_wakeup_completions (how_many);
01031 }
01032
01033 void
01034 ACE_Proactor::implementation (ACE_Proactor_Impl *implementation)
01035 {
01036 this->implementation_ = implementation;
01037 }
01038
01039 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
01040 template class ACE_Timer_Queue_T<ACE_Handler *,
01041 ACE_Proactor_Handle_Timeout_Upcall,
01042 ACE_SYNCH_RECURSIVE_MUTEX>;
01043 template class ACE_Timer_Queue_Iterator_T<ACE_Handler *,
01044 ACE_Proactor_Handle_Timeout_Upcall,
01045 ACE_SYNCH_RECURSIVE_MUTEX>;
01046 template class ACE_Timer_List_T<ACE_Handler *,
01047 ACE_Proactor_Handle_Timeout_Upcall,
01048 ACE_SYNCH_RECURSIVE_MUTEX>;
01049 template class ACE_Timer_List_Iterator_T<ACE_Handler *,
01050 ACE_Proactor_Handle_Timeout_Upcall,
01051 ACE_SYNCH_RECURSIVE_MUTEX>;
01052 template class ACE_Timer_Node_T<ACE_Handler *>;
01053 template class ACE_Unbounded_Set<ACE_Timer_Node_T<ACE_Handler *> *>;
01054 template class ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<ACE_Handler *> *>;
01055 template class ACE_Node <ACE_Timer_Node_T<ACE_Handler *> *>;
01056 template class ACE_Free_List<ACE_Timer_Node_T<ACE_Handler *> >;
01057 template class ACE_Locked_Free_List<ACE_Timer_Node_T<ACE_Handler *>, ACE_Null_Mutex>;
01058 template class ACE_Timer_Heap_T<ACE_Handler *,
01059 ACE_Proactor_Handle_Timeout_Upcall,
01060 ACE_SYNCH_RECURSIVE_MUTEX>;
01061 template class ACE_Timer_Heap_Iterator_T<ACE_Handler *,
01062 ACE_Proactor_Handle_Timeout_Upcall,
01063 ACE_SYNCH_RECURSIVE_MUTEX>;
01064 template class ACE_Timer_Wheel_T<ACE_Handler *,
01065 ACE_Proactor_Handle_Timeout_Upcall,
01066 ACE_SYNCH_RECURSIVE_MUTEX>;
01067 template class ACE_Timer_Wheel_Iterator_T<ACE_Handler *,
01068 ACE_Proactor_Handle_Timeout_Upcall,
01069 ACE_SYNCH_RECURSIVE_MUTEX>;
01070 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
01071 #pragma instantiate ACE_Timer_Queue_T<ACE_Handler *,\
01072 ACE_Proactor_Handle_Timeout_Upcall,\
01073 ACE_SYNCH_RECURSIVE_MUTEX>
01074 #pragma instantiate ACE_Timer_Queue_Iterator_T<ACE_Handler *,\
01075 ACE_Proactor_Handle_Timeout_Upcall,\
01076 ACE_SYNCH_RECURSIVE_MUTEX>
01077 #pragma instantiate ACE_Timer_List_T<ACE_Handler *,\
01078 ACE_Proactor_Handle_Timeout_Upcall,\
01079 ACE_SYNCH_RECURSIVE_MUTEX>
01080 #pragma instantiate ACE_Timer_List_Iterator_T<ACE_Handler *,\
01081 ACE_Proactor_Handle_Timeout_Upcall,\
01082 ACE_SYNCH_RECURSIVE_MUTEX>
01083 #pragma instantiate ACE_Timer_Node_T<ACE_Handler *>
01084 #pragma instantiate ACE_Unbounded_Set<ACE_Timer_Node_T<ACE_Handler *> *>
01085 #pragma instantiate ACE_Unbounded_Set_Iterator<ACE_Timer_Node_T<ACE_Handler *> *>
01086 #pragma instantiate ACE_Node <ACE_Timer_Node_T<ACE_Handler *> *>
01087 #pragma instantiate ACE_Free_List<ACE_Timer_Node_T<ACE_Handler *> >
01088 #pragma instantiate ACE_Locked_Free_List<ACE_Timer_Node_T<ACE_Handler *>,\
01089 ACE_Null_Mutex>
01090 #pragma instantiate ACE_Timer_Heap_T<ACE_Handler *,\
01091 ACE_Proactor_Handle_Timeout_Upcall,\
01092 ACE_SYNCH_RECURSIVE_MUTEX>
01093 #pragma instantiate ACE_Timer_Heap_Iterator_T<ACE_Handler *,\
01094 ACE_Proactor_Handle_Timeout_Upcall,\
01095 ACE_SYNCH_RECURSIVE_MUTEX>
01096 #pragma instantiate ACE_Timer_Wheel_T<ACE_Handler *,\
01097 ACE_Proactor_Handle_Timeout_Upcall,\
01098 ACE_SYNCH_RECURSIVE_MUTEX>
01099 #pragma instantiate ACE_Timer_Wheel_Iterator_T<ACE_Handler *,\
01100 ACE_Proactor_Handle_Timeout_Upcall,\
01101 ACE_SYNCH_RECURSIVE_MUTEX>
01102 #endif
01103
01104 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
01105 template class ACE_Framework_Component_T<ACE_Proactor>;
01106 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
01107 #pragma instantiate ACE_Framework_Component_T<ACE_Proactor>
01108 #endif
01109
01110 #else
01111
01112 ACE_Proactor *
01113 ACE_Proactor::instance (size_t threads)
01114 {
01115 ACE_UNUSED_ARG (threads);
01116 return 0;
01117 }
01118
01119 ACE_Proactor *
01120 ACE_Proactor::instance (ACE_Proactor *)
01121 {
01122 return 0;
01123 }
01124
01125 void
01126 ACE_Proactor::close_singleton (void)
01127 {
01128 }
01129
01130 int
01131 ACE_Proactor::run_event_loop (void)
01132 {
01133
01134 return -1;
01135 }
01136
01137 int
01138 ACE_Proactor::run_event_loop (ACE_Time_Value &tv)
01139 {
01140
01141 ACE_UNUSED_ARG (tv);
01142 return -1;
01143 }
01144
01145 int
01146 ACE_Proactor::end_event_loop (void)
01147 {
01148
01149 return -1;
01150 }
01151
01152 sig_atomic_t
01153 ACE_Proactor::event_loop_done (void)
01154 {
01155 return sig_atomic_t (1);
01156 }
01157
01158 #endif