summaryrefslogtreecommitdiff
path: root/ace/WFMO_Reactor.cpp
diff options
context:
space:
mode:
authorirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-03-31 01:41:20 +0000
committerirfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2000-03-31 01:41:20 +0000
commit1bfe720230c57e03d62d9c2c00fd4727b96ce74f (patch)
treea030449cc221efe6cc58c34d5956c1100ef51fff /ace/WFMO_Reactor.cpp
parent7cd87aad768be7a3cfe08b654a31acc64e227a55 (diff)
downloadATCD-1bfe720230c57e03d62d9c2c00fd4727b96ce74f.tar.gz
ChangeLogTag: Thu Mar 30 19:25:14 2000 Irfan Pyarali <irfan@cs.wustl.edu>
Diffstat (limited to 'ace/WFMO_Reactor.cpp')
-rw-r--r--ace/WFMO_Reactor.cpp71
1 files changed, 50 insertions, 21 deletions
diff --git a/ace/WFMO_Reactor.cpp b/ace/WFMO_Reactor.cpp
index 8091712966a..c936137b13c 100644
--- a/ace/WFMO_Reactor.cpp
+++ b/ace/WFMO_Reactor.cpp
@@ -431,14 +431,13 @@ int
ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i (ACE_HANDLE handle,
int &changes_required)
{
- // Remember this value; only if it changes do we need to wakeup
- // the other threads
- size_t original_handle_count = this->handles_to_be_suspended_;
size_t i = 0;
// Go through all the handles looking for <handle>. Even if we find
// it, we continue through the rest of the list since <handle> could
// appear multiple times. All handles are checked.
+
+ // Check the current entries first.
for (i = 0; i < this->max_handlep1_; i++)
// Since the handle can either be the event or the I/O handle,
// we have to check both
@@ -451,9 +450,28 @@ ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i (ACE_HANDLE handle,
this->current_info_[i].suspend_entry_ = 1;
// Increment the handle count
this->handles_to_be_suspended_++;
+ // Changes will be required
+ changes_required = 1;
}
- // Then check the to_be_added entries
+ // Then check the suspended entries.
+ for (i = 0; i < this->suspended_handles_; i++)
+ // Since the handle can either be the event or the I/O handle,
+ // we have to check both
+ if ((this->current_suspended_info_[i].event_handle_ == handle ||
+ this->current_suspended_info_[i].io_handle_ == handle) &&
+ // Make sure that the resumption is not already undone
+ this->current_suspended_info_[i].resume_entry_)
+ {
+ // Undo resumption
+ this->current_suspended_info_[i].resume_entry_ = 0;
+ // Decrement the handle count
+ this->handles_to_be_resumed_--;
+ // Changes will be required
+ changes_required = 1;
+ }
+
+ // Then check the to_be_added entries.
for (i = 0; i < this->handles_to_be_added_; i++)
// Since the handle can either be the event or the I/O handle,
// we have to check both
@@ -466,13 +484,10 @@ ACE_WFMO_Reactor_Handler_Repository::suspend_handler_i (ACE_HANDLE handle,
this->to_be_added_info_[i].suspend_entry_ = 1;
// Increment the handle count
this->handles_to_be_suspended_++;
+ // Changes will be required
+ changes_required = 1;
}
- // Only if the number of handlers to be deleted changes do we need
- // to wakeup the other threads
- if (original_handle_count < this->handles_to_be_suspended_)
- changes_required = 1;
-
return 0;
}
@@ -480,15 +495,30 @@ int
ACE_WFMO_Reactor_Handler_Repository::resume_handler_i (ACE_HANDLE handle,
int &changes_required)
{
- // Remember this value; only if it changes do we need to wakeup
- // the other threads
- size_t original_handle_count = this->handles_to_be_resumed_;
+ size_t i = 0;
// Go through all the handles looking for <handle>. Even if we find
// it, we continue through the rest of the list since <handle> could
// appear multiple times. All handles are checked.
- size_t i = 0;
+ // Check the current entries first.
+ for (i = 0; i < this->max_handlep1_; i++)
+ // Since the handle can either be the event or the I/O handle,
+ // we have to check both
+ if ((this->current_handles_[i] == handle ||
+ this->current_info_[i].io_handle_ == handle) &&
+ // Make sure that the suspension is not already undone
+ this->current_info_[i].suspend_entry_)
+ {
+ // Undo suspension
+ this->current_info_[i].suspend_entry_ = 0;
+ // Decrement the handle count
+ this->handles_to_be_suspended_--;
+ // Changes will be required
+ changes_required = 1;
+ }
+
+ // Then check the suspended entries.
for (i = 0; i < this->suspended_handles_; i++)
// Since the handle can either be the event or the I/O handle,
// we have to check both
@@ -501,28 +531,27 @@ ACE_WFMO_Reactor_Handler_Repository::resume_handler_i (ACE_HANDLE handle,
this->current_suspended_info_[i].resume_entry_ = 1;
// Increment the handle count
this->handles_to_be_resumed_++;
+ // Changes will be required
+ changes_required = 1;
}
- // Then check the to_be_added entries
+ // Then check the to_be_added entries.
for (i = 0; i < this->handles_to_be_added_; i++)
// Since the handle can either be the event or the I/O handle,
// we have to check both
if ((this->to_be_added_info_[i].io_handle_ == handle ||
this->to_be_added_info_[i].event_handle_ == handle) &&
- // Make sure that it is not already marked for resumption
+ // Make sure that the suspension is not already undone
this->to_be_added_info_[i].suspend_entry_)
{
- // Mark to be resumed
+ // Undo suspension
this->to_be_added_info_[i].suspend_entry_ = 0;
// Decrement the handle count
this->handles_to_be_suspended_--;
+ // Changes will be required
+ changes_required = 1;
}
- // Only if the number of handlers to be deleted changes do we need
- // to wakeup the other threads
- if (original_handle_count < this->handles_to_be_resumed_)
- changes_required = 1;
-
return 0;
}