#include <WFMO_Reactor.h>
Collaboration diagram for ACE_WFMO_Reactor_Handler_Repository:

Public Member Functions | |
| ACE_WFMO_Reactor_Handler_Repository (ACE_WFMO_Reactor &wfmo_reactor) | |
| Constructor. | |
| virtual | ~ACE_WFMO_Reactor_Handler_Repository (void) |
| Destructor. | |
| int | open (size_t size) |
| Initialize the repository of the approriate . | |
| int | close (void) |
| Close down the handler repository. | |
| int | bind (ACE_HANDLE, ACE_Event_Handler *) |
| int | bind_i (int io_entry, ACE_Event_Handler *event_handler, long network_events, ACE_HANDLE io_handle, ACE_HANDLE event_handle, int delete_event) |
| int | unbind (ACE_HANDLE, ACE_Reactor_Mask mask) |
| Remove the binding of ACE_HANDLE in accordance with the . | |
| int | unbind_i (ACE_HANDLE, ACE_Reactor_Mask mask, int &changes_required) |
| Non-lock-grabbing version of . | |
| void | unbind_all (void) |
| Remove all bindings of <ACE_HANDLE, ACE_Event_Handler> tuples. | |
| int | invalid_handle (ACE_HANDLE handle) const |
| DWORD | max_handlep1 (void) const |
| Maximum ACE_HANDLE value, plus 1. | |
| ACE_HANDLE * | handles (void) const |
| Current_Info * | current_info (void) const |
| virtual int | changes_required (void) |
| Check if changes to the handle set are required. | |
| virtual int | make_changes (void) |
| Make changes to the handle set. | |
| int | scheduled_for_deletion (size_t slot) const |
| Check to see if has been scheduled for deletion. | |
| int | modify_network_events_i (ACE_HANDLE io_handle, ACE_Reactor_Mask new_masks, ACE_Reactor_Mask &old_masks, long &new_network_events, ACE_HANDLE &event_handle, int &delete_event, int operation) |
| ACE_Reactor_Mask | bit_ops (long &existing_masks, ACE_Reactor_Mask to_be_removed_masks, int operation) |
| int | suspend_handler_i (ACE_HANDLE handle, int &changes_required) |
| Temporarily suspend entry. | |
| int | resume_handler_i (ACE_HANDLE handle, int &changes_required) |
| Resume suspended entry. | |
| int | make_changes_in_current_infos (void) |
| Deletions and suspensions in current_info_. | |
| int | make_changes_in_suspension_infos (void) |
| Deletions and resumptions in current_suspended_info_. | |
| int | make_changes_in_to_be_added_infos (void) |
| int | remove_handler_i (size_t slot, ACE_Reactor_Mask mask) |
| Removes the ACE_Event_Handler at from the table. | |
| int | remove_suspended_handler_i (size_t slot, ACE_Reactor_Mask mask) |
| Removes the ACE_Event_Handler at from the table. | |
| int | remove_to_be_added_handler_i (size_t slot, ACE_Reactor_Mask to_be_removed_masks) |
| Removes the ACE_Event_Handler at from the table. | |
| ACE_Event_Handler * | find_handler (ACE_HANDLE handle) |
| int | handler (ACE_HANDLE handle, ACE_Reactor_Mask mask, ACE_Event_Handler **event_handler=0) |
| ACE_Event_Handler * | handler (ACE_HANDLE handle, long &existing_masks) |
| void | dump (void) const |
| Dump the state of an object. | |
Protected Attributes | |
| ACE_WFMO_Reactor & | wfmo_reactor_ |
| Reference to our . | |
| size_t | max_size_ |
| Maximum number of handles. | |
| ACE_HANDLE * | current_handles_ |
| Current_Info * | current_info_ |
| Array of current entries in the table. | |
| DWORD | max_handlep1_ |
| A count of the number of active handles. | |
| To_Be_Added_Info * | to_be_added_info_ |
| Information for entries to be added. | |
| size_t | handles_to_be_added_ |
| Number of records to be added. | |
| Suspended_Info * | current_suspended_info_ |
| Currently suspended handles. | |
| size_t | suspended_handles_ |
| Number of currently suspended handles. | |
| size_t | handles_to_be_suspended_ |
| Number of records to be suspended. | |
| size_t | handles_to_be_resumed_ |
| Number of records to be resumed. | |
| size_t | handles_to_be_deleted_ |
| Number of records to be deleted. | |
Friends | |
| class | ACE_WFMO_Reactor |
| class | ACE_WFMO_Reactor_Test |
Definition at line 103 of file WFMO_Reactor.h.
|
|
Constructor.
Definition at line 23 of file WFMO_Reactor.cpp.
00024 : wfmo_reactor_ (wfmo_reactor) 00025 { 00026 } |
|
|
Destructor.
Definition at line 67 of file WFMO_Reactor.cpp. References current_handles_, current_info_, current_suspended_info_, and to_be_added_info_. Referenced by ACE_WFMO_Reactor::open().
00068 {
00069 // Free up dynamically allocated space
00070 delete [] this->current_handles_;
00071 delete [] this->current_info_;
00072 delete [] this->current_suspended_info_;
00073 delete [] this->to_be_added_info_;
00074 }
|
|
||||||||||||
|
Bind the <ACE_Event_Handler *> to the ACE_HANDLE. This is for the simple event entry. |
|
||||||||||||||||||||||||||||
|
Insert I/O entry into the system. This method assumes that the lock are head *before* this method is invoked. Definition at line 627 of file WFMO_Reactor.cpp. References ACE_Event_Handler::add_reference(), ACE_Event_Handler::get_handle(), handles_to_be_added_, handles_to_be_deleted_, invalid_handle(), ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::set(), suspended_handles_, to_be_added_info_, ACE_WFMO_Reactor::wakeup_all_threads(), and wfmo_reactor_. Referenced by ACE_WFMO_Reactor::register_handler(), and ACE_WFMO_Reactor::register_handler_i().
00633 {
00634 // Make sure that the <handle> is valid
00635 if (event_handle == ACE_INVALID_HANDLE)
00636 event_handle = event_handler->get_handle ();
00637 if (this->invalid_handle (event_handle))
00638 return -1;
00639
00640 size_t current_size = this->max_handlep1_ +
00641 this->handles_to_be_added_ -
00642 this->handles_to_be_deleted_ +
00643 this->suspended_handles_;
00644
00645 // Make sure that there's room in the table and that total pending
00646 // additions should not exceed what the <to_be_added_info_> array
00647 // can hold.
00648 if (current_size < this->max_size_ &&
00649 this->handles_to_be_added_ < this->max_size_)
00650 {
00651 // Cache this set into the <to_be_added_info_>, till we come
00652 // around to actually adding this to the <current_info_>
00653 this->to_be_added_info_[this->handles_to_be_added_].set (event_handle,
00654 io_entry,
00655 event_handler,
00656 io_handle,
00657 network_events,
00658 delete_event);
00659
00660 ++this->handles_to_be_added_;
00661
00662 event_handler->add_reference ();
00663
00664 // Wake up all threads in WaitForMultipleObjects so that they can
00665 // reconsult the handle set
00666 this->wfmo_reactor_.wakeup_all_threads ();
00667 }
00668 else
00669 {
00670 errno = EMFILE; // File descriptor table is full (better than nothing)
00671 return -1;
00672 }
00673
00674 return 0;
00675 }
|
|
||||||||||||||||
|
This method is used to change the network mask left (if any) after a remove request to Definition at line 77 of file WFMO_Reactor.cpp. References ACE_BIT_ENABLED, ACE_CLR_BITS, ACE_Reactor_Mask, ACE_SET_BITS, FD_GROUP_QOS, and FD_QOS. Referenced by modify_network_events_i(), remove_handler_i(), remove_suspended_handler_i(), and remove_to_be_added_handler_i().
00080 {
00081 // Find the old reactor masks. This automatically does the work of
00082 // the GET_MASK operation.
00083
00084 ACE_Reactor_Mask old_masks = ACE_Event_Handler::NULL_MASK;
00085
00086 if (ACE_BIT_ENABLED (existing_masks, FD_READ)
00087 || ACE_BIT_ENABLED (existing_masks, FD_CLOSE))
00088 ACE_SET_BITS (old_masks, ACE_Event_Handler::READ_MASK);
00089
00090 if (ACE_BIT_ENABLED (existing_masks, FD_WRITE))
00091 ACE_SET_BITS (old_masks, ACE_Event_Handler::WRITE_MASK);
00092
00093 if (ACE_BIT_ENABLED (existing_masks, FD_OOB))
00094 ACE_SET_BITS (old_masks, ACE_Event_Handler::EXCEPT_MASK);
00095
00096 if (ACE_BIT_ENABLED (existing_masks, FD_ACCEPT))
00097 ACE_SET_BITS (old_masks, ACE_Event_Handler::ACCEPT_MASK);
00098
00099 if (ACE_BIT_ENABLED (existing_masks, FD_CONNECT))
00100 ACE_SET_BITS (old_masks, ACE_Event_Handler::CONNECT_MASK);
00101
00102 if (ACE_BIT_ENABLED (existing_masks, FD_QOS))
00103 ACE_SET_BITS (old_masks, ACE_Event_Handler::QOS_MASK);
00104
00105 if (ACE_BIT_ENABLED (existing_masks, FD_GROUP_QOS))
00106 ACE_SET_BITS (old_masks, ACE_Event_Handler::GROUP_QOS_MASK);
00107
00108 switch (operation)
00109 {
00110 case ACE_Reactor::CLR_MASK:
00111 // For the CLR_MASK operation, clear only the specific masks.
00112
00113 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::READ_MASK))
00114 {
00115 ACE_CLR_BITS (existing_masks, FD_READ);
00116 ACE_CLR_BITS (existing_masks, FD_CLOSE);
00117 }
00118
00119 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::WRITE_MASK))
00120 ACE_CLR_BITS (existing_masks, FD_WRITE);
00121
00122 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::EXCEPT_MASK))
00123 ACE_CLR_BITS (existing_masks, FD_OOB);
00124
00125 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::ACCEPT_MASK))
00126 ACE_CLR_BITS (existing_masks, FD_ACCEPT);
00127
00128 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::CONNECT_MASK))
00129 ACE_CLR_BITS (existing_masks, FD_CONNECT);
00130
00131 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::QOS_MASK))
00132 ACE_CLR_BITS (existing_masks, FD_QOS);
00133
00134 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::GROUP_QOS_MASK))
00135 ACE_CLR_BITS (existing_masks, FD_GROUP_QOS);
00136
00137 break;
00138
00139 case ACE_Reactor::SET_MASK:
00140 // If the operation is a set, first reset any existing masks
00141
00142 existing_masks = 0;
00143 /* FALLTHRU */
00144
00145 case ACE_Reactor::ADD_MASK:
00146 // For the ADD_MASK and the SET_MASK operation, add only the
00147 // specific masks.
00148
00149 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::READ_MASK))
00150 {
00151 ACE_SET_BITS (existing_masks, FD_READ);
00152 ACE_SET_BITS (existing_masks, FD_CLOSE);
00153 }
00154
00155 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::WRITE_MASK))
00156 ACE_SET_BITS (existing_masks, FD_WRITE);
00157
00158 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::EXCEPT_MASK))
00159 ACE_SET_BITS (existing_masks, FD_OOB);
00160
00161 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::ACCEPT_MASK))
00162 ACE_SET_BITS (existing_masks, FD_ACCEPT);
00163
00164 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::CONNECT_MASK))
00165 ACE_SET_BITS (existing_masks, FD_CONNECT);
00166
00167 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::QOS_MASK))
00168 ACE_SET_BITS (existing_masks, FD_QOS);
00169
00170 if (ACE_BIT_ENABLED (change_masks, ACE_Event_Handler::GROUP_QOS_MASK))
00171 ACE_SET_BITS (existing_masks, FD_GROUP_QOS);
00172
00173 break;
00174
00175 case ACE_Reactor::GET_MASK:
00176
00177 // The work for this operation is done in all cases at the
00178 // begining of the function.
00179
00180 ACE_UNUSED_ARG (change_masks);
00181
00182 break;
00183 }
00184
00185 return old_masks;
00186 }
|
|
|
Check if changes to the handle set are required.
Definition at line 395 of file WFMO_Reactor.inl. References handles_to_be_added_, handles_to_be_deleted_, handles_to_be_resumed_, and handles_to_be_suspended_. Referenced by ACE_WFMO_Reactor::open(), unbind(), and ACE_WFMO_Reactor::update_state().
00396 {
00397 // Check if handles have be scheduled for additions or removal
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 }
|
|
|
Close down the handler repository.
Definition at line 329 of file WFMO_Reactor.inl. References unbind_all(). Referenced by ACE_WFMO_Reactor::close().
00330 {
00331 // Let all the handlers know that the <WFMO_Reactor> is closing down
00332 this->unbind_all ();
00333
00334 return 0;
00335 }
|
|
|
Pointer to the beginning of the current array of ACE_Event_Handler *'s. Definition at line 353 of file WFMO_Reactor.inl. References current_info_, ACE_WFMO_Reactor::owner_i(), ACE_Thread::self(), and wfmo_reactor_. Referenced by ACE_WFMO_Reactor::complex_dispatch_handler(), ACE_WFMO_Reactor::dispatch_handler(), and ACE_WFMO_Reactor::simple_dispatch_handler().
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 }
|
|
|
Dump the state of an object.
Definition at line 992 of file WFMO_Reactor.cpp. References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, current_info_, current_suspended_info_, ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::dump(), ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::dump(), ACE_WFMO_Reactor_Handler_Repository::Current_Info::dump(), handles_to_be_added_, LM_DEBUG, suspended_handles_, and to_be_added_info_. Referenced by ACE_WFMO_Reactor::dump().
00993 {
00994 #if defined (ACE_HAS_DUMP)
00995 size_t i = 0;
00996
00997 ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::dump");
00998
00999 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
01000
01001 ACE_DEBUG ((LM_DEBUG,
01002 ACE_LIB_TEXT ("Max size = %d\n"),
01003 this->max_size_));
01004
01005 ACE_DEBUG ((LM_DEBUG,
01006 ACE_LIB_TEXT ("Current info table\n\n")));
01007 ACE_DEBUG ((LM_DEBUG,
01008 ACE_LIB_TEXT ("\tSize = %d\n"),
01009 this->max_handlep1_));
01010 ACE_DEBUG ((LM_DEBUG,
01011 ACE_LIB_TEXT ("\tHandles to be suspended = %d\n"),
01012 this->handles_to_be_suspended_));
01013
01014 for (i = 0; i < this->max_handlep1_; ++i)
01015 this->current_info_[i].dump (this->current_handles_[i]);
01016
01017 ACE_DEBUG ((LM_DEBUG,
01018 ACE_LIB_TEXT ("\n")));
01019
01020 ACE_DEBUG ((LM_DEBUG,
01021 ACE_LIB_TEXT ("To-be-added info table\n\n")));
01022 ACE_DEBUG ((LM_DEBUG,
01023 ACE_LIB_TEXT ("\tSize = %d\n"),
01024 this->handles_to_be_added_));
01025
01026 for (i = 0; i < this->handles_to_be_added_; ++i)
01027 this->to_be_added_info_[i].dump ();
01028
01029 ACE_DEBUG ((LM_DEBUG,
01030 ACE_LIB_TEXT ("\n")));
01031
01032 ACE_DEBUG ((LM_DEBUG,
01033 ACE_LIB_TEXT ("Suspended info table\n\n")));
01034 ACE_DEBUG ((LM_DEBUG,
01035 ACE_LIB_TEXT ("\tSize = %d\n"),
01036 this->suspended_handles_));
01037 ACE_DEBUG ((LM_DEBUG,
01038 ACE_LIB_TEXT ("\tHandles to be resumed = %d\n"),
01039 this->handles_to_be_resumed_));
01040
01041 for (i = 0; i < this->suspended_handles_; ++i)
01042 this->current_suspended_info_[i].dump ();
01043
01044 ACE_DEBUG ((LM_DEBUG,
01045 ACE_LIB_TEXT ("\n")));
01046
01047 ACE_DEBUG ((LM_DEBUG,
01048 ACE_LIB_TEXT ("Total handles to be deleted = %d\n"),
01049 this->handles_to_be_deleted_));
01050
01051 ACE_DEBUG ((LM_DEBUG,
01052 ACE_END_DUMP));
01053 #endif /* ACE_HAS_DUMP */
01054 }
|
|
|
Return the Event_Handler associated with . Return 0 if is not registered. Definition at line 1534 of file WFMO_Reactor.cpp. References handler(). Referenced by ACE_WFMO_Reactor::find_handler().
01535 {
01536 long existing_masks_ignored = 0;
01537 return this->handler (handle,
01538 existing_masks_ignored);
01539 }
|
|
||||||||||||
|
Check to see if is associated with a valid Event_Handler. Return Event_Handler and associated masks. Definition at line 1542 of file WFMO_Reactor.cpp. References ACE_Event_Handler::add_reference(), current_handles_, current_info_, current_suspended_info_, handles_to_be_added_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_handle_, suspended_handles_, and to_be_added_info_.
01544 {
01545 int found = 0;
01546 size_t i = 0;
01547 ACE_Event_Handler *event_handler = 0;
01548 existing_masks = 0;
01549
01550 // Look for the handle first
01551
01552 // First go through the current entries
01553 //
01554 // Look for all entries in the current handles for matching handle
01555 // (except those that have been scheduled for deletion)
01556 for (i = 0; i < this->max_handlep1_ && !found; ++i)
01557 if ((handle == this->current_info_[i].io_handle_ ||
01558 handle == this->current_handles_[i]) &&
01559 !this->current_info_[i].delete_entry_)
01560 {
01561 found = 1;
01562 event_handler = this->current_info_[i].event_handler_;
01563 existing_masks = this->current_info_[i].network_events_;
01564 }
01565
01566 // Then pass through the suspended handles
01567 //
01568 // Look for all entries in the suspended handles for matching handle
01569 // (except those that have been scheduled for deletion)
01570 for (i = 0; i < this->suspended_handles_ && !found; ++i)
01571 if ((handle == this->current_suspended_info_[i].io_handle_ ||
01572 handle == this->current_suspended_info_[i].event_handle_) &&
01573 !this->current_suspended_info_[i].delete_entry_)
01574 {
01575 found = 1;
01576 event_handler = this->current_suspended_info_[i].event_handler_;
01577 existing_masks = this->current_suspended_info_[i].network_events_;
01578 }
01579
01580 // Then check the to_be_added handles
01581 //
01582 // Look for all entries in the to_be_added handles for matching
01583 // handle (except those that have been scheduled for deletion)
01584 for (i = 0; i < this->handles_to_be_added_ && !found; ++i)
01585 if ((handle == this->to_be_added_info_[i].io_handle_ ||
01586 handle == this->to_be_added_info_[i].event_handle_) &&
01587 !this->to_be_added_info_[i].delete_entry_)
01588 {
01589 found = 1;
01590 event_handler = this->to_be_added_info_[i].event_handler_;
01591 existing_masks = this->to_be_added_info_[i].network_events_;
01592 }
01593
01594 if (event_handler)
01595 event_handler->add_reference ();
01596
01597 return event_handler;
01598 }
|
|
||||||||||||||||
|
Check to see if is associated with a valid Event_Handler bound to . Return the associated with this if != 0. Definition at line 1601 of file WFMO_Reactor.cpp. References ACE_BIT_ENABLED, ACE_Reactor_Mask, FD_GROUP_QOS, FD_QOS, ACE_Event_Handler_var::handler(), and ACE_Event_Handler_var::release(). Referenced by find_handler(), and ACE_WFMO_Reactor::handler().
01604 {
01605 long existing_masks = 0;
01606 int found = 0;
01607
01608 ACE_Event_Handler_var safe_event_handler =
01609 this->handler (handle,
01610 existing_masks);
01611
01612 if (safe_event_handler.handler ())
01613 found = 1;
01614
01615 if (!found)
01616 return -1;
01617
01618 // Otherwise, make sure that the masks that the user is looking for
01619 // are on.
01620 if (found &&
01621 ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::READ_MASK))
01622 if (!ACE_BIT_ENABLED (existing_masks, FD_READ) &&
01623 !ACE_BIT_ENABLED (existing_masks, FD_CLOSE))
01624 found = 0;
01625
01626 if (found &&
01627 ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::WRITE_MASK))
01628 if (!ACE_BIT_ENABLED (existing_masks, FD_WRITE))
01629 found = 0;
01630
01631 if (found &&
01632 ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::EXCEPT_MASK))
01633 if (!ACE_BIT_ENABLED (existing_masks, FD_OOB))
01634 found = 0;
01635
01636 if (found &&
01637 ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::ACCEPT_MASK))
01638 if (!ACE_BIT_ENABLED (existing_masks, FD_ACCEPT))
01639 found = 0;
01640
01641 if (found &&
01642 ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::CONNECT_MASK))
01643 if (!ACE_BIT_ENABLED (existing_masks, FD_CONNECT))
01644 found = 0;
01645
01646 if (found &&
01647 ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::QOS_MASK))
01648 if (!ACE_BIT_ENABLED (existing_masks, FD_QOS))
01649 found = 0;
01650
01651 if (found &&
01652 ACE_BIT_ENABLED (user_masks, ACE_Event_Handler::GROUP_QOS_MASK))
01653 if (!ACE_BIT_ENABLED (existing_masks, FD_GROUP_QOS))
01654 found = 0;
01655
01656 if (found &&
01657 user_event_handler)
01658 *user_event_handler = safe_event_handler.release ();
01659
01660 if (found)
01661 return 0;
01662 else
01663 return -1;
01664 }
|
|
|
Pointer to the beginning of the current array of ACE_HANDLE 's. Definition at line 338 of file WFMO_Reactor.inl. References current_handles_, ACE_WFMO_Reactor::owner_i(), ACE_Thread::self(), and wfmo_reactor_. Referenced by ACE_WFMO_Reactor::dispatch_handler(), ACE_WFMO_Reactor::poll_remaining_handles(), ACE_Msg_WFMO_Reactor::poll_remaining_handles(), ACE_WFMO_Reactor::wait_for_multiple_events(), and ACE_Msg_WFMO_Reactor::wait_for_multiple_events().
00339 {
00340 // This code is probably too subtle to be useful in the long run...
00341 // The basic idea is that all threads wait on all user handles plus
00342 // the <wakeup_all_threads_> handle. The owner thread additional
00343 // waits on the <notify_> handle. This is to ensure that only the
00344 // <owner_> thread get to expire timers and handle event on the
00345 // notify pipe.
00346 if (ACE_Thread::self () == this->wfmo_reactor_.owner_i ())
00347 return this->current_handles_;
00348 else
00349 return this->current_handles_ + 1;
00350 }
|
|
|
Definition at line 380 of file WFMO_Reactor.inl. References ACE_TRACE. Referenced by bind_i(), ACE_WFMO_Reactor::mask_ops_i(), ACE_WFMO_Reactor::register_handler_i(), and unbind().
00381 {
00382 ACE_TRACE ("ACE_WFMO_Reactor_Handler_Repository::invalid_handle");
00383 // It's too expensive to perform more exhaustive validity checks on
00384 // Win32 due to the way that they implement SOCKET HANDLEs.
00385 if (handle == ACE_INVALID_HANDLE)
00386 {
00387 errno = EINVAL;
00388 return 1;
00389 }
00390 else
00391 return 0;
00392 }
|
|
|
Make changes to the handle set.
Definition at line 405 of file WFMO_Reactor.inl. References make_changes_in_current_infos(), make_changes_in_suspension_infos(), and make_changes_in_to_be_added_infos(). Referenced by ACE_WFMO_Reactor::open(), ACE_WFMO_Reactor::update_state(), and ACE_WFMO_Reactor::~ACE_WFMO_Reactor().
00406 {
00407 // This method must ONLY be called by the
00408 // <WFMO_Reactor->change_state_thread_>. We therefore assume that
00409 // there will be no contention for this method and hence no guards
00410 // are neccessary.
00411
00412 // Deletions and suspensions in current_info_
00413 this->make_changes_in_current_infos ();
00414
00415 // Deletions and resumptions in current_suspended_info_
00416 this->make_changes_in_suspension_infos ();
00417
00418 // Deletions in to_be_added_info_, or transfers to current_info_ or
00419 // current_suspended_info_ from to_be_added_info_
00420 this->make_changes_in_to_be_added_infos ();
00421
00422 return 0;
00423 }
|
|
|
Deletions and suspensions in current_info_.
Definition at line 678 of file WFMO_Reactor.cpp. References ACE_BIT_ENABLED, ACE_Reactor_Mask, ACE_WFMO_Reactor_Handler_Repository::Common_Info::close_masks_, current_handles_, current_info_, current_suspended_info_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::delete_entry_, ACE_OS::event_destroy(), ACE_Event_Handler::handle_close(), handles_to_be_deleted_, handles_to_be_suspended_, ACE_Event_Handler::reference_counting_policy(), ACE_Event_Handler::remove_reference(), ACE_WFMO_Reactor_Handler_Repository::Current_Info::reset(), ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::set(), ACE_WFMO_Reactor_Handler_Repository::Current_Info::suspend_entry_, and suspended_handles_. Referenced by make_changes().
00679 {
00680 // Go through the entire valid array and check for all handles that
00681 // have been schedule for deletion
00682 if (this->handles_to_be_deleted_ > 0 || this->handles_to_be_suspended_ > 0)
00683 {
00684 size_t i = 0;
00685 while (i < this->max_handlep1_)
00686 {
00687 // This stuff is necessary here, since we should not make
00688 // the upcall until all the internal data structures have
00689 // been updated. This is to protect against upcalls that
00690 // try to deregister again.
00691 ACE_HANDLE handle = ACE_INVALID_HANDLE;
00692 ACE_Reactor_Mask masks = ACE_Event_Handler::NULL_MASK;
00693 ACE_Event_Handler *event_handler = 0;
00694
00695 // See if this entry is scheduled for deletion
00696 if (this->current_info_[i].delete_entry_)
00697 {
00698 // Calling the <handle_close> method here will ensure that we
00699 // will only call it once per deregistering <Event_Handler>.
00700 // This is essential in the case when the <Event_Handler> will
00701 // do something like delete itself and we have multiple
00702 // threads in WFMO_Reactor.
00703 //
00704 // Make sure that the DONT_CALL mask is not set
00705 masks = this->current_info_[i].close_masks_;
00706 if (ACE_BIT_ENABLED (masks, ACE_Event_Handler::DONT_CALL) == 0)
00707 {
00708 // Grab the correct handle depending on the type entry
00709 if (this->current_info_[i].io_entry_)
00710 handle = this->current_info_[i].io_handle_;
00711 else
00712 handle = this->current_handles_[i];
00713
00714 // Event handler
00715 event_handler = this->current_info_[i].event_handler_;
00716 }
00717
00718 // If <WFMO_Reactor> created the event, we need to clean it up
00719 if (this->current_info_[i].delete_event_)
00720 ACE_OS::event_destroy (&this->current_handles_[i]);
00721
00722 // Reduce count by one
00723 --this->handles_to_be_deleted_;
00724 }
00725
00726 // See if this entry is scheduled for suspension
00727 else if (this->current_info_[i].suspend_entry_)
00728 {
00729 this->current_suspended_info_ [this->suspended_handles_].set (this->current_handles_[i],
00730 this->current_info_[i]);
00731 // Increase number of suspended handles
00732 ++this->suspended_handles_;
00733
00734 // Reduce count by one
00735 --this->handles_to_be_suspended_;
00736 }
00737
00738 // See if this entry is scheduled for deletion or suspension
00739 // If so we need to clean up
00740 if (this->current_info_[i].delete_entry_ ||
00741 this->current_info_[i].suspend_entry_ )
00742 {
00743 size_t last_valid_slot = this->max_handlep1_ - 1;
00744 // If this is the last handle in the set, no need to swap
00745 // places. Simply remove it.
00746 if (i < last_valid_slot)
00747 // Swap this handle with the last valid handle
00748 {
00749 // Struct copy
00750 this->current_info_[i] =
00751 this->current_info_[last_valid_slot];
00752 this->current_handles_[i] =
00753 this->current_handles_[last_valid_slot];
00754 }
00755 // Reset the info in this slot
00756 this->current_info_[last_valid_slot].reset ();
00757 this->current_handles_[last_valid_slot] = ACE_INVALID_HANDLE;
00758 --this->max_handlep1_;
00759 }
00760 else
00761 {
00762 // This current entry is not up for deletion or
00763 // suspension. Proceed to the next entry in the current
00764 // handles.
00765 ++i;
00766 }
00767
00768 // Now that all internal structures have been updated, make
00769 // the upcall.
00770 if (event_handler != 0)
00771 {
00772 int requires_reference_counting =
00773 event_handler->reference_counting_policy ().value () ==
00774 ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
00775
00776 event_handler->handle_close (handle, masks);
00777
00778 if (requires_reference_counting)
00779 {
00780 event_handler->remove_reference ();
00781 }
00782 }
00783 }
00784 }
00785
00786 return 0;
00787 }
|
|
|
Deletions and resumptions in current_suspended_info_.
Definition at line 790 of file WFMO_Reactor.cpp. References ACE_BIT_ENABLED, ACE_Reactor_Mask, ACE_WFMO_Reactor_Handler_Repository::Common_Info::close_masks_, current_handles_, current_info_, current_suspended_info_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::delete_entry_, ACE_OS::event_destroy(), ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::event_handle_, ACE_Event_Handler::handle_close(), handles_to_be_deleted_, handles_to_be_resumed_, ACE_Event_Handler::reference_counting_policy(), ACE_Event_Handler::remove_reference(), ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::reset(), ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::resume_entry_, ACE_WFMO_Reactor_Handler_Repository::Current_Info::set(), and suspended_handles_. Referenced by make_changes().
00791 {
00792 // Go through the <suspended_handle> array
00793 if (this->handles_to_be_deleted_ > 0 || this->handles_to_be_resumed_ > 0)
00794 {
00795 size_t i = 0;
00796 while (i < this->suspended_handles_)
00797 {
00798 // This stuff is necessary here, since we should not make
00799 // the upcall until all the internal data structures have
00800 // been updated. This is to protect against upcalls that
00801 // try to deregister again.
00802 ACE_HANDLE handle = ACE_INVALID_HANDLE;
00803 ACE_Reactor_Mask masks = ACE_Event_Handler::NULL_MASK;
00804 ACE_Event_Handler *event_handler = 0;
00805
00806 // See if this entry is scheduled for deletion
00807 if (this->current_suspended_info_[i].delete_entry_)
00808 {
00809 // Calling the <handle_close> method here will ensure that we
00810 // will only call it once per deregistering <Event_Handler>.
00811 // This is essential in the case when the <Event_Handler> will
00812 // do something like delete itself and we have multiple
00813 // threads in WFMO_Reactor.
00814 //
00815 // Make sure that the DONT_CALL mask is not set
00816 masks = this->current_suspended_info_[i].close_masks_;
00817 if (ACE_BIT_ENABLED (masks, ACE_Event_Handler::DONT_CALL) == 0)
00818 {
00819 // Grab the correct handle depending on the type entry
00820 if (this->current_suspended_info_[i].io_entry_)
00821 handle = this->current_suspended_info_[i].io_handle_;
00822 else
00823 handle = this->current_suspended_info_[i].event_handle_;
00824
00825 // Upcall
00826 event_handler = this->current_suspended_info_[i].event_handler_;
00827 }
00828
00829 // If <WFMO_Reactor> created the event, we need to clean it up
00830 if (this->current_suspended_info_[i].delete_event_)
00831 ACE_OS::event_destroy (&this->current_suspended_info_[i].event_handle_);
00832
00833 // Reduce count by one
00834 --this->handles_to_be_deleted_;
00835 }
00836
00837 else if (this->current_suspended_info_[i].resume_entry_)
00838 {
00839 // Add to the end of the current handles set
00840 this->current_handles_[this->max_handlep1_] = this->current_suspended_info_[i].event_handle_;
00841 // Struct copy
00842 this->current_info_[this->max_handlep1_].set (this->current_suspended_info_[i]);
00843 ++this->max_handlep1_;
00844
00845 // Reduce count by one
00846 --this->handles_to_be_resumed_;
00847 }
00848
00849 // If an entry needs to be removed, either because it
00850 // was deleted or resumed, remove it now before doing
00851 // the upcall.
00852 if (this->current_suspended_info_[i].resume_entry_ ||
00853 this->current_suspended_info_[i].delete_entry_)
00854 {
00855 size_t last_valid_slot = this->suspended_handles_ - 1;
00856 // Net effect is that we're removing an entry and
00857 // compressing the list from the end. So, if removing
00858 // an entry from the middle, copy the last valid one to the
00859 // removed slot. Reset the end and decrement the number
00860 // of suspended handles.
00861 if (i < last_valid_slot)
00862 // Struct copy
00863 this->current_suspended_info_[i] =
00864 this->current_suspended_info_[last_valid_slot];
00865 this->current_suspended_info_[last_valid_slot].reset ();
00866 --this->suspended_handles_;
00867 }
00868 else
00869 {
00870 // This current entry is not up for deletion or
00871 // resumption. Proceed to the next entry in the
00872 // suspended handles.
00873 ++i;
00874 }
00875
00876 // Now that all internal structures have been updated, make
00877 // the upcall.
00878 if (event_handler != 0)
00879 {
00880 int requires_reference_counting =
00881 event_handler->reference_counting_policy ().value () ==
00882 ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
00883
00884 event_handler->handle_close (handle, masks);
00885
00886 if (requires_reference_counting)
00887 {
00888 event_handler->remove_reference ();
00889 }
00890 }
00891 }
00892 }
00893
00894 return 0;
00895 }
|
|
|
Deletions in to_be_added_info_, or transfers to current_info_ or current_suspended_info_ from to_be_added_info_ Definition at line 898 of file WFMO_Reactor.cpp. References ACE_BIT_ENABLED, ACE_Reactor_Mask, ACE_WFMO_Reactor_Handler_Repository::Common_Info::close_masks_, current_handles_, current_info_, current_suspended_info_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::delete_entry_, ACE_OS::event_destroy(), ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::event_handle_, ACE_Event_Handler::handle_close(), handles_to_be_added_, handles_to_be_deleted_, handles_to_be_suspended_, ACE_Event_Handler::reference_counting_policy(), ACE_Event_Handler::remove_reference(), ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::reset(), ACE_WFMO_Reactor_Handler_Repository::Current_Info::set(), ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::set(), ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::suspend_entry_, suspended_handles_, and to_be_added_info_. Referenced by make_changes().
00899 {
00900 // Go through the <to_be_added_*> arrays
00901 for (size_t i = 0; i < this->handles_to_be_added_; ++i)
00902 {
00903 // This stuff is necessary here, since we should not make
00904 // the upcall until all the internal data structures have
00905 // been updated. This is to protect against upcalls that
00906 // try to deregister again.
00907 ACE_HANDLE handle = ACE_INVALID_HANDLE;
00908 ACE_Reactor_Mask masks = ACE_Event_Handler::NULL_MASK;
00909 ACE_Event_Handler *event_handler = 0;
00910
00911 // See if this entry is scheduled for deletion
00912 if (this->to_be_added_info_[i].delete_entry_)
00913 {
00914 // Calling the <handle_close> method here will ensure that we
00915 // will only call it once per deregistering <Event_Handler>.
00916 // This is essential in the case when the <Event_Handler> will
00917 // do something like delete itself and we have multiple
00918 // threads in WFMO_Reactor.
00919 //
00920 // Make sure that the DONT_CALL mask is not set
00921 masks = this->to_be_added_info_[i].close_masks_;
00922 if (ACE_BIT_ENABLED (masks, ACE_Event_Handler::DONT_CALL) == 0)
00923 {
00924 // Grab the correct handle depending on the type entry
00925 if (this->to_be_added_info_[i].io_entry_)
00926 handle = this->to_be_added_info_[i].io_handle_;
00927 else
00928 handle = this->to_be_added_info_[i].event_handle_;
00929
00930 // Upcall
00931 event_handler = this->to_be_added_info_[i].event_handler_;
00932 }
00933
00934 // If <WFMO_Reactor> created the event, we need to clean it up
00935 if (this->to_be_added_info_[i].delete_event_)
00936 ACE_OS::event_destroy (&this->to_be_added_info_[i].event_handle_);
00937
00938 // Reduce count by one
00939 --this->handles_to_be_deleted_;
00940 }
00941
00942 // See if this entry is scheduled for suspension
00943 else if (this->to_be_added_info_[i].suspend_entry_)
00944 {
00945 this->current_suspended_info_ [this->suspended_handles_].set (this->to_be_added_info_[i].event_handle_,
00946 this->to_be_added_info_[i]);
00947 // Increase number of suspended handles
00948 ++this->suspended_handles_;
00949
00950 // Reduce count by one
00951 --this->handles_to_be_suspended_;
00952 }
00953
00954 // If neither of the two flags are on, add to current
00955 else
00956 {
00957 // Add to the end of the current handles set
00958 this->current_handles_[this->max_handlep1_] = this->to_be_added_info_[i].event_handle_;
00959 // Struct copy
00960 this->current_info_[this->max_handlep1_].set (this->to_be_added_info_[i]);
00961 ++this->max_handlep1_;
00962 }
00963
00964 // Reset the <to_be_added_info_>
00965 this->to_be_added_info_[i].reset ();
00966
00967 // Now that all internal structures have been updated, make the
00968 // upcall.
00969 if (event_handler != 0)
00970 {
00971 int requires_reference_counting =
00972 event_handler->reference_counting_policy ().value () ==
00973 ACE_Event_Handler::Reference_Counting_Policy::ENABLED;
00974
00975 event_handler->handle_close (handle, masks);
00976
00977 if (requires_reference_counting)
00978 {
00979 event_handler->remove_reference ();
00980 }
00981 }
00982 }
00983
00984 // Since all to be added handles have been taken care of, reset the
00985 // counter
00986 this->handles_to_be_added_ = 0;
00987
00988 return 0;
00989 }
|
|
|
Maximum ACE_HANDLE value, plus 1.
Definition at line 362 of file WFMO_Reactor.inl. References ACE_WFMO_Reactor::owner_i(), ACE_Thread::self(), and wfmo_reactor_. Referenced by ACE_WFMO_Reactor::dispatch_handles().
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 }
|
|
||||||||||||||||||||||||||||||||
|
This method is used to calculate the network mask after a mask_op request to . Note that because the may already be in the handler repository, we may have to find the old event and the old network events Definition at line 1470 of file WFMO_Reactor.cpp. References ACE_Reactor_Mask, bit_ops(), current_handles_, current_info_, current_suspended_info_, handles_to_be_added_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_handle_, suspended_handles_, and to_be_added_info_. Referenced by ACE_WFMO_Reactor::mask_ops_i(), and ACE_WFMO_Reactor::register_handler_i().
01477 {
01478 long *modified_network_events = &new_network_events;
01479 int found = 0;
01480 size_t i;
01481
01482 // First go through the current entries
01483 //
01484 // Look for all entries in the current handles for matching handle
01485 // (except those that have been scheduled for deletion)
01486 for (i = 0; i < this->max_handlep1_ && !found; ++i)
01487 if (io_handle == this->current_info_[i].io_handle_ &&
01488 !this->current_info_[i].delete_entry_)
01489 {
01490 found = 1;
01491 modified_network_events = &this->current_info_[i].network_events_;
01492 delete_event = this->current_info_[i].delete_event_;
01493 event_handle = this->current_handles_[i];
01494 }
01495
01496 // Then pass through the suspended handles
01497 //
01498 // Look for all entries in the suspended handles for matching handle
01499 // (except those that have been scheduled for deletion)
01500 for (i = 0; i < this->suspended_handles_ && !found; ++i)
01501 if (io_handle == this->current_suspended_info_[i].io_handle_ &&
01502 !this->current_suspended_info_[i].delete_entry_)
01503 {
01504 found = 1;
01505 modified_network_events = &this->current_suspended_info_[i].network_events_;
01506 delete_event = this->current_suspended_info_[i].delete_event_;
01507 event_handle = this->current_suspended_info_[i].event_handle_;
01508 }
01509
01510 // Then check the to_be_added handles
01511 //
01512 // Look for all entries in the to_be_added handles for matching
01513 // handle (except those that have been scheduled for deletion)
01514 for (i = 0; i < this->handles_to_be_added_ && !found; ++i)
01515 if (io_handle == this->to_be_added_info_[i].io_handle_ &&
01516 !this->to_be_added_info_[i].delete_entry_)
01517 {
01518 found = 1;
01519 modified_network_events = &this->to_be_added_info_[i].network_events_;
01520 delete_event = this->to_be_added_info_[i].delete_event_;
01521 event_handle = this->to_be_added_info_[i].event_handle_;
01522 }
01523
01524 old_masks = this->bit_ops (*modified_network_events,
01525 new_masks,
01526 operation);
01527
01528 new_network_events = *modified_network_events;
01529
01530 return found;
01531 }
|
|
|
Initialize the repository of the approriate .
Definition at line 29 of file WFMO_Reactor.cpp. References ACE_ERROR_RETURN, ACE_LIB_TEXT, ACE_NEW_RETURN, current_handles_, handles_to_be_added_, handles_to_be_deleted_, handles_to_be_resumed_, handles_to_be_suspended_, LM_ERROR, and suspended_handles_. Referenced by ACE_WFMO_Reactor::open().
00030 {
00031 if (size > MAXIMUM_WAIT_OBJECTS)
00032 ACE_ERROR_RETURN ((LM_ERROR,
00033 ACE_LIB_TEXT ("%d exceeds MAXIMUM_WAIT_OBJECTS (%d)\n"),
00034 size,
00035 MAXIMUM_WAIT_OBJECTS),
00036 -1);
00037
00038 // Dynamic allocation
00039 ACE_NEW_RETURN (this->current_handles_,
00040 ACE_HANDLE[size],
00041 -1);
00042 ACE_NEW_RETURN (this->current_info_,
00043 Current_Info[size],
00044 -1);
00045 ACE_NEW_RETURN (this->current_suspended_info_,
00046 Suspended_Info[size],
00047 -1);
00048 ACE_NEW_RETURN (this->to_be_added_info_,
00049 To_Be_Added_Info[size],
00050 -1);
00051
00052 // Initialization
00053 this->max_size_ = size;
00054 this->max_handlep1_ = 0;
00055 this->suspended_handles_ = 0;
00056 this->handles_to_be_added_ = 0;
00057 this->handles_to_be_deleted_ = 0;
00058 this->handles_to_be_suspended_ = 0;
00059 this->handles_to_be_resumed_ = 0;
00060
00061 for (size_t i = 0; i < size; ++i)
00062 this->current_handles_[i] = ACE_INVALID_HANDLE;
00063
00064 return 0;
00065 }
|
|
||||||||||||
|
Removes the ACE_Event_Handler at from the table.
Definition at line 261 of file WFMO_Reactor.cpp. References ACE_BIT_ENABLED, ACE_Reactor_Mask, bit_ops(), ACE_WFMO_Reactor_Handler_Repository::Common_Info::close_masks_, current_handles_, current_info_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::delete_entry_, handles_to_be_deleted_, handles_to_be_suspended_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_entry_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_handle_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::network_events_, and ACE_WFMO_Reactor_Handler_Repository::Current_Info::suspend_entry_. Referenced by unbind_i().
00263 {
00264 // I/O entries
00265 if (this->current_info_[slot].io_entry_)
00266 {
00267 // See if there are other events that the <Event_Handler> is
00268 // interested in
00269 this->bit_ops (this->current_info_[slot].network_events_,
00270 to_be_removed_masks,
00271 ACE_Reactor::CLR_MASK);
00272
00273 // Disassociate/Reassociate the event from/with the I/O handle.
00274 // This will depend on the value of remaining set of network
00275 // events that the <event_handler> is interested in. I don't
00276 // think we can do anything about errors here, so I will not
00277 // check this.
00278 ::WSAEventSelect ((SOCKET) this->current_info_[slot].io_handle_,
00279 this->current_handles_[slot],
00280 this->current_info_[slot].network_events_);
00281 }
00282 // Normal event entries.
00283 else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL))
00284 // Preserve DONT_CALL
00285 to_be_removed_masks = ACE_Event_Handler::DONT_CALL;
00286 else
00287 // Make sure that the <to_be_removed_masks> is the NULL_MASK
00288 to_be_removed_masks = ACE_Event_Handler::NULL_MASK;
00289
00290 // If this event was marked for suspension, undo the suspension flag
00291 // and reduce the to be suspended count.
00292 if (this->current_info_[slot].suspend_entry_)
00293 {
00294 // Undo suspension
00295 this->current_info_[slot].suspend_entry_ = 0;
00296 // Decrement the handle count
00297 --this->handles_to_be_suspended_;
00298 }
00299
00300 // If there are no more events that the <Event_Handler> is
00301 // interested in, or this is a non-I/O entry, schedule the
00302 // <Event_Handler> for removal
00303 if (this->current_info_[slot].network_events_ == 0)
00304 {
00305 // Mark to be deleted
00306 this->current_info_[slot].delete_entry_ = 1;
00307 // Remember the mask
00308 this->current_info_[slot].close_masks_ = to_be_removed_masks;
00309 // Increment the handle count
00310 ++this->handles_to_be_deleted_;
00311 }
00312
00313 // Since it is not a complete removal, we'll call handle_close
00314 // for all the masks that were removed. This does not change
00315 // the internal state of the reactor.
00316 //
00317 // Note: this condition only applies to I/O entries
00318 else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL) == 0)
00319 {
00320 ACE_HANDLE handle = this->current_info_[slot].io_handle_;
00321 this->current_info_[slot].event_handler_->handle_close (handle,
00322 to_be_removed_masks);
00323 }
00324
00325 return 0;
00326 }
|
|
||||||||||||
|
Removes the ACE_Event_Handler at from the table.
Definition at line 329 of file WFMO_Reactor.cpp. References ACE_BIT_ENABLED, ACE_Reactor_Mask, bit_ops(), ACE_WFMO_Reactor_Handler_Repository::Common_Info::close_masks_, current_suspended_info_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::delete_entry_, ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::event_handle_, handles_to_be_deleted_, handles_to_be_resumed_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_entry_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_handle_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::network_events_, and ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::resume_entry_. Referenced by unbind_i().
00331 {
00332 // I/O entries
00333 if (this->current_suspended_info_[slot].io_entry_)
00334 {
00335 // See if there are other events that the <Event_Handler> is
00336 // interested in
00337 this->bit_ops (this->current_suspended_info_[slot].network_events_,
00338 to_be_removed_masks,
00339 ACE_Reactor::CLR_MASK);
00340
00341 // Disassociate/Reassociate the event from/with the I/O handle.
00342 // This will depend on the value of remaining set of network
00343 // events that the <event_handler> is interested in. I don't
00344 // think we can do anything about errors here, so I will not
00345 // check this.
00346 ::WSAEventSelect ((SOCKET) this->current_suspended_info_[slot].io_handle_,
00347 this->current_suspended_info_[slot].event_handle_,
00348 this->current_suspended_info_[slot].network_events_);
00349 }
00350 // Normal event entries.
00351 else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL))
00352 // Preserve DONT_CALL
00353 to_be_removed_masks = ACE_Event_Handler::DONT_CALL;
00354 else
00355 // Make sure that the <to_be_removed_masks> is the NULL_MASK
00356 to_be_removed_masks = ACE_Event_Handler::NULL_MASK;
00357
00358 // If this event was marked for resumption, undo the resumption flag
00359 // and reduce the to be resumed count.
00360 if (this->current_suspended_info_[slot].resume_entry_)
00361 {
00362 // Undo resumption
00363 this->current_suspended_info_[slot].resume_entry_ = 0;
00364 // Decrement the handle count
00365 --this->handles_to_be_resumed_;
00366 }
00367
00368 // If there are no more events that the <Event_Handler> is
00369 // interested in, or this is a non-I/O entry, schedule the
00370 // <Event_Handler> for removal
00371 if (this->current_suspended_info_[slot].network_events_ == 0)
00372 {
00373 // Mark to be deleted
00374 this->current_suspended_info_[slot].delete_entry_ = 1;
00375 // Remember the mask
00376 this->current_suspended_info_[slot].close_masks_ = to_be_removed_masks;
00377 // Increment the handle count
00378 ++this->handles_to_be_deleted_;
00379 }
00380 // Since it is not a complete removal, we'll call handle_close for
00381 // all the masks that were removed. This does not change the
00382 // internal state of the reactor.
00383 //
00384 // Note: this condition only applies to I/O entries
00385 else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL) == 0)
00386 {
00387 ACE_HANDLE handle = this->current_suspended_info_[slot].io_handle_;
00388 this->current_suspended_info_[slot].event_handler_->handle_close (handle,
00389 to_be_removed_masks);
00390 }
00391
00392 return 0;
00393 }
|
|
||||||||||||
|
Removes the ACE_Event_Handler at from the table.
Definition at line 396 of file WFMO_Reactor.cpp. References ACE_BIT_ENABLED, ACE_Reactor_Mask, bit_ops(), ACE_WFMO_Reactor_Handler_Repository::Common_Info::close_masks_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::delete_entry_, ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::event_handle_, handles_to_be_deleted_, handles_to_be_suspended_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_entry_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_handle_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::network_events_, ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::suspend_entry_, and to_be_added_info_. Referenced by unbind_i().
00398 {
00399 // I/O entries
00400 if (this->to_be_added_info_[slot].io_entry_)
00401 {
00402 // See if there are other events that the <Event_Handler> is
00403 // interested in
00404 this->bit_ops (this->to_be_added_info_[slot].network_events_,
00405 to_be_removed_masks,
00406 ACE_Reactor::CLR_MASK);
00407
00408 // Disassociate/Reassociate the event from/with the I/O handle.
00409 // This will depend on the value of remaining set of network
00410 // events that the <event_handler> is interested in. I don't
00411 // think we can do anything about errors here, so I will not
00412 // check this.
00413 ::WSAEventSelect ((SOCKET) this->to_be_added_info_[slot].io_handle_,
00414 this->to_be_added_info_[slot].event_handle_,
00415 this->to_be_added_info_[slot].network_events_);
00416 }
00417 // Normal event entries.
00418 else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL))
00419 // Preserve DONT_CALL
00420 to_be_removed_masks = ACE_Event_Handler::DONT_CALL;
00421 else
00422 // Make sure that the <to_be_removed_masks> is the NULL_MASK
00423 to_be_removed_masks = ACE_Event_Handler::NULL_MASK;
00424
00425 // If this event was marked for suspension, undo the suspension flag
00426 // and reduce the to be suspended count.
00427 if (this->to_be_added_info_[slot].suspend_entry_)
00428 {
00429 // Undo suspension
00430 this->to_be_added_info_[slot].suspend_entry_ = 0;
00431 // Decrement the handle count
00432 --this->handles_to_be_suspended_;
00433 }
00434
00435 // If there are no more events that the <Event_Handler> is
00436 // interested in, or this is a non-I/O entry, schedule the
00437 // <Event_Handler> for removal
00438 if (this->to_be_added_info_[slot].network_events_ == 0)
00439 {
00440 // Mark to be deleted
00441 this->to_be_added_info_[slot].delete_entry_ = 1;
00442 // Remember the mask
00443 this->to_be_added_info_[slot].close_masks_ = to_be_removed_masks;
00444 // Increment the handle count
00445 ++this->handles_to_be_deleted_;
00446 }
00447 // Since it is not a complete removal, we'll call handle_close
00448 // for all the masks that were removed. This does not change
00449 // the internal state of the reactor.
00450 //
00451 // Note: this condition only applies to I/O entries
00452 else if (ACE_BIT_ENABLED (to_be_removed_masks, ACE_Event_Handler::DONT_CALL) == 0)
00453 {
00454 ACE_HANDLE handle = this->to_be_added_info_[slot].io_handle_;
00455 this->to_be_added_info_[slot].event_handler_->handle_close (handle,
00456 to_be_removed_masks);
00457 }
00458
00459 return 0;
00460 }
|
|
||||||||||||
|
Resume suspended entry.
Definition at line 527 of file WFMO_Reactor.cpp. References current_handles_, current_info_, current_suspended_info_, ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::event_handle_, ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::event_handle_, handles_to_be_added_, handles_to_be_resumed_, handles_to_be_suspended_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_handle_, ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::resume_entry_, ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::suspend_entry_, ACE_WFMO_Reactor_Handler_Repository::Current_Info::suspend_entry_, suspended_handles_, and to_be_added_info_. Referenced by ACE_WFMO_Reactor::resume_handler(), and ACE_WFMO_Reactor::resume_handlers().
00529 {
00530 size_t i = 0;
00531
00532 // Go through all the handles looking for <handle>. Even if we find
00533 // it, we continue through the rest of the list since <handle> could
00534 // appear multiple times. All handles are checked.
00535
00536 // Check the current entries first.
00537 for (i = 0; i < this->max_handlep1_; ++i)
00538 // Since the handle can either be the event or the I/O handle,
00539 // we have to check both
00540 if ((this->current_handles_[i] == handle ||
00541 this->current_info_[i].io_handle_ == handle) &&
00542 // Make sure that the suspension is not already undone
00543 this->current_info_[i].suspend_entry_)
00544 {
00545 // Undo suspension
00546 this->current_info_[i].suspend_entry_ = 0;
00547 // Decrement the handle count
00548 --this->handles_to_be_suspended_;
00549 // Changes will be required
00550 changes_required = 1;
00551 }
00552
00553 // Then check the suspended entries.
00554 for (i = 0; i < this->suspended_handles_; ++i)
00555 // Since the handle can either be the event or the I/O handle,
00556 // we have to check both
00557 if ((this->current_suspended_info_[i].event_handle_ == handle ||
00558 this->current_suspended_info_[i].io_handle_ == handle) &&
00559 // Make sure that it is not already marked for resumption
00560 !this->current_suspended_info_[i].resume_entry_)
00561 {
00562 // Mark to be resumed
00563 this->current_suspended_info_[i].resume_entry_ = 1;
00564 // Increment the handle count
00565 ++this->handles_to_be_resumed_;
00566 // Changes will be required
00567 changes_required = 1;
00568 }
00569
00570 // Then check the to_be_added entries.
00571 for (i = 0; i < this->handles_to_be_added_; ++i)
00572 // Since the handle can either be the event or the I/O handle,
00573 // we have to check both
00574 if ((this->to_be_added_info_[i].io_handle_ == handle ||
00575 this->to_be_added_info_[i].event_handle_ == handle) &&
00576 // Make sure that the suspension is not already undone
00577 this->to_be_added_info_[i].suspend_entry_)
00578 {
00579 // Undo suspension
00580 this->to_be_added_info_[i].suspend_entry_ = 0;
00581 // Decrement the handle count
00582 --this->handles_to_be_suspended_;
00583 // Changes will be required
00584 changes_required = 1;
00585 }
00586
00587 return 0;
00588 }
|
|
|
Check to see if has been scheduled for deletion.
Definition at line 371 of file WFMO_Reactor.inl. References current_info_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::delete_entry_, ACE_WFMO_Reactor::owner_i(), ACE_Thread::self(), and wfmo_reactor_. Referenced by ACE_WFMO_Reactor::complex_dispatch_handler(), and ACE_WFMO_Reactor::dispatch_handler().
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 }
|
|
||||||||||||
|
Temporarily suspend entry.
Definition at line 463 of file WFMO_Reactor.cpp. References current_handles_, current_info_, current_suspended_info_, ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::event_handle_, ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::event_handle_, handles_to_be_added_, handles_to_be_resumed_, handles_to_be_suspended_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_handle_, ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::resume_entry_, ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::suspend_entry_, ACE_WFMO_Reactor_Handler_Repository::Current_Info::suspend_entry_, suspended_handles_, and to_be_added_info_. Referenced by ACE_WFMO_Reactor::suspend_handler(), and ACE_WFMO_Reactor::suspend_handlers().
00465 {
00466 size_t i = 0;
00467
00468 // Go through all the handles looking for <handle>. Even if we find
00469 // it, we continue through the rest of the list since <handle> could
00470 // appear multiple times. All handles are checked.
00471
00472 // Check the current entries first.
00473 for (i = 0; i < this->max_handlep1_; ++i)
00474 // Since the handle can either be the event or the I/O handle,
00475 // we have to check both
00476 if ((this->current_handles_[i] == handle ||
00477 this->current_info_[i].io_handle_ == handle) &&
00478 // Make sure that it is not already marked for suspension
00479 !this->current_info_[i].suspend_entry_)
00480 {
00481 // Mark to be suspended
00482 this->current_info_[i].suspend_entry_ = 1;
00483 // Increment the handle count
00484 ++this->handles_to_be_suspended_;
00485 // Changes will be required
00486 changes_required = 1;
00487 }
00488
00489 // Then check the suspended entries.
00490 for (i = 0; i < this->suspended_handles_; ++i)
00491 // Since the handle can either be the event or the I/O handle,
00492 // we have to check both
00493 if ((this->current_suspended_info_[i].event_handle_ == handle ||
00494 this->current_suspended_info_[i].io_handle_ == handle) &&
00495 // Make sure that the resumption is not already undone
00496 this->current_suspended_info_[i].resume_entry_)
00497 {
00498 // Undo resumption
00499 this->current_suspended_info_[i].resume_entry_ = 0;
00500 // Decrement the handle count
00501 --this->handles_to_be_resumed_;
00502 // Changes will be required
00503 changes_required = 1;
00504 }
00505
00506 // Then check the to_be_added entries.
00507 for (i = 0; i < this->handles_to_be_added_; ++i)
00508 // Since the handle can either be the event or the I/O handle,
00509 // we have to check both
00510 if ((this->to_be_added_info_[i].io_handle_ == handle ||
00511 this->to_be_added_info_[i].event_handle_ == handle) &&
00512 // Make sure that it is not already marked for suspension
00513 !this->to_be_added_info_[i].suspend_entry_)
00514 {
00515 // Mark to be suspended
00516 this->to_be_added_info_[i].suspend_entry_ = 1;
00517 // Increment the handle count
00518 ++this->handles_to_be_suspended_;
00519 // Changes will be required
00520 changes_required = 1;
00521 }
00522
00523 return 0;
00524 }
|
|
||||||||||||
|
Remove the binding of ACE_HANDLE in accordance with the .
Definition at line 426 of file WFMO_Reactor.inl. References ACE_GUARD_RETURN, ACE_Reactor_Mask, changes_required(), invalid_handle(), unbind_i(), ACE_WFMO_Reactor::wakeup_all_threads(), and wfmo_reactor_. Referenced by ACE_WFMO_Reactor::complex_dispatch_handler(), ACE_WFMO_Reactor::remove_handler(), and ACE_WFMO_Reactor::simple_dispatch_handler().
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 // Wake up all threads in WaitForMultipleObjects so that they can
00441 // reconsult the handle set
00442 this->wfmo_reactor_.wakeup_all_threads ();
00443
00444 return result;
00445 }
|
|
|
Remove all bindings of <ACE_HANDLE, ACE_Event_Handler> tuples.
Definition at line 591 of file WFMO_Reactor.cpp. References ACE_GUARD, handles_to_be_added_, suspended_handles_, unbind_i(), ACE_WFMO_Reactor::wakeup_all_threads(), and wfmo_reactor_. Referenced by close().
00592 {
00593 {
00594 ACE_GUARD (ACE_Process_Mutex, ace_mon, this->wfmo_reactor_.lock_);
00595
00596 int dummy;
00597 size_t i;
00598
00599 // Remove all the current handlers
00600 for (i = 0; i < this->max_handlep1_; ++i)
00601 this->unbind_i (this->current_handles_[i],
00602 ACE_Event_Handler::ALL_EVENTS_MASK,
00603 dummy);
00604
00605 // Remove all the suspended handlers
00606 for (i = 0; i < this->suspended_handles_; ++i)
00607 this->unbind_i (this->current_suspended_info_[i].event_handle_,
00608 ACE_Event_Handler::ALL_EVENTS_MASK,
00609 dummy);
00610
00611 // Remove all the to_be_added handlers
00612 for (i = 0; i < this->handles_to_be_added_; ++i)
00613 this->unbind_i (this->to_be_added_info_[i].event_handle_,
00614 ACE_Event_Handler::ALL_EVENTS_MASK,
00615 dummy);
00616
00617 }
00618
00619 // The guard is released here
00620
00621 // Wake up all threads in WaitForMultipleObjects so that they can
00622 // reconsult the handle set
00623 this->wfmo_reactor_.wakeup_all_threads ();
00624 }
|
|
||||||||||||||||
|
Non-lock-grabbing version of .
Definition at line 189 of file WFMO_Reactor.cpp. References ACE_Reactor_Mask, current_handles_, current_info_, current_suspended_info_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::delete_entry_, ACE_WFMO_Reactor_Handler_Repository::To_Be_Added_Info::event_handle_, ACE_WFMO_Reactor_Handler_Repository::Suspended_Info::event_handle_, handles_to_be_added_, handles_to_be_deleted_, ACE_WFMO_Reactor_Handler_Repository::Common_Info::io_handle_, remove_handler_i(), remove_suspended_handler_i(), remove_to_be_added_handler_i(), suspended_handles_, and to_be_added_info_. Referenced by ACE_WFMO_Reactor::remove_handler(), unbind(), and unbind_all().
00192 {
00193 int error = 0;
00194
00195 // Remember this value; only if it changes do we need to wakeup
00196 // the other threads
00197 size_t const original_handle_count = this->handles_to_be_deleted_;
00198 int result = 0;
00199 size_t i;
00200
00201 // Go through all the handles looking for <handle>. Even if we find
00202 // it, we continue through the rest of the list since <handle> could
00203 // appear multiple times. All handles are checked.
00204
00205 // First check the current entries
00206 for (i = 0; i < this->max_handlep1_ && error == 0; ++i)
00207 // Since the handle can either be the event or the I/O handle,
00208 // we have to check both
00209 if ((this->current_handles_[i] == handle
00210 || this->current_info_[i].io_handle_ == handle)
00211 && // Make sure that it is not already marked for deleted
00212 !this->current_info_[i].delete_entry_)
00213 {
00214 result = this->remove_handler_i (i,
00215 mask);
00216 if (result == -1)
00217 error = 1;
00218 }
00219
00220 // Then check the suspended entries
00221 for (i = 0; i < this->suspended_handles_ && error == 0; ++i)
00222 // Since the handle can either be the event or the I/O handle, we
00223 // have to check both
00224 if ((this->current_suspended_info_[i].io_handle_ == handle
00225 || this->current_suspended_info_[i].event_handle_ == handle)
00226 &&
00227 // Make sure that it is not already marked for deleted
00228 !this->current_suspended_info_[i].delete_entry_)
00229 {
00230 result = this->remove_suspended_handler_i (i,
00231 mask);
00232 if (result == -1)
00233 error = 1;
00234 }
00235
00236 // Then check the to_be_added entries
00237 for (i = 0; i < this->handles_to_be_added_ && error == 0; ++i)
00238 // Since the handle can either be the event or the I/O handle,
00239 // we have to check both
00240 if ((this->to_be_added_info_[i].io_handle_ == handle
00241 || this->to_be_added_info_[i].event_handle_ == handle)
00242 &&
00243 // Make sure that it is not already marked for deleted
00244 !this->to_be_added_info_[i].delete_entry_)
00245 {
00246 result = this->remove_to_be_added_handler_i (i,
00247 mask);
00248 if (result == -1)
00249 error = 1;
00250 }
00251
00252 // Only if the number of handlers to be deleted changes do we need
00253 // to wakeup the other threads
00254 if (original_handle_count < this->handles_to_be_deleted_)
00255 changes_required = 1;
00256
00257 return error ? -1 : 0;
00258 }
|
|
|
Definition at line 106 of file WFMO_Reactor.h. |
|
|
Definition at line 107 of file WFMO_Reactor.h. |
|
|
Array of passed to . This is not part of the structure as the handle array needs to be passed directly to . Definition at line 449 of file WFMO_Reactor.h. Referenced by handler(), handles(), make_changes_in_current_infos(), make_changes_in_suspension_infos(), make_changes_in_to_be_added_infos(), modify_network_events_i(), open(), remove_handler_i(), resume_handler_i(), suspend_handler_i(), unbind_i(), and ~ACE_WFMO_Reactor_Handler_Repository(). |
|
|
Array of current entries in the table.
Definition at line 452 of file WFMO_Reactor.h. Referenced by current_info(), dump(), handler(), make_changes_in_current_infos(), make_changes_in_suspension_infos(), make_changes_in_to_be_added_infos(), modify_network_events_i(), remove_handler_i(), resume_handler_i(), scheduled_for_deletion(), suspend_handler_i(), unbind_i(), and ~ACE_WFMO_Reactor_Handler_Repository(). |
|
|
Currently suspended handles.
Definition at line 464 of file WFMO_Reactor.h. Referenced by dump(), handler(), make_changes_in_current_infos(), make_changes_in_suspension_infos(), make_changes_in_to_be_added_infos(), modify_network_events_i(), remove_suspended_handler_i(), resume_handler_i(), suspend_handler_i(), unbind_i(), and ~ACE_WFMO_Reactor_Handler_Repository(). |
|
|
Number of records to be added.
Definition at line 461 of file WFMO_Reactor.h. Referenced by bind_i(), changes_required(), dump(), handler(), make_changes_in_to_be_added_infos(), modify_network_events_i(), open(), resume_handler_i(), ACE_WFMO_Reactor::resume_handlers(), suspend_handler_i(), ACE_WFMO_Reactor::suspend_handlers(), unbind_all(), and unbind_i(). |
|
|
Number of records to be deleted.
Definition at line 476 of file WFMO_Reactor.h. Referenced by bind_i(), changes_required(), make_changes_in_current_infos(), make_changes_in_suspension_infos(), make_changes_in_to_be_added_infos(), open(), remove_handler_i(), remove_suspended_handler_i(), remove_to_be_added_handler_i(), and unbind_i(). |
|
|
Number of records to be resumed.
Definition at line 473 of file WFMO_Reactor.h. Referenced by changes_required(), make_changes_in_suspension_infos(), open(), remove_suspended_handler_i(), resume_handler_i(), and suspend_handler_i(). |
|
|
Number of records to be suspended.
Definition at line 470 of file WFMO_Reactor.h. Referenced by changes_required(), make_changes_in_current_infos(), make_changes_in_to_be_added_infos(), open(), remove_handler_i(), remove_to_be_added_handler_i(), resume_handler_i(), and suspend_handler_i(). |
|
|
A count of the number of active handles.
Definition at line 455 of file WFMO_Reactor.h. Referenced by ACE_WFMO_Reactor::suspend_handlers(). |
|
|
Maximum number of handles.
Definition at line 442 of file WFMO_Reactor.h. Referenced by ACE_WFMO_Reactor::size(). |
|
|
Number of currently suspended handles.
Definition at line 467 of file WFMO_Reactor.h. Referenced by bind_i(), dump(), handler(), make_changes_in_current_infos(), make_changes_in_suspension_infos(), make_changes_in_to_be_added_infos(), modify_network_events_i(), open(), resume_handler_i(), ACE_WFMO_Reactor::resume_handlers(), suspend_handler_i(), unbind_all(), and unbind_i(). |
|
|
Information for entries to be added.
Definition at line 458 of file WFMO_Reactor.h. Referenced by bind_i(), dump(), handler(), make_changes_in_to_be_added_infos(), modify_network_events_i(), remove_to_be_added_handler_i(), resume_handler_i(), ACE_WFMO_Reactor::resume_handlers(), suspend_handler_i(), ACE_WFMO_Reactor::suspend_handlers(), unbind_i(), and ~ACE_WFMO_Reactor_Handler_Repository(). |
|
|
Reference to our .
Definition at line 439 of file WFMO_Reactor.h. Referenced by bind_i(), current_info(), handles(), max_handlep1(), scheduled_for_deletion(), unbind(), and unbind_all(). |
1.3.6