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_ (0),
00033 event_handler_ (0),
00034 io_handle_ (ACE_INVALID_HANDLE),
00035 network_events_ (0),
00036 delete_event_ (0),
00037 delete_entry_ (0),
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_ = 0;
00047 this->io_handle_ = ACE_INVALID_HANDLE;
00048 this->network_events_ = 0;
00049 this->delete_event_ = 0;
00050 this->delete_entry_ = 0;
00051 this->close_masks_ = ACE_Event_Handler::NULL_MASK;
00052 }
00053
00054 ACE_INLINE void
00055 ACE_WFMO_Reactor_Handler_Repository::Common_Info::set (int io_entry,
00056 ACE_Event_Handler *event_handler,
00057 ACE_HANDLE io_handle,
00058 long network_events,
00059 int delete_event,
00060 int 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_ (0)
00123 {
00124 }
00125
00126 ACE_INLINE void
00127 ACE_WFMO_Reactor_Handler_Repository::Current_Info::set (int io_entry,
00128 ACE_Event_Handler *event_handler,
00129 ACE_HANDLE io_handle,
00130 long network_events,
00131 int delete_event,
00132 int delete_entry,
00133 ACE_Reactor_Mask close_masks,
00134 int 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 int 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_ = 0;
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_ (0)
00191 {
00192 }
00193
00194 ACE_INLINE void
00195 ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::set (ACE_HANDLE event_handle,
00196 int io_entry,
00197 ACE_Event_Handler *event_handler,
00198 ACE_HANDLE io_handle,
00199 long network_events,
00200 int delete_event,
00201 int delete_entry,
00202 ACE_Reactor_Mask close_masks,
00203 int 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 int 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_ = 0;
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_ (0)
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_ = 0;
00270 Common_Info::reset ();
00271 }
00272
00273 ACE_INLINE void
00274 ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::set (ACE_HANDLE event_handle,
00275 int io_entry,
00276 ACE_Event_Handler *event_handler,
00277 ACE_HANDLE io_handle,
00278 long network_events,
00279 int delete_event,
00280 int delete_entry,
00281 ACE_Reactor_Mask close_masks,
00282 int 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 int 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_ == 1;
00376 else
00377 return this->current_info_[slot + 1].delete_entry_ == 1;
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 int
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 int changes_required = 0;
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 int changes_required = 0;
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 int changes_required = 0;
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 int changes_required = 0;
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 int error = 0;
00732 int result = 0;
00733 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00734
00735
00736 int changes_required = 0;
00737
00738 for (size_t i = 0;
00739 i < this->handler_rep_.max_handlep1_ && error == 0;
00740 i++)
00741 {
00742 result =
00743 this->handler_rep_.suspend_handler_i (this->handler_rep_.current_handles_[i],
00744 changes_required);
00745 if (result == -1)
00746 error = 1;
00747 }
00748
00749 if (!error)
00750
00751 for (size_t i = 0;
00752 i < this->handler_rep_.handles_to_be_added_;
00753 i++)
00754 this->handler_rep_.to_be_added_info_[i].suspend_entry_ = 1;
00755
00756
00757
00758 this->wakeup_all_threads ();
00759
00760 return error ? -1 : 0;
00761 }
00762
00763 ACE_INLINE int
00764 ACE_WFMO_Reactor::resume_handler (ACE_HANDLE handle)
00765 {
00766 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00767
00768 int changes_required = 0;
00769 int result =
00770 this->handler_rep_.resume_handler_i (handle,
00771 changes_required);
00772
00773 if (changes_required)
00774
00775
00776 this->wakeup_all_threads ();
00777
00778 return result;
00779 }
00780
00781 ACE_INLINE int
00782 ACE_WFMO_Reactor::resume_handler (ACE_Event_Handler *event_handler)
00783 {
00784 return this->resume_handler (event_handler->get_handle ());
00785 }
00786
00787 ACE_INLINE int
00788 ACE_WFMO_Reactor::resume_handler (const ACE_Handle_Set &handles)
00789 {
00790 ACE_Handle_Set_Iterator handle_iter (handles);
00791 ACE_HANDLE h;
00792 int changes_required = 0;
00793
00794 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00795
00796 while ((h = handle_iter ()) != ACE_INVALID_HANDLE)
00797 if (this->handler_rep_.resume_handler_i (h,
00798 changes_required) == -1)
00799 return -1;
00800
00801
00802
00803 this->wakeup_all_threads ();
00804
00805 return 0;
00806 }
00807
00808 ACE_INLINE int
00809 ACE_WFMO_Reactor::resume_handlers (void)
00810 {
00811 int error = 0;
00812 int result = 0;
00813 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00814
00815 int changes_required = 0;
00816 for (size_t i = 0;
00817 i < this->handler_rep_.suspended_handles_ && error == 0;
00818 i++)
00819 {
00820 result =
00821 this->handler_rep_.resume_handler_i (this->handler_rep_.current_suspended_info_[i].event_handle_,
00822 changes_required);
00823 if (result == -1)
00824 error = 1;
00825 }
00826
00827 if (!error)
00828
00829 for (size_t i = 0;
00830 i < this->handler_rep_.handles_to_be_added_;
00831 i++)
00832 this->handler_rep_.to_be_added_info_[i].suspend_entry_ = 0;
00833
00834
00835
00836 this->wakeup_all_threads ();
00837
00838 return error ? -1 : 0;
00839 }
00840
00841 ACE_INLINE int
00842 ACE_WFMO_Reactor::uses_event_associations (void)
00843 {
00844
00845
00846 return 1;
00847 }
00848
00849 ACE_INLINE int
00850 ACE_WFMO_Reactor::handle_events (ACE_Time_Value &how_long)
00851 {
00852 return this->event_handling (&how_long, FALSE);
00853 }
00854
00855 ACE_INLINE int
00856 ACE_WFMO_Reactor::alertable_handle_events (ACE_Time_Value &how_long)
00857 {
00858 return this->event_handling (&how_long, TRUE);
00859 }
00860
00861 ACE_INLINE int
00862 ACE_WFMO_Reactor::handle_events (ACE_Time_Value *how_long)
00863 {
00864 return this->event_handling (how_long, FALSE);
00865 }
00866
00867 ACE_INLINE int
00868 ACE_WFMO_Reactor::alertable_handle_events (ACE_Time_Value *how_long)
00869 {
00870 return this->event_handling (how_long, TRUE);
00871 }
00872
00873 ACE_INLINE int
00874 ACE_WFMO_Reactor::deactivated (void)
00875 {
00876 return this->deactivated_;
00877 }
00878
00879 ACE_INLINE void
00880 ACE_WFMO_Reactor::deactivate (int do_stop)
00881 {
00882 this->deactivated_ = do_stop;
00883 this->wakeup_all_threads ();
00884 }
00885
00886 ACE_INLINE int
00887 ACE_WFMO_Reactor::owner (ACE_thread_t *t)
00888 {
00889 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
00890 *t = this->owner_i ();
00891 return 0;
00892 }
00893
00894 ACE_INLINE ACE_thread_t
00895 ACE_WFMO_Reactor::owner_i (void)
00896 {
00897 return this->owner_;
00898 }
00899
00900 ACE_INLINE int
00901 ACE_WFMO_Reactor::owner (ACE_thread_t new_owner, ACE_thread_t *old_owner)
00902 {
00903 ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
00904 this->new_owner_ = new_owner;
00905
00906 if (old_owner != 0)
00907 *old_owner = this->owner_i ();
00908
00909
00910
00911 this->wakeup_all_threads ();
00912
00913 return 0;
00914 }
00915
00916 ACE_INLINE int
00917 ACE_WFMO_Reactor::new_owner (void)
00918 {
00919 return this->new_owner_ != ACE_thread_t (0);
00920 }
00921
00922 ACE_INLINE int
00923 ACE_WFMO_Reactor::change_owner (void)
00924 {
00925 this->owner_ = this->new_owner_;
00926 this->new_owner_ = ACE_thread_t (0);
00927 return 0;
00928 }
00929
00930 ACE_INLINE int
00931 ACE_WFMO_Reactor::safe_dispatch (DWORD wait_status)
00932 {
00933 int result = -1;
00934 ACE_SEH_TRY
00935 {
00936 result = this->dispatch (wait_status);
00937 }
00938 ACE_SEH_FINALLY
00939 {
00940 this->update_state ();
00941 }
00942
00943 return result;
00944 }
00945
00946 ACE_INLINE int
00947 ACE_WFMO_Reactor::dispatch_window_messages (void)
00948 {
00949 return 0;
00950 }
00951
00952 ACE_INLINE void
00953 ACE_WFMO_Reactor::wakeup_all_threads (void)
00954 {
00955 this->wakeup_all_threads_.signal ();
00956 }
00957
00958 ACE_INLINE int
00959 ACE_WFMO_Reactor::notify (ACE_Event_Handler *event_handler,
00960 ACE_Reactor_Mask mask,
00961 ACE_Time_Value *timeout)
00962 {
00963 return this->notify_handler_->notify (event_handler, mask, timeout);
00964 }
00965
00966 ACE_INLINE int
00967 ACE_WFMO_Reactor::register_handler (int signum,
00968 ACE_Event_Handler *new_sh,
00969 ACE_Sig_Action *new_disp,
00970 ACE_Event_Handler **old_sh,
00971 ACE_Sig_Action *old_disp)
00972 {
00973 return this->signal_handler_->register_handler (signum,
00974 new_sh, new_disp,
00975 old_sh, old_disp);
00976 }
00977
00978 ACE_INLINE int
00979 ACE_WFMO_Reactor::register_handler (const ACE_Sig_Set &sigset,
00980 ACE_Event_Handler *new_sh,
00981 ACE_Sig_Action *new_disp)
00982 {
00983 int result = 0;
00984
00985 #if (ACE_NSIG > 0)
00986 for (int s = 1; s < ACE_NSIG; s++)
00987 if (sigset.is_member (s)
00988 && this->signal_handler_->register_handler (s,
00989 new_sh,
00990 new_disp) == -1)
00991 result = -1;
00992 #else
00993 ACE_UNUSED_ARG (sigset);
00994 ACE_UNUSED_ARG (new_sh);
00995 ACE_UNUSED_ARG (new_disp);
00996 #endif
00997
00998 return result;
00999 }
01000
01001 ACE_INLINE int
01002 ACE_WFMO_Reactor::remove_handler (int signum,
01003 ACE_Sig_Action *new_disp,
01004 ACE_Sig_Action *old_disp,
01005 int sigkey)
01006 {
01007 return this->signal_handler_->remove_handler (signum,
01008 new_disp,
01009 old_disp,
01010 sigkey);
01011 }
01012
01013 ACE_INLINE int
01014 ACE_WFMO_Reactor::remove_handler (const ACE_Sig_Set &sigset)
01015 {
01016 int result = 0;
01017
01018 #if (ACE_NSIG > 0)
01019 for (int s = 1; s < ACE_NSIG; s++)
01020 if (sigset.is_member (s)
01021 && this->signal_handler_->remove_handler (s) == -1)
01022 result = -1;
01023 #else
01024 ACE_UNUSED_ARG (sigset);
01025 #endif
01026
01027 return result;
01028 }
01029
01030 ACE_INLINE int
01031 ACE_WFMO_Reactor::handler (int signum, ACE_Event_Handler **eh)
01032 {
01033 ACE_Event_Handler *handler =
01034 this->signal_handler_->handler (signum);
01035
01036 if (handler == 0)
01037 return -1;
01038 else if (eh != 0)
01039 *eh = handler;
01040 return 0;
01041 }
01042
01043 ACE_INLINE int
01044 ACE_WFMO_Reactor::mask_ops (ACE_Event_Handler *event_handler,
01045 ACE_Reactor_Mask mask,
01046 int operation)
01047 {
01048 ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
01049
01050 return this->mask_ops_i (event_handler->get_handle (),
01051 mask,
01052 operation);
01053 }
01054
01055 ACE_INLINE int
01056 ACE_WFMO_Reactor::mask_ops (ACE_HANDLE io_handle,
01057 ACE_Reactor_Mask mask,
01058 int operation)
01059 {
01060 ACE_GUARD_RETURN (ACE_Process_Mutex, monitor, this->lock_, -1);
01061
01062 return this->mask_ops_i (io_handle,
01063 mask,
01064 operation);
01065 }
01066
01067 ACE_INLINE void
01068 ACE_WFMO_Reactor::requeue_position (int)
01069 {
01070
01071 }
01072
01073 ACE_INLINE int
01074 ACE_WFMO_Reactor::requeue_position (void)
01075 {
01076
01077 ACE_NOTSUP_RETURN (-1);
01078 }
01079
01080 ACE_INLINE int
01081 ACE_WFMO_Reactor::restart (void)
01082 {
01083 return 0;
01084 }
01085
01086 ACE_INLINE int
01087 ACE_WFMO_Reactor::restart (int)
01088 {
01089 return 0;
01090 }
01091
01092 ACE_INLINE int
01093 ACE_WFMO_Reactor::ready_ops (ACE_Event_Handler *event_handler,
01094 ACE_Reactor_Mask mask,
01095 int ops)
01096 {
01097
01098 ACE_UNUSED_ARG (event_handler);
01099 ACE_UNUSED_ARG (mask);
01100 ACE_UNUSED_ARG (ops);
01101 ACE_NOTSUP_RETURN (-1);
01102 }
01103
01104 ACE_INLINE int
01105 ACE_WFMO_Reactor::ready_ops (ACE_HANDLE handle,
01106 ACE_Reactor_Mask,
01107 int ops)
01108 {
01109
01110 ACE_UNUSED_ARG (handle);
01111 ACE_UNUSED_ARG (ops);
01112 ACE_NOTSUP_RETURN (-1);
01113 }
01114
01115 ACE_INLINE ACE_Event_Handler *
01116 ACE_WFMO_Reactor::find_handler (ACE_HANDLE handle)
01117 {
01118 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, 0);
01119
01120 return this->handler_rep_.find_handler (handle);
01121 }
01122
01123 ACE_INLINE int
01124 ACE_WFMO_Reactor::handler (ACE_HANDLE handle,
01125 ACE_Reactor_Mask mask,
01126 ACE_Event_Handler **event_handler)
01127 {
01128 ACE_GUARD_RETURN (ACE_Process_Mutex, ace_mon, this->lock_, -1);
01129
01130 return this->handler_rep_.handler (handle,
01131 mask,
01132 event_handler);
01133 }
01134
01135 ACE_INLINE bool
01136 ACE_WFMO_Reactor::initialized (void)
01137 {
01138 return this->open_for_business_;
01139 }
01140
01141 ACE_INLINE ACE_Lock &
01142 ACE_WFMO_Reactor::lock (void)
01143 {
01144 return this->lock_adapter_;
01145 }
01146
01147 ACE_INLINE size_t
01148 ACE_WFMO_Reactor::size (void) const
01149 {
01150
01151 return this->handler_rep_.max_size_ - 2;
01152 }
01153 #else
01154 ACE_INLINE int
01155 ACE_WFMO_Reactor_Handler_Repository::changes_required (void)
01156 {
01157 return 0;
01158 }
01159
01160 ACE_INLINE int
01161 ACE_WFMO_Reactor_Handler_Repository::make_changes (void)
01162 {
01163 return 0;
01164 }
01165
01166 ACE_INLINE
01167 ACE_WFMO_Reactor_Handler_Repository::~ACE_WFMO_Reactor_Handler_Repository (void)
01168 {
01169 }
01170
01171 #endif
01172
01173 ACE_END_VERSIONED_NAMESPACE_DECL