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