diff options
author | bala <balanatarajan@users.noreply.github.com> | 2001-08-21 12:54:22 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2001-08-21 12:54:22 +0000 |
commit | b8fdce58ac50924887557d5d10060d1c47e1a4a4 (patch) | |
tree | 4388fdfda220cd32e82dc112ca3fdbf3fe6dcbab | |
parent | 63c15883c4829ba39e05107a5f491bf3887b0dc3 (diff) | |
download | ATCD-b8fdce58ac50924887557d5d10060d1c47e1a4a4.tar.gz |
ChangeLogTag:Tue Aug 21 07:58:42 2001 Balachandran Natarajan <bala@cs.wustl.edu>
-rw-r--r-- | ace/TP_Reactor.cpp | 137 | ||||
-rw-r--r-- | ace/TP_Reactor.h | 10 | ||||
-rw-r--r-- | ace/TP_Reactor.i | 11 |
3 files changed, 94 insertions, 64 deletions
diff --git a/ace/TP_Reactor.cpp b/ace/TP_Reactor.cpp index 9b3881ea3b4..8fe6ecd6fc0 100644 --- a/ace/TP_Reactor.cpp +++ b/ace/TP_Reactor.cpp @@ -66,25 +66,7 @@ ACE_TP_Reactor::handle_events (ACE_Time_Value *max_wait_time) // called. ACE_Countdown_Time countdown (max_wait_time); - // The order of these events is very subtle, modify with care. - - // Try to grab the lock. If someone if already there, don't wake - // them up, just queue up in the thread pool. - int result = 0; - - if (max_wait_time) - { - ACE_Time_Value tv = ACE_OS::gettimeofday (); - tv += *max_wait_time; - - ACE_MT (result = this->token_.acquire_read (&ACE_TP_Reactor::no_op_sleep_hook, - 0, - &tv)); - } - else - { - ACE_MT (result = this->token_.acquire_read (&ACE_TP_Reactor::no_op_sleep_hook)); - } + int result = this->grab_token (max_wait_time); // Update the countdown to reflect time waiting for the token. countdown.update (); @@ -107,9 +89,23 @@ ACE_TP_Reactor::handle_events (ACE_Time_Value *max_wait_time) return -1; } - // We got the lock, lets handle some events. Note: this method will + // We got the lock, lets handle some events. We collect the events + // that we need to handle. We release the token and then handle + // those events that needs handling. + int event_count = this->get_event_for_dispatching (max_wait_time); + + + // @@ Look for signals that needs dispatching + // @@ Timeouts that need dispatching, if any timeouts, just return + // @@ after dispatching + // @@ Notify that needs dispatching, if any, just return after + // dispatching. + // @@ Socket events + + // Note: this method will // *not* dispatch any I/O handlers. It will dispatch signals, // timeouts, and notifications. + ACE_EH_Dispatch_Info dispatch_info; result = this->dispatch_i_protected (max_wait_time, dispatch_info); if (result == -1) @@ -201,39 +197,6 @@ ACE_TP_Reactor::dispatch_i (ACE_Time_Value *max_wait_time, event.reset (); // Nothing to dispatch yet - // If the reactor handler state has changed, clear any remembered - // ready bits and re-scan from the master wait_set. - if (this->state_changed_) - { - this->ready_set_.rd_mask_.reset (); - this->ready_set_.wr_mask_.reset (); - this->ready_set_.ex_mask_.reset (); - this->state_changed_ = 0; - } - else - { - // This is a hack... somewhere, under certain conditions (which - // I don't understand...) the mask will have all of its bits clear, - // yet have a size_ > 0. This is an attempt to remedy the affect, - // without knowing why it happens. - - //# if !(defined (__SUNPRO_CC) && (__SUNPRO_CC > 0x500)) - // SunCC seems to be having problems with this piece of code - // here. I am not sure why though. This works fine with other - // compilers. As we dont seem to understand when this piece of - // code is needed and as it creates problems for SunCC we will - // not compile this. Most of the tests in TAO seem to be happy - // without this in SunCC. - this->ready_set_.rd_mask_.sync (this->ready_set_.rd_mask_.max_set ()); - this->ready_set_.wr_mask_.sync (this->ready_set_.wr_mask_.max_set ()); - this->ready_set_.ex_mask_.sync (this->ready_set_.ex_mask_.max_set ()); - //# endif /* ! __SUNPRO_CC */ - - } - - int active_handle_count = this->wait_for_multiple_events (this->ready_set_, - max_wait_time); - int handlers_dispatched = 0; int signal_occurred = 0; @@ -436,12 +399,80 @@ ACE_TP_Reactor::notify_handle (ACE_EH_Dispatch_Info &dispatch_info) } int +ACE_TP_Reactor::get_event_for_dispatching (ACE_Time_Value *max_wait_time) +{ + // If the reactor handler state has changed, clear any remembered + // ready bits and re-scan from the master wait_set. + if (this->state_changed_) + { + this->ready_set_.rd_mask_.reset (); + this->ready_set_.wr_mask_.reset (); + this->ready_set_.ex_mask_.reset (); + this->state_changed_ = 0; + } + else + { + // This is a hack... somewhere, under certain conditions (which + // I don't understand...) the mask will have all of its bits clear, + // yet have a size_ > 0. This is an attempt to remedy the affect, + // without knowing why it happens. + this->ready_set_.rd_mask_.sync (this->ready_set_.rd_mask_.max_set ()); + this->ready_set_.wr_mask_.sync (this->ready_set_.wr_mask_.max_set ()); + this->ready_set_.ex_mask_.sync (this->ready_set_.ex_mask_.max_set ()); + } + + return this->wait_for_multiple_events (this->ready_set_, + max_wait_time); +} + + +int +ACE_TP_Reactor::grab_token (ACE_Time_Value *max_wait_time) +{ + ACE_TRACE ("ACE_TP_Reactor::grab_token"); + + // The order of these events is very subtle, modify with care. + + // Try to grab the lock. If someone if already there, don't wake + // them up, just queue up in the thread pool. + int result = 0; + + if (max_wait_time) + { + ACE_Time_Value tv = ACE_OS::gettimeofday (); + tv += *max_wait_time; + + ACE_MT (result = this->token_.acquire_read (&ACE_TP_Reactor::no_op_sleep_hook, + 0, + &tv)); + } + else + { + ACE_MT (result = this->token_.acquire_read (&ACE_TP_Reactor::no_op_sleep_hook)); + } + + return result; +} + + +int ACE_TP_Reactor::resumable_handler (void) { return 1; } +void +ACE_TP_Reactor::notify_handle (ACE_HANDLE, + ACE_Reactor_Mask, + ACE_Handle_Set &, + ACE_Event_Handler *, + ACE_EH_PTMF) +{ + ACE_ERROR ((LM_ERROR, + ACE_LIB_TEXT ("ACE_TP_Reactor::notify_handle: Wrong version of notify_handle() gets called"))); +} + ACE_EH_Dispatch_Info::ACE_EH_Dispatch_Info (void) { this->reset (); diff --git a/ace/TP_Reactor.h b/ace/TP_Reactor.h index 65f85383058..903aaedf0e9 100644 --- a/ace/TP_Reactor.h +++ b/ace/TP_Reactor.h @@ -214,6 +214,16 @@ protected: /// associated with <handle> that a particular event has occurred. virtual int notify_handle (ACE_EH_Dispatch_Info &dispatch_info); + /// Get the event that needs dispatching.It could be either a + /// signal, timer, notification handlers or return possibly 1 I/O + /// handler for dispatching. In the most common use case, this would + /// return 1 I/O handler for dispatching + int get_event_for_dispatching (); + + /// A helper method that grabs the token for us, after which we can + /// do some actual work. + int grab_token (ACE_Time_Value *max_wait_time); + private: /// Deny access since member-wise won't work... ACE_TP_Reactor (const ACE_TP_Reactor &); diff --git a/ace/TP_Reactor.i b/ace/TP_Reactor.i index 091124adbef..1b419dc20a2 100644 --- a/ace/TP_Reactor.i +++ b/ace/TP_Reactor.i @@ -14,14 +14,3 @@ ACE_TP_Reactor::mask_ops (ACE_Event_Handler *eh, { return this->mask_ops (eh->get_handle (), mask, ops); } - -ACE_INLINE void -ACE_TP_Reactor::notify_handle (ACE_HANDLE, - ACE_Reactor_Mask, - ACE_Handle_Set &, - ACE_Event_Handler *, - ACE_EH_PTMF) -{ - ACE_ERROR ((LM_ERROR, - ACE_LIB_TEXT ("ACE_TP_Reactor::notify_handle: Wrong version of notify_handle() gets called"))); -} |