00001
00002
00003
00004
00005 #include "ace/Handle_Set.h"
00006 #include "ace/Reactor.h"
00007 #include "ace/Thread.h"
00008 #include "ace/OS_NS_errno.h"
00009
00010 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00011
00012
00013
00014 ACE_INLINE int
00015 ACE_Wakeup_All_Threads_Handler::handle_signal (int ,
00016 siginfo_t * ,
00017 ucontext_t *)
00018 {
00019
00020
00021
00022 return 0;
00023 }
00024
00025 #if defined (ACE_WIN32)
00026
00027
00028
00029 ACE_INLINE
00030 ACE_WFMO_Reactor_Handler_Repository::Common_Info::Common_Info (void)
00031 : io_entry_ (0),
00032 event_handler_ (0),
00033 io_handle_ (ACE_INVALID_HANDLE),
00034 network_events_ (0),
00035 delete_event_ (0),
00036 delete_entry_ (0),
00037 close_masks_ (ACE_Event_Handler::NULL_MASK)
00038 {
00039 }
00040
00041 ACE_INLINE void
00042 ACE_WFMO_Reactor_Handler_Repository::Common_Info::reset (void)
00043 {
00044 this->event_handler_ = 0;
00045 this->io_entry_ = 0;
00046 this->io_handle_ = ACE_INVALID_HANDLE;
00047 this->network_events_ = 0;
00048 this->delete_event_ = 0;
00049 this->delete_entry_ = 0;
00050 this->close_masks_ = ACE_Event_Handler::NULL_MASK;
00051 }
00052
00053 ACE_INLINE void
00054 ACE_WFMO_Reactor_Handler_Repository::Common_Info::set (int io_entry,
00055 ACE_Event_Handler *event_handler,
00056 ACE_HANDLE io_handle,
00057 long network_events,
00058 int delete_event,
00059 int delete_entry,
00060 ACE_Reactor_Mask close_masks)
00061 {
00062 this->event_handler_ = event_handler;
00063 this->io_entry_ = io_entry;
00064 this->io_handle_ = io_handle;
00065 this->network_events_ = network_events;
00066 this->delete_event_ = delete_event;
00067 this->delete_entry_ = delete_entry;
00068 this->close_masks_ = close_masks;
00069 }
00070
00071 ACE_INLINE void
00072 ACE_WFMO_Reactor_Handler_Repository::Common_Info::set (Common_Info &common_info)
00073 {
00074 *this = common_info;
00075 }
00076
00077 ACE_INLINE void
00078 ACE_WFMO_Reactor_Handler_Repository::Common_Info::dump (void) const
00079 {
00080 #if defined (ACE_HAS_DUMP)
00081 ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::Common_Info::dump");
00082
00083 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00084
00085 ACE_DEBUG ((LM_DEBUG,
00086 ACE_LIB_TEXT ("I/O Entry = %d\n"),
00087 this->io_entry_));
00088
00089 ACE_DEBUG ((LM_DEBUG,
00090 ACE_LIB_TEXT ("Event Handler = %d\n"),
00091 this->event_handler_));
00092
00093 ACE_DEBUG ((LM_DEBUG,
00094 ACE_LIB_TEXT ("I/O Handle = %d\n"),
00095 this->io_handle_));
00096
00097 ACE_DEBUG ((LM_DEBUG,
00098 ACE_LIB_TEXT ("Network Events = %d\n"),
00099 this->network_events_));
00100
00101 ACE_DEBUG ((LM_DEBUG,
00102 ACE_LIB_TEXT ("Delete Event = %d\n"),
00103 this->delete_event_));
00104
00105 ACE_DEBUG ((LM_DEBUG,
00106 ACE_LIB_TEXT ("Delete Entry = %d\n"),
00107 this->delete_entry_));
00108
00109 ACE_DEBUG ((LM_DEBUG,
00110 ACE_LIB_TEXT ("Close Masks = %d\n"),
00111 this->close_masks_));
00112
00113 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00114 #endif
00115 }
00116
00117
00118
00119 ACE_INLINE
00120 ACE_WFMO_Reactor_Handler_Repository::Current_Info::Current_Info (void)
00121 : suspend_entry_ (0)
00122 {
00123 }
00124
00125 ACE_INLINE void
00126 ACE_WFMO_Reactor_Handler_Repository::Current_Info::set (int io_entry,
00127 ACE_Event_Handler *event_handler,
00128 ACE_HANDLE io_handle,
00129 long network_events,
00130 int delete_event,
00131 int delete_entry,
00132 ACE_Reactor_Mask close_masks,
00133 int suspend_entry)
00134 {
00135 this->suspend_entry_ = suspend_entry;
00136 Common_Info::set (io_entry,
00137 event_handler,
00138 io_handle,
00139 network_events,
00140 delete_event,
00141 delete_entry,
00142 close_masks);
00143 }
00144
00145 ACE_INLINE void
00146 ACE_WFMO_Reactor_Handler_Repository::Current_Info::set (Common_Info &common_info,
00147 int suspend_entry)
00148 {
00149 this->suspend_entry_ = suspend_entry;
00150 Common_Info::set (common_info);
00151 }
00152
00153 ACE_INLINE void
00154 ACE_WFMO_Reactor_Handler_Repository::Current_Info::reset (void)
00155 {
00156 this->suspend_entry_ = 0;
00157 Common_Info::reset ();
00158 }
00159
00160 ACE_INLINE void
00161 ACE_WFMO_Reactor_Handler_Repository::Current_Info::dump (ACE_HANDLE event_handle) const
00162 {
00163 #if defined (ACE_HAS_DUMP)
00164 ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::Current_Info::dump");
00165
00166 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00167
00168 Common_Info::dump ();
00169
00170 ACE_DEBUG ((LM_DEBUG,
00171 ACE_LIB_TEXT ("Event Handle = %d\n"),
00172 event_handle));
00173
00174 ACE_DEBUG ((LM_DEBUG,
00175 ACE_LIB_TEXT ("Suspend Entry = %d\n"),
00176 this->suspend_entry_));
00177
00178 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00179 #else
00180 ACE_UNUSED_ARG (event_handle);
00181 #endif
00182 }
00183
00184
00185
00186 ACE_INLINE
00187 ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::To_Be_Added_Info (void)
00188 : event_handle_ (ACE_INVALID_HANDLE),
00189 suspend_entry_ (0)
00190 {
00191 }
00192
00193 ACE_INLINE void
00194 ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::set (ACE_HANDLE event_handle,
00195 int io_entry,
00196 ACE_Event_Handler *event_handler,
00197 ACE_HANDLE io_handle,
00198 long network_events,
00199 int delete_event,
00200 int delete_entry,
00201 ACE_Reactor_Mask close_masks,
00202 int suspend_entry)
00203 {
00204 this->event_handle_ = event_handle;
00205 this->suspend_entry_ = suspend_entry;
00206 Common_Info::set (io_entry,
00207 event_handler,
00208 io_handle,
00209 network_events,
00210 delete_event,
00211 delete_entry,
00212 close_masks);
00213 }
00214
00215 ACE_INLINE void
00216 ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::set (ACE_HANDLE event_handle,
00217 Common_Info &common_info,
00218 int suspend_entry)
00219 {
00220 this->event_handle_ = event_handle;
00221 this->suspend_entry_ = suspend_entry;
00222 Common_Info::set (common_info);
00223 }
00224
00225 ACE_INLINE void
00226 ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::reset (void)
00227 {
00228 this->event_handle_ = ACE_INVALID_HANDLE;
00229 this->suspend_entry_ = 0;
00230 Common_Info::reset ();
00231 }
00232
00233 ACE_INLINE void
00234 ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::dump (void) const
00235 {
00236 #if defined (ACE_HAS_DUMP)
00237 ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::dump");
00238
00239 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00240
00241 Common_Info::dump ();
00242
00243 ACE_DEBUG ((LM_DEBUG,
00244 ACE_LIB_TEXT ("Event Handle = %d\n"),
00245 this->event_handle_));
00246
00247 ACE_DEBUG ((LM_DEBUG,
00248 ACE_LIB_TEXT ("Suspend Entry = %d\n"),
00249 this->suspend_entry_));
00250
00251 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00252 #endif
00253 }
00254
00255
00256
00257 ACE_INLINE
00258 ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::Suspended_Info (void)
00259 : event_handle_ (ACE_INVALID_HANDLE),
00260 resume_entry_ (0)
00261 {
00262 }
00263
00264 ACE_INLINE void
00265 ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::reset (void)
00266 {
00267 this->event_handle_ = ACE_INVALID_HANDLE;
00268 this->resume_entry_ = 0;
00269 Common_Info::reset ();
00270 }
00271
00272 ACE_INLINE void
00273 ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::set (ACE_HANDLE event_handle,
00274 int io_entry,
00275 ACE_Event_Handler *event_handler,
00276 ACE_HANDLE io_handle,
00277 long network_events,
00278 int delete_event,
00279 int delete_entry,
00280 ACE_Reactor_Mask close_masks,
00281 int resume_entry)
00282 {
00283 this->event_handle_ = event_handle;
00284 this->resume_entry_ = resume_entry;
00285 Common_Info::set (io_entry,
00286 event_handler,
00287 io_handle,
00288 network_events,
00289 delete_event,
00290 delete_entry,
00291 close_masks);
00292 }
00293
00294 ACE_INLINE void
00295 ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::set (ACE_HANDLE event_handle,
00296 Common_Info &common_info,
00297 int resume_entry)
00298 {
00299 this->event_handle_ = event_handle;
00300 this->resume_entry_ = resume_entry;
00301 Common_Info::set (common_info);
00302 }
00303
00304 ACE_INLINE void
00305 ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::dump (void) const
00306 {
00307 #if defined (ACE_HAS_DUMP)
00308 ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::dump");
00309
00310 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00311
00312 Common_Info::dump ();
00313
00314 ACE_DEBUG ((LM_DEBUG,
00315 ACE_LIB_TEXT ("Event Handle = %d\n"),
00316 this->event_handle_));
00317
00318 ACE_DEBUG ((LM_DEBUG,
00319 ACE_LIB_TEXT ("Resume Entry = %d\n"),
00320 this->resume_entry_));
00321
00322 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00323 #endif
00324 }
00325
00326
00327
00328 ACE_INLINE int
00329 ACE_WFMO_Reactor_Handler_Repository::close (void)
00330 {
00331
00332 this->unbind_all ();
00333
00334 return 0;
00335 }
00336
00337 ACE_INLINE ACE_HANDLE *
00338 ACE_WFMO_Reactor_Handler_Repository::handles (void) const
00339 {
00340
00341
00342
00343
00344
00345
00346 if (ACE_Thread::self () == this->wfmo_reactor_.owner_i ())
00347 return this->current_handles_;
00348 else
00349 return this->current_handles_ + 1;
00350 }
00351
00352 ACE_INLINE ACE_WFMO_Reactor_Handler_Repository::Current_Info *
00353 ACE_WFMO_Reactor_Handler_Repository::current_info (void) const
00354 {
00355 if (ACE_Thread::self () == this->wfmo_reactor_.owner_i ())
00356 return this->current_info_;
00357 else
00358 return this->current_info_ + 1;
00359 }
00360
00361 ACE_INLINE DWORD
00362 ACE_WFMO_Reactor_Handler_Repository::max_handlep1 (void) const
00363 {
00364 if (ACE_Thread::self () == this->wfmo_reactor_.owner_i ())
00365 return this->max_handlep1_;
00366 else
00367 return this->max_handlep1_ - 1;
00368 }
00369
00370 ACE_INLINE int
00371 ACE_WFMO_Reactor_Handler_Repository::scheduled_for_deletion (size_t slot) const
00372 {
00373 if (ACE_Thread::self () == this->wfmo_reactor_.owner_i ())
00374 return this->current_info_[slot].delete_entry_ == 1;
00375 else
00376 return this->current_info_[slot + 1].delete_entry_ == 1;
00377 }
00378
00379 ACE_INLINE int
00380 ACE_WFMO_Reactor_Handler_Repository::invalid_handle (ACE_HANDLE handle) const
00381 {
00382 ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::invalid_handle");
00383
00384
00385 if (handle == ACE_INVALID_HANDLE)
00386 {
00387 errno = EINVAL;
00388 return 1;
00389 }
00390 else
00391 return 0;
00392 }
00393
00394 ACE_INLINE int
00395 ACE_WFMO_Reactor_Handler_Repository::changes_required (void)
00396 {
00397
00398 return this->handles_to_be_added_ > 0
00399 || this->handles_to_be_deleted_ > 0
00400 || this->handles_to_be_suspended_ > 0
00401 || this->handles_to_be_resumed_ > 0;
00402 }
00403
00404 ACE_INLINE int
00405 ACE_WFMO_Reactor_Handler_Repository::make_changes (void)
00406 {
00407
00408
00409
00410
00411
00412
00413 this->make_changes_in_current_infos ();
00414
00415
00416 this->make_changes_in_suspension_infos ();
00417
00418
00419
00420 this->make_changes_in_to_be_added_infos ();
00421
00422 return 0;
00423 }
00424
00425 ACE_INLINE int
00426 ACE_WFMO_Reactor_Handler_Repository::unbind (ACE_HANDLE handle,
00427 ACE_Reactor_Mask mask)
00428 {
00429 if (this->invalid_handle (handle))
00430 return -1;
00431
00432 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->wfmo_reactor_.lock_, -1);
00433
00434 int changes_required = 0;
00435 int const result = this->unbind_i (handle,
00436 mask,
00437 changes_required);
00438
00439 if (changes_required)
00440
00441
00442 this->wfmo_reactor_.wakeup_all_threads ();
00443
00444 return result;
00445 }
00446
00447 ACE_INLINE int
00448 ACE_WFMO_Reactor::reset_timer_interval
00449 (long timer_id,
00450 const ACE_Time_Value &interval)
00451 {
00452 ACE_TRACE ("ACE_WFMO_Reactor::reset_timer_interval");
00453
00454 if (0 != this->timer_queue_)
00455 {
00456 long result = this->timer_queue_->reset_interval
00457 (timer_id,
00458 interval);
00459
00460
00461 this->notify ();
00462
00463 return result;
00464 }
00465
00466 errno = ESHUTDOWN;
00467 return -1;
00468 }
00469
00470 ACE_INLINE long
00471 ACE_WFMO_Reactor::schedule_timer (ACE_Event_Handler *handler,
00472 const void *arg,
00473 const ACE_Time_Value &delay_time,
00474 const ACE_Time_Value &interval)
00475 {
00476 ACE_TRACE ("ACE_WFMO_Reactor::schedule_timer");
00477
00478 if (0 != this->timer_queue_)
00479 {
00480 long result = this->timer_queue_->schedule
00481 (handler,
00482 arg,
00483 timer_queue_->gettimeofday () + delay_time,
00484 interval);
00485
00486
00487 this->notify ();
00488
00489 return result;
00490 }
00491
00492 errno = ESHUTDOWN;
00493 return -1;
00494 }
00495
00496 ACE_INLINE int
00497 ACE_WFMO_Reactor::cancel_timer (ACE_Event_Handler *handler,
00498 int dont_call_handle_close)
00499 {
00500 ACE_TRACE ("ACE_WFMO_Reactor::cancel_timer");
00501 if (0 != this->timer_queue_)
00502 return this->timer_queue_->cancel (handler, dont_call_handle_close);
00503 return 0;
00504 }
00505
00506 ACE_INLINE int
00507 ACE_WFMO_Reactor::cancel_timer (long timer_id,
00508 const void **arg,
00509 int dont_call_handle_close)
00510 {
00511 ACE_TRACE ("ACE_WFMO_Reactor::cancel_timer");
00512 if (0 != this->timer_queue_)
00513 return this->timer_queue_->cancel (timer_id, arg, dont_call_handle_close);
00514 return 0;
00515 }
00516
00517 ACE_INLINE int
00518 ACE_WFMO_Reactor::register_handler (ACE_Event_Handler *event_handler,
00519 ACE_HANDLE event_handle)
00520 {
00521
00522 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00523
00524 return this->handler_rep_.bind_i (0,
00525 event_handler,
00526 0,
00527 ACE_INVALID_HANDLE,
00528 event_handle,
00529 0);
00530 }
00531
00532 ACE_INLINE int
00533 ACE_WFMO_Reactor::register_handler (ACE_Event_Handler *event_handler,
00534 ACE_Reactor_Mask mask)
00535 {
00536
00537 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00538
00539 return this->register_handler_i (ACE_INVALID_HANDLE,
00540 ACE_INVALID_HANDLE,
00541 event_handler,
00542 mask);
00543 }
00544
00545 ACE_INLINE int
00546 ACE_WFMO_Reactor::register_handler (ACE_HANDLE io_handle,
00547 ACE_Event_Handler *event_handler,
00548 ACE_Reactor_Mask mask)
00549 {
00550
00551 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00552
00553 return this->register_handler_i (ACE_INVALID_HANDLE,
00554 io_handle,
00555 event_handler,
00556 mask);
00557 }
00558
00559 ACE_INLINE int
00560 ACE_WFMO_Reactor::register_handler (ACE_HANDLE event_handle,
00561 ACE_HANDLE io_handle,
00562 ACE_Event_Handler *event_handler,
00563 ACE_Reactor_Mask mask)
00564 {
00565
00566 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00567
00568 return this->register_handler_i (event_handle,
00569 io_handle,
00570 event_handler,
00571 mask);
00572 }
00573
00574 ACE_INLINE int
00575 ACE_WFMO_Reactor::register_handler (const ACE_Handle_Set &handles,
00576 ACE_Event_Handler *handler,
00577 ACE_Reactor_Mask mask)
00578 {
00579
00580 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00581
00582 ACE_Handle_Set_Iterator handle_iter (handles);
00583 ACE_HANDLE h;
00584
00585 while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00586 if (this->register_handler_i (h,
00587 ACE_INVALID_HANDLE,
00588 handler,
00589 mask) == -1)
00590 return -1;
00591
00592 return 0;
00593 }
00594
00595 ACE_INLINE int
00596 ACE_WFMO_Reactor::schedule_wakeup (ACE_HANDLE io_handle,
00597 ACE_Reactor_Mask masks_to_be_added)
00598 {
00599
00600 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00601
00602 return this->mask_ops_i (io_handle,
00603 masks_to_be_added,
00604 ACE_Reactor::ADD_MASK);
00605 }
00606
00607 ACE_INLINE int
00608 ACE_WFMO_Reactor::schedule_wakeup (ACE_Event_Handler *event_handler,
00609 ACE_Reactor_Mask masks_to_be_added)
00610 {
00611
00612 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00613
00614 return this->mask_ops_i (event_handler->get_handle (),
00615 masks_to_be_added,
00616 ACE_Reactor::ADD_MASK);
00617 }
00618
00619 ACE_INLINE int
00620 ACE_WFMO_Reactor::cancel_wakeup (ACE_HANDLE io_handle,
00621 ACE_Reactor_Mask masks_to_be_removed)
00622 {
00623
00624 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00625
00626 return this->mask_ops_i (io_handle,
00627 masks_to_be_removed,
00628 ACE_Reactor::CLR_MASK);
00629 }
00630
00631 ACE_INLINE int
00632 ACE_WFMO_Reactor::cancel_wakeup (ACE_Event_Handler *event_handler,
00633 ACE_Reactor_Mask masks_to_be_removed)
00634 {
00635
00636 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00637
00638 return this->mask_ops_i (event_handler->get_handle (),
00639 masks_to_be_removed,
00640 ACE_Reactor::CLR_MASK);
00641 }
00642
00643 ACE_INLINE int
00644 ACE_WFMO_Reactor::remove_handler (ACE_Event_Handler *event_handler,
00645 ACE_Reactor_Mask mask)
00646 {
00647 return this->handler_rep_.unbind (event_handler->get_handle (),
00648 mask);
00649 }
00650
00651 ACE_INLINE int
00652 ACE_WFMO_Reactor::remove_handler (ACE_HANDLE handle,
00653 ACE_Reactor_Mask mask)
00654 {
00655 return this->handler_rep_.unbind (handle,
00656 mask);
00657 }
00658
00659 ACE_INLINE int
00660 ACE_WFMO_Reactor::remove_handler (const ACE_Handle_Set &handles,
00661 ACE_Reactor_Mask mask)
00662 {
00663 ACE_Handle_Set_Iterator handle_iter (handles);
00664 ACE_HANDLE h;
00665 int changes_required = 0;
00666
00667 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00668
00669 while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00670 if (this->handler_rep_.unbind_i (h,
00671 mask,
00672 changes_required) == -1)
00673 return -1;
00674
00675
00676
00677 this->wakeup_all_threads ();
00678
00679 return 0;
00680 }
00681
00682 ACE_INLINE int
00683 ACE_WFMO_Reactor::suspend_handler (ACE_HANDLE handle)
00684 {
00685 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00686
00687 int changes_required = 0;
00688 int const result =
00689 this->handler_rep_.suspend_handler_i (handle,
00690 changes_required);
00691
00692 if (changes_required)
00693
00694
00695 this->wakeup_all_threads ();
00696
00697 return result;
00698 }
00699
00700 ACE_INLINE int
00701 ACE_WFMO_Reactor::suspend_handler (ACE_Event_Handler *event_handler)
00702 {
00703 return this->suspend_handler (event_handler->get_handle ());
00704 }
00705
00706 ACE_INLINE int
00707 ACE_WFMO_Reactor::suspend_handler (const ACE_Handle_Set &handles)
00708 {
00709 ACE_Handle_Set_Iterator handle_iter (handles);
00710 ACE_HANDLE h;
00711 int changes_required = 0;
00712
00713 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00714
00715 while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00716 if (this->handler_rep_.suspend_handler_i (h,
00717 changes_required) == -1)
00718 return -1;
00719
00720
00721
00722 this->wakeup_all_threads ();
00723
00724 return 0;
00725 }
00726
00727 ACE_INLINE int
00728 ACE_WFMO_Reactor::suspend_handlers (void)
00729 {
00730 int error = 0;
00731 int result = 0;
00732 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00733
00734
00735 int changes_required = 0;
00736
00737 for (size_t i = 0;
00738 i < this->handler_rep_.max_handlep1_ && error == 0;
00739 i++)
00740 {
00741 result =
00742 this->handler_rep_.suspend_handler_i (this->handler_rep_.current_handles_[i],
00743 changes_required);
00744 if (result == -1)
00745 error = 1;
00746 }
00747
00748 if (!error)
00749
00750 for (size_t i = 0;
00751 i < this->handler_rep_.handles_to_be_added_;
00752 i++)
00753 this->handler_rep_.to_be_added_info_[i].suspend_entry_ = 1;
00754
00755
00756
00757 this->wakeup_all_threads ();
00758
00759 return error ? -1 : 0;
00760 }
00761
00762 ACE_INLINE int
00763 ACE_WFMO_Reactor::resume_handler (ACE_HANDLE handle)
00764 {
00765 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00766
00767 int changes_required = 0;
00768 int result =
00769 this->handler_rep_.resume_handler_i (handle,
00770 changes_required);
00771
00772 if (changes_required)
00773
00774
00775 this->wakeup_all_threads ();
00776
00777 return result;
00778 }
00779
00780 ACE_INLINE int
00781 ACE_WFMO_Reactor::resume_handler (ACE_Event_Handler *event_handler)
00782 {
00783 return this->resume_handler (event_handler->get_handle ());
00784 }
00785
00786 ACE_INLINE int
00787 ACE_WFMO_Reactor::resume_handler (const ACE_Handle_Set &handles)
00788 {
00789 ACE_Handle_Set_Iterator handle_iter (handles);
00790 ACE_HANDLE h;
00791 int changes_required = 0;
00792
00793 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00794
00795 while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00796 if (this->handler_rep_.resume_handler_i (h,
00797 changes_required) == -1)
00798 return -1;
00799
00800
00801
00802 this->wakeup_all_threads ();
00803
00804 return 0;
00805 }
00806
00807 ACE_INLINE int
00808 ACE_WFMO_Reactor::resume_handlers (void)
00809 {
00810 int error = 0;
00811 int result = 0;
00812 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00813
00814 int changes_required = 0;
00815 for (size_t i = 0;
00816 i < this->handler_rep_.suspended_handles_ && error == 0;
00817 i++)
00818 {
00819 result =
00820 this->handler_rep_.resume_handler_i (this->handler_rep_.current_suspended_info_[i].event_handle_,
00821 changes_required);
00822 if (result == -1)
00823 error = 1;
00824 }
00825
00826 if (!error)
00827
00828 for (size_t i = 0;
00829 i < this->handler_rep_.handles_to_be_added_;
00830 i++)
00831 this->handler_rep_.to_be_added_info_[i].suspend_entry_ = 0;
00832
00833
00834
00835 this->wakeup_all_threads ();
00836
00837 return error ? -1 : 0;
00838 }
00839
00840 ACE_INLINE int
00841 ACE_WFMO_Reactor::uses_event_associations (void)
00842 {
00843
00844
00845 return 1;
00846 }
00847
00848 ACE_INLINE int
00849 ACE_WFMO_Reactor::handle_events (ACE_Time_Value &how_long)
00850 {
00851 return this->event_handling (&how_long, FALSE);
00852 }
00853
00854 ACE_INLINE int
00855 ACE_WFMO_Reactor::alertable_handle_events (ACE_Time_Value &how_long)
00856 {
00857 return this->event_handling (&how_long, TRUE);
00858 }
00859
00860 ACE_INLINE int
00861 ACE_WFMO_Reactor::handle_events (ACE_Time_Value *how_long)
00862 {
00863 return this->event_handling (how_long, FALSE);
00864 }
00865
00866 ACE_INLINE int
00867 ACE_WFMO_Reactor::alertable_handle_events (ACE_Time_Value *how_long)
00868 {
00869 return this->event_handling (how_long, TRUE);
00870 }
00871
00872 ACE_INLINE int
00873 ACE_WFMO_Reactor::deactivated (void)
00874 {
00875 return this->deactivated_;
00876 }
00877
00878 ACE_INLINE void
00879 ACE_WFMO_Reactor::deactivate (int do_stop)
00880 {
00881 this->deactivated_ = do_stop;
00882 this->wakeup_all_threads ();
00883 }
00884
00885 ACE_INLINE int
00886 ACE_WFMO_Reactor::owner (ACE_thread_t *t)
00887 {
00888 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00889 *t = this->owner_i ();
00890 return 0;
00891 }
00892
00893 ACE_INLINE ACE_thread_t
00894 ACE_WFMO_Reactor::owner_i (void)
00895 {
00896 return this->owner_;
00897 }
00898
00899 ACE_INLINE int
00900 ACE_WFMO_Reactor::owner (ACE_thread_t new_owner, ACE_thread_t *old_owner)
00901 {
00902 ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
00903 this->new_owner_ = new_owner;
00904
00905 if (old_owner != 0)
00906 *old_owner = this->owner_i ();
00907
00908
00909
00910 this->wakeup_all_threads ();
00911
00912 return 0;
00913 }
00914
00915 ACE_INLINE int
00916 ACE_WFMO_Reactor::new_owner (void)
00917 {
00918 return this->new_owner_ != ACE_thread_t (0);
00919 }
00920
00921 ACE_INLINE int
00922 ACE_WFMO_Reactor::change_owner (void)
00923 {
00924 this->owner_ = this->new_owner_;
00925 this->new_owner_ = ACE_thread_t (0);
00926 return 0;
00927 }
00928
00929 ACE_INLINE int
00930 ACE_WFMO_Reactor::safe_dispatch (DWORD wait_status)
00931 {
00932 int result = -1;
00933 ACE_SEH_TRY
00934 {
00935 result = this->dispatch (wait_status);
00936 }
00937 ACE_SEH_FINALLY
00938 {
00939 this->update_state ();
00940 }
00941
00942 return result;
00943 }
00944
00945 ACE_INLINE int
00946 ACE_WFMO_Reactor::dispatch_window_messages (void)
00947 {
00948 return 0;
00949 }
00950
00951 ACE_INLINE void
00952 ACE_WFMO_Reactor::wakeup_all_threads (void)
00953 {
00954 this->wakeup_all_threads_.signal ();
00955 }
00956
00957 ACE_INLINE int
00958 ACE_WFMO_Reactor::notify (ACE_Event_Handler *event_handler,
00959 ACE_Reactor_Mask mask,
00960 ACE_Time_Value *timeout)
00961 {
00962 return this->notify_handler_->notify (event_handler, mask, timeout);
00963 }
00964
00965 ACE_INLINE int
00966 ACE_WFMO_Reactor::register_handler (int signum,
00967 ACE_Event_Handler *new_sh,
00968 ACE_Sig_Action *new_disp,
00969 ACE_Event_Handler **old_sh,
00970 ACE_Sig_Action *old_disp)
00971 {
00972 return this->signal_handler_->register_handler (signum,
00973 new_sh, new_disp,
00974 old_sh, old_disp);
00975 }
00976
00977 ACE_INLINE int
00978 ACE_WFMO_Reactor::register_handler (const ACE_Sig_Set &sigset,
00979 ACE_Event_Handler *new_sh,
00980 ACE_Sig_Action *new_disp)
00981 {
00982 int result = 0;
00983
00984 #if (ACE_NSIG > 0)
00985 for (int s = 1; s < ACE_NSIG; s++)
00986 if (sigset.is_member (s)
00987 && this->signal_handler_->register_handler (s,
00988 new_sh,
00989 new_disp) == -1)
00990 result = -1;
00991 #else
00992 ACE_UNUSED_ARG (sigset);
00993 ACE_UNUSED_ARG (new_sh);
00994 ACE_UNUSED_ARG (new_disp);
00995 #endif
00996
00997 return result;
00998 }
00999
01000 ACE_INLINE int
01001 ACE_WFMO_Reactor::remove_handler (int signum,
01002 ACE_Sig_Action *new_disp,
01003 ACE_Sig_Action *old_disp,
01004 int sigkey)
01005 {
01006 return this->signal_handler_->remove_handler (signum,
01007 new_disp,
01008 old_disp,
01009 sigkey);
01010 }
01011
01012 ACE_INLINE int
01013 ACE_WFMO_Reactor::remove_handler (const ACE_Sig_Set &sigset)
01014 {
01015 int result = 0;
01016
01017 #if (ACE_NSIG > 0)
01018 for (int s = 1; s < ACE_NSIG; s++)
01019 if (sigset.is_member (s)
01020 && this->signal_handler_->remove_handler (s) == -1)
01021 result = -1;
01022 #else
01023 ACE_UNUSED_ARG (sigset);
01024 #endif
01025
01026 return result;
01027 }
01028
01029 ACE_INLINE int
01030 ACE_WFMO_Reactor::handler (int signum, ACE_Event_Handler **eh)
01031 {
01032 ACE_Event_Handler *handler =
01033 this->signal_handler_->handler (signum);
01034
01035 if (handler == 0)
01036 return -1;
01037 else if (eh != 0)
01038 *eh = handler;
01039 return 0;
01040 }
01041
01042 ACE_INLINE int
01043 ACE_WFMO_Reactor::mask_ops (ACE_Event_Handler *event_handler,
01044 ACE_Reactor_Mask mask,
01045 int operation)
01046 {
01047 ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
01048
01049 return this->mask_ops_i (event_handler->get_handle (),
01050 mask,
01051 operation);
01052 }
01053
01054 ACE_INLINE int
01055 ACE_WFMO_Reactor::mask_ops (ACE_HANDLE io_handle,
01056 ACE_Reactor_Mask mask,
01057 int operation)
01058 {
01059 ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
01060
01061 return this->mask_ops_i (io_handle,
01062 mask,
01063 operation);
01064 }
01065
01066 ACE_INLINE void
01067 ACE_WFMO_Reactor::requeue_position (int)
01068 {
01069
01070 }
01071
01072 ACE_INLINE int
01073 ACE_WFMO_Reactor::requeue_position (void)
01074 {
01075
01076 ACE_NOTSUP_RETURN (-1);
01077 }
01078
01079 ACE_INLINE int
01080 ACE_WFMO_Reactor::restart (void)
01081 {
01082 return 0;
01083 }
01084
01085 ACE_INLINE int
01086 ACE_WFMO_Reactor::restart (int)
01087 {
01088 return 0;
01089 }
01090
01091 ACE_INLINE int
01092 ACE_WFMO_Reactor::ready_ops (ACE_Event_Handler *event_handler,
01093 ACE_Reactor_Mask mask,
01094 int ops)
01095 {
01096
01097 ACE_UNUSED_ARG (event_handler);
01098 ACE_UNUSED_ARG (mask);
01099 ACE_UNUSED_ARG (ops);
01100 ACE_NOTSUP_RETURN (-1);
01101 }
01102
01103 ACE_INLINE int
01104 ACE_WFMO_Reactor::ready_ops (ACE_HANDLE handle,
01105 ACE_Reactor_Mask,
01106 int ops)
01107 {
01108
01109 ACE_UNUSED_ARG (handle);
01110 ACE_UNUSED_ARG (ops);
01111 ACE_NOTSUP_RETURN (-1);
01112 }
01113
01114 ACE_INLINE ACE_Event_Handler *
01115 ACE_WFMO_Reactor::find_handler (ACE_HANDLE handle)
01116 {
01117 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, 0);
01118
01119 return this->handler_rep_.find_handler (handle);
01120 }
01121
01122 ACE_INLINE int
01123 ACE_WFMO_Reactor::handler (ACE_HANDLE handle,
01124 ACE_Reactor_Mask mask,
01125 ACE_Event_Handler **event_handler)
01126 {
01127 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
01128
01129 return this->handler_rep_.handler (handle,
01130 mask,
01131 event_handler);
01132 }
01133
01134 ACE_INLINE int
01135 ACE_WFMO_Reactor::initialized (void)
01136 {
01137 return this->open_for_business_;
01138 }
01139
01140 ACE_INLINE ACE_Lock &
01141 ACE_WFMO_Reactor::lock (void)
01142 {
01143 return this->lock_adapter_;
01144 }
01145
01146 ACE_INLINE size_t
01147 ACE_WFMO_Reactor::size (void) const
01148 {
01149
01150 return this->handler_rep_.max_size_ - 2;
01151 }
01152 #else
01153 ACE_INLINE int
01154 ACE_WFMO_Reactor_Handler_Repository::changes_required (void)
01155 {
01156 return 0;
01157 }
01158
01159 ACE_INLINE int
01160 ACE_WFMO_Reactor_Handler_Repository::make_changes (void)
01161 {
01162 return 0;
01163 }
01164
01165 ACE_INLINE
01166 ACE_WFMO_Reactor_Handler_Repository::~ACE_WFMO_Reactor_Handler_Repository (void)
01167 {
01168 }
01169
01170 #endif
01171
01172 ACE_END_VERSIONED_NAMESPACE_DECL