diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 2002-06-04 15:51:30 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 2002-06-04 15:51:30 +0000 |
commit | 2e8c2bfc686195b9a98d8cf412c3e762ab03b145 (patch) | |
tree | 3f3bc6c0e7e47f19324d8939bd468bd54414a461 /ace | |
parent | 13176c7cfd3ae7d477316d579ecbf437964a44a2 (diff) | |
download | ATCD-2e8c2bfc686195b9a98d8cf412c3e762ab03b145.tar.gz |
ChangeLogTag:Tue Jun 4 10:03:19 2002 Douglas C. Schmidt <schmidt@macarena.cs.wustl.edu>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Message_Queue.cpp | 129 | ||||
-rw-r--r-- | ace/Message_Queue.h | 87 | ||||
-rw-r--r-- | ace/Message_Queue.i | 10 | ||||
-rw-r--r-- | ace/Message_Queue_T.cpp | 70 | ||||
-rw-r--r-- | ace/Message_Queue_T.h | 38 | ||||
-rw-r--r-- | ace/Message_Queue_T.i | 18 |
6 files changed, 212 insertions, 140 deletions
diff --git a/ace/Message_Queue.cpp b/ace/Message_Queue.cpp index 0456f6f3fb5..3e76849fc34 100644 --- a/ace/Message_Queue.cpp +++ b/ace/Message_Queue.cpp @@ -22,8 +22,22 @@ ACE_Message_Queue_Vx::dump (void) const { ACE_TRACE ("ACE_Message_Queue_Vx::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + switch (this->state_) + { + case ACE_Message_Queue_Base::ACTIVATED: + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("state = ACTIVATED\n"))); + break; + case ACE_Message_Queue_Base::DEACTIVATED: + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("state = DEACTIVATED\n"))); + break; + case ACE_Message_Queue_Base::PULSED: + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("state = PULSED\n"))); + break; + } ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("deactivated = %d\n") ACE_LIB_TEXT ("low_water_mark = %d\n") ACE_LIB_TEXT ("high_water_mark = %d\n") ACE_LIB_TEXT ("cur_bytes = %d\n") @@ -31,7 +45,6 @@ ACE_Message_Queue_Vx::dump (void) const ACE_LIB_TEXT ("cur_count = %d\n") ACE_LIB_TEXT ("head_ = %u\n") ACE_LIB_TEXT ("MSG_Q_ID = %u\n"), - this->deactivated_, this->low_water_mark_, this->high_water_mark_, this->cur_bytes_, @@ -75,7 +88,6 @@ ACE_Message_Queue_Vx::open (size_t max_messages, ACE_TRACE ("ACE_Message_Queue_Vx::open"); this->high_water_mark_ = 0; this->low_water_mark_ = 0; - this->deactivated_ = 0; this->cur_bytes_ = 0; this->cur_length_ = 0; this->cur_count_ = 0; @@ -98,32 +110,6 @@ ACE_Message_Queue_Vx::open (size_t max_messages, MSG_Q_FIFO))) == NULL ? -1 : 0; } -// Implementation of the public deactivate() method -// (assumes locks are held). - -int -ACE_Message_Queue_Vx::deactivate_i (void) -{ - ACE_TRACE ("ACE_Message_Queue_Vx::deactivate_i"); - - int current_status = - this->deactivated_ ? WAS_INACTIVE : WAS_ACTIVE; - - this->deactivated_ = 1; - - return current_status; -} - -int -ACE_Message_Queue_Vx::activate_i (void) -{ - ACE_TRACE ("ACE_Message_Queue_Vx::activate_i"); - int current_status = - this->deactivated_ ? WAS_INACTIVE : WAS_ACTIVE; - this->deactivated_ = 0; - return current_status; -} - // Clean up the queue if we have not already done so! int @@ -302,7 +288,6 @@ ACE_Message_Queue_NT::ACE_Message_Queue_NT (size_t max_threads) cur_bytes_ (0), cur_length_ (0), cur_count_ (0), - deactivated_ (0), completion_port_ (ACE_INVALID_HANDLE) { ACE_TRACE ("ACE_Message_Queue_NT::ACE_Message_Queue_NT"); @@ -342,13 +327,17 @@ ACE_Message_Queue_NT::enqueue (ACE_Message_Block *new_item, { ACE_TRACE ("ACE_Message_Queue_NT::enqueue"); ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); - if (!this->deactivated_) + if (this->state_ != ACE_Message_Queue_Base::DEACTIVATED) { size_t msize = new_item->total_size (); size_t mlength = new_item->total_length (); if (::PostQueuedCompletionStatus (this->completion_port_, msize, - this->deactivated_, + // Irfan, can you please figure out what this should be? It used + // to be this->deactivated_, but that was removed... I don't + // see how that ever worked, however, since this seems to want + // to be a pointer! + this->state_, ACE_reinterpret_cast (LPOVERLAPPED, new_item))) { // Update the states once I succeed. @@ -372,8 +361,10 @@ ACE_Message_Queue_NT::dequeue (ACE_Message_Block *&first_item, { ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); - if (this->deactivated_) // Make sure the MQ is not deactivated before - { // I proceed. + + // Make sure the MQ is not deactivated before proceeding. + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) + { errno = ESHUTDOWN; // Operation on deactivated MQ not allowed. return -1; } @@ -409,26 +400,38 @@ ACE_Message_Queue_NT::dequeue (ACE_Message_Block *&first_item, } int -ACE_Message_Queue_NT::deactivate (void) +ACE_Message_Queue_NT::deactivate (int pulse) { ACE_TRACE ("ACE_Message_Queue_NT::deactivate"); ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); - if (this->deactivated_) // Check if I have been deactivated already. - return ACE_Message_Queue_Base::WAS_INACTIVE; - - this->deactivated_ = 1; - - // Get the number of shutdown messages necessary to wake up - // all waiting threads. - - for (size_t cntr = this->cur_thrs_ - this->cur_count_; - cntr > 0; cntr++) - ::PostQueuedCompletionStatus (this->completion_port_, - 0, - this->deactivated_, - NULL); - return ACE_Message_Queue_Base::WAS_ACTIVE; + int previous_status = this->state_; + if (previous_state != ACE_Message_Queue_Base::DEACTIVATED) + { + if (pulse) + this->state_ = ACE_Message_Queue_Base::PULSED; + else + this->state_ = ACE_Message_Queue_Base::DEACTIVATED; + + // Get the number of shutdown messages necessary to wake up all + // waiting threads. + + for (size_t cntr = this->cur_thrs_ - this->cur_count_; + cntr > 0; cntr++) + ::PostQueuedCompletionStatus (this->completion_port_, + 0, + // Irfan, can you please figure + // out what this should be? It + // used to be + // this->deactivated_, but that + // was removed... I don't see + // how that ever worked, + // however, since this seems to + // want to be a pointer! + this->state_, + NULL); + } + return previous_state; } int @@ -436,11 +439,9 @@ ACE_Message_Queue_NT::activate (void) { ACE_TRACE ("ACE_Message_Queue_NT::activate"); ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); - if (!this->deactivated_) - return ACE_Message_Queue_Base::WAS_ACTIVE; - - this->deactivated_ = 0; - return ACE_Message_Queue_Base::WAS_INACTIVE; + int previous_status = this->state_; + this->state_ = ACE_Message_Queue_Base::ACTIVATED; + return previous_status; } void @@ -449,15 +450,29 @@ ACE_Message_Queue_NT::dump (void) const ACE_TRACE ("ACE_Message_Queue_NT::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + switch (this->state_) + { + case ACE_Message_Queue_Base::ACTIVATED: + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("state = ACTIVATED\n"))); + break; + case ACE_Message_Queue_Base::DEACTIVATED: + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("state = DEACTIVATED\n"))); + break; + case ACE_Message_Queue_Base::PULSED: + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("state = PULSED\n"))); + break; + } + ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("deactivated = %d\n") ACE_LIB_TEXT ("max_cthrs_ = %d\n") ACE_LIB_TEXT ("cur_thrs_ = %d\n") ACE_LIB_TEXT ("cur_bytes = %d\n") ACE_LIB_TEXT ("cur_length = %d\n") ACE_LIB_TEXT ("cur_count = %d\n") ACE_LIB_TEXT ("completion_port_ = %x\n"), - this->deactivated_, this->max_cthrs_, this->cur_thrs_, this->cur_bytes_, diff --git a/ace/Message_Queue.h b/ace/Message_Queue.h index 1fe16763b6a..4f957217d45 100644 --- a/ace/Message_Queue.h +++ b/ace/Message_Queue.h @@ -38,6 +38,11 @@ template <ACE_SYNCH_DECL> class ACE_Message_Queue_Reverse_Iterator; * block until action is possible if <timeout> == 0. Otherwise, it * will wait until the absolute time specified in *<timeout> * elapses. + * + * A queue is always in one of three states: + * . ACTIVATED + * . DEACTIVATED + * . PULSED */ class ACE_Export ACE_Message_Queue_Base { @@ -49,10 +54,22 @@ public: DEFAULT_HWM = 16 * 1024, /// Default low watermark (same as high water mark). DEFAULT_LWM = 16 * 1024, - /// Message queue was active before <activate> or <deactivate>. - WAS_ACTIVE = 1, - /// Message queue was inactive before <activate> or <deactivate>. - WAS_INACTIVE = 2 + + /// Message queue was activated before <activate> or <deactivate>. + WAS_ACTIVE = 1, /* DEPRECATED */ + WAS_ACTIVATED = 1, + + /// Message queue was deactivated before <activate> or <deactivate>. + WAS_INACTIVE = 2, /* DEPRECATED */ + WAS_DEACTIVATED = 2, + + /// Message queue was pulsed before <activate> or <deactivate>. + WAS_PULSED = 3, + + /// The following are the states that a queue can be in. + ACTIVATED = 0, + DEACTIVATED = 1, + PULSED = 2 }; ACE_Message_Queue_Base (void); @@ -136,24 +153,27 @@ public: // = Activation control methods. /** - * Deactivate the queue and wakeup all threads waiting on the queue - * so they can continue. No messages are removed from the queue, - * however. Any other operations called until the queue is - * activated again will immediately return -1 with <errno> == - * ESHUTDOWN. Returns WAS_INACTIVE if queue was inactive before the - * call and WAS_ACTIVE if queue was active before the call. - */ + * Notify all waiting threads so they can wakeup and continue other + * processing. If <pulse> is 0 the queue's state is changed to + * deactivated and other operations called until the queue is + * activated again will return -1 with <errno> == ESHUTDOWN. If <pulse> is + * non-0 then only the waiting threads are notified and the queue's state + * is not changed. In either case, however, no messages are removed + * from the queue. Return the state of the queue before the call. */ virtual int deactivate (int pulse = 0) = 0; /** * Reactivate the queue so that threads can enqueue and dequeue - * messages again. Returns WAS_INACTIVE if queue was inactive - * before the call and WAS_ACTIVE if queue was active before the - * call. + * messages again. Returns the state of the queue before the call. */ virtual int activate (void) = 0; - /// Returns true if <deactivated_> is enabled. + /// Returns the current state of the queue, which can either + /// be <ACTIVATED>, <DEACTIVATED>, or <PULSED>. + virtual int state (void) = 0; + + /// Returns true if the state of the queue is <DEACTIVATED>, + /// but false if the queue's is <ACTIVATED> or <PULSED>. virtual int deactivated (void) = 0; /// Get the notification strategy for the <Message_Queue> @@ -326,12 +346,6 @@ protected: // These methods assume locks are held. - /// Deactivate the queue. - virtual int deactivate_i (void); - - /// Activate the queue. - virtual int activate_i (void); - // = Helper methods to factor out common #ifdef code. /// Wait for the queue to become non-full. virtual int wait_not_full_cond (ACE_Guard<ACE_Null_Mutex> &mon, @@ -481,26 +495,28 @@ public: // = Activation control methods. /** - * Deactivate the queue and wakeup all threads waiting on the queue - * so they can continue. Messages already in the queue get removed. - * If there are more messages in the queue than there are threads - * waiting on the queue, the left over messages will not be removed. - * Any other enqueue/dequeue operations called until the queue is - * activated again will immediately return -1 with <errno> == - * ESHUTDOWN. Returns WAS_INACTIVE if queue was inactive before the - * call and WAS_ACTIVE if queue was active before the call. + * Notify all waiting threads so they can wakeup and continue other + * processing. If <pulse> is 0 the queue's state is changed to + * deactivated and other operations called until the queue is + * activated again will return -1 with <errno> == ESHUTDOWN. If <pulse> is + * non-0 then only the waiting threads are notified and the queue's state + * is not changed. In either case, however, no messages are removed + * from the queue. Returns the state of the queue before the call. */ */ - virtual int deactivate (void); + virtual int deactivate (int pulse = 0); /** * Reactivate the queue so that threads can enqueue and dequeue - * messages again. Returns WAS_INACTIVE if queue was inactive - * before the call and WAS_ACTIVE if queue was active before the - * call. + * messages again. Returns the state of the queue before the call. */ virtual int activate (void); - /// Returns true if <deactivated_> is enabled. + /// Returns the current state of the queue, which can either + /// be <ACTIVATED>, <DEACTIVATED>, or <PULSED>. + virtual int state (void); + + /// Returns true if the state of the queue is <DEACTIVATED>, + /// but false if the queue's is <ACTIVATED> or <PULSED>. virtual int deactivated (void); // = Not currently implemented... @@ -545,9 +561,6 @@ private: */ ACE_Thread_Mutex lock_; - /// Indicates that the queue is inactive. - int deactivated_; - /// Underlying NT IoCompletionPort. ACE_HANDLE completion_port_; diff --git a/ace/Message_Queue.i b/ace/Message_Queue.i index 8cf619653a8..943f32aff62 100644 --- a/ace/Message_Queue.i +++ b/ace/Message_Queue.i @@ -186,12 +186,20 @@ ACE_Message_Queue_NT::max_threads (void) return this->max_cthrs_; } +template <ACE_SYNCH_DECL> ACE_INLINE int +ACE_Message_Queue_NT<ACE_SYNCH_USE>::state (void) +{ + ACE_TRACE ("ACE_Message_Queue_NT<ACE_SYNCH_USE>::state"); + + return this->state_; +} + ACE_INLINE int ACE_Message_Queue_NT::deactivated (void) { ACE_TRACE ("ACE_Message_Queue_NT::deactivated"); // Accessing to int must be atomic. - return this->deactivated_; + return this->state_ == ACE_Message_Queue_Base::DEACTIVATED; } ACE_INLINE ACE_HANDLE diff --git a/ace/Message_Queue_T.cpp b/ace/Message_Queue_T.cpp index 8685ef37901..7c6399a6374 100644 --- a/ace/Message_Queue_T.cpp +++ b/ace/Message_Queue_T.cpp @@ -428,8 +428,22 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dump (void) const { ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dump"); ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + switch (this->state_) + { + case ACE_Message_Queue_Base::ACTIVATED: + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("state = ACTIVATED\n"))); + break; + case ACE_Message_Queue_Base::DEACTIVATED: + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("state = DEACTIVATED\n"))); + break; + case ACE_Message_Queue_Base::PULSED: + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("state = PULSED\n"))); + break; + } ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("deactivated = %d\n") ACE_LIB_TEXT ("low_water_mark = %d\n") ACE_LIB_TEXT ("high_water_mark = %d\n") ACE_LIB_TEXT ("cur_bytes = %d\n") @@ -437,7 +451,6 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dump (void) const ACE_LIB_TEXT ("cur_count = %d\n") ACE_LIB_TEXT ("head_ = %u\n") ACE_LIB_TEXT ("tail_ = %u\n"), - this->deactivated_, this->low_water_mark_, this->high_water_mark_, this->cur_bytes_, @@ -543,7 +556,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::open (size_t hwm, ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::open"); this->high_water_mark_ = hwm; this->low_water_mark_ = lwm; - this->deactivated_ = 0; + this->state_ = ACE_Message_Queue_Base::ACTIVATED; this->cur_bytes_ = 0; this->cur_length_ = 0; this->cur_count_ = 0; @@ -560,28 +573,31 @@ template <ACE_SYNCH_DECL> int ACE_Message_Queue<ACE_SYNCH_USE>::deactivate_i (int pulse) { ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::deactivate_i"); - int current_status = - this->deactivated_ ? WAS_INACTIVE : WAS_ACTIVE; + int previous_state = this->state_; - // Wakeup all waiters. + if (previous_state != ACE_Message_Queue_Base::DEACTIVATED) + { + // Wakeup all waiters. #if !defined (ACE_HAS_OPTIMIZED_MESSAGE_QUEUE) - this->not_empty_cond_.broadcast (); - this->not_full_cond_.broadcast (); + this->not_empty_cond_.broadcast (); + this->not_full_cond_.broadcast (); #endif /* ACE_HAS_OPTIMIZED_MESSAGE_QUEUE */ - if (pulse == 0) - this->deactivated_ = 1; - return current_status; + if (pulse) + this->state_ = ACE_Message_Queue_Base::PULSED; + else + this->state_ = ACE_Message_Queue_Base::DEACTIVATED; + } + return previous_state; } template <ACE_SYNCH_DECL> int ACE_Message_Queue<ACE_SYNCH_USE>::activate_i (void) { ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::activate_i"); - int current_status = - this->deactivated_ ? WAS_INACTIVE : WAS_ACTIVE; - this->deactivated_ = 0; - return current_status; + int previous_state = this->state_; + this->state_ = ACE_Message_Queue_Base::ACTIVATED; + return previous_state; } template <ACE_SYNCH_DECL> int @@ -1094,7 +1110,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head (ACE_Message_Block *&first_i ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::peek_dequeue_head"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - if (this->deactivated_) + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) { errno = ESHUTDOWN; return -1; @@ -1146,7 +1162,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_full_cond (ACE_Guard<ACE_SYNCH_MUTEX_ result = -1; break; } - if (this->deactivated_) + if (this->state_ != ACE_Message_Queue_Base::ACTIVATED) { errno = ESHUTDOWN; result = -1; @@ -1194,7 +1210,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_empty_cond (ACE_Guard<ACE_SYNCH_MUTEX result = -1; break; } - if (this->deactivated_) + if (this->state_ != ACE_Message_Queue_Base::ACTIVATED) { errno = ESHUTDOWN; result = -1; @@ -1217,7 +1233,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head (ACE_Message_Block *new_item, { ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - if (this->deactivated_) + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) { errno = ESHUTDOWN; return -1; @@ -1249,7 +1265,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_prio (ACE_Message_Block *new_item, { ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - if (this->deactivated_) + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) { errno = ESHUTDOWN; return -1; @@ -1280,7 +1296,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_deadline (ACE_Message_Block *new_item, { ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - if (this->deactivated_) + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) { errno = ESHUTDOWN; return -1; @@ -1318,7 +1334,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail (ACE_Message_Block *new_item, { ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - if (this->deactivated_) + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) { errno = ESHUTDOWN; return -1; @@ -1348,7 +1364,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head (ACE_Message_Block *&first_item, ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - if (this->deactivated_) + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) { errno = ESHUTDOWN; return -1; @@ -1371,7 +1387,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio (ACE_Message_Block *&dequeued, ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_prio"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - if (this->deactivated_) + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) { errno = ESHUTDOWN; return -1; @@ -1394,7 +1410,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail (ACE_Message_Block *&dequeued, ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_tail"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - if (this->deactivated_) + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) { errno = ESHUTDOWN; return -1; @@ -1417,7 +1433,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline (ACE_Message_Block *&dequeued ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_deadline"); ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - if (this->deactivated_) + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) { errno = ESHUTDOWN; return -1; @@ -1618,7 +1634,7 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head (ACE_Message_Block *&firs ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, -1); - if (this->deactivated_) + if (this->state_ == ACE_Message_Queue_Base::DEACTIVATED) { errno = ESHUTDOWN; return -1; diff --git a/ace/Message_Queue_T.h b/ace/Message_Queue_T.h index 77f58a3c01f..445a4710f32 100644 --- a/ace/Message_Queue_T.h +++ b/ace/Message_Queue_T.h @@ -311,19 +311,21 @@ public: * activated again will return -1 with <errno> == ESHUTDOWN. If <pulse> is * non-0 then only the waiting threads are notified and the queue's state * is not changed. In either case, however, no messages are removed - * from the queue. Returns WAS_INACTIVE if queue was inactive before - * the call and WAS_ACTIVE if queue was active before the call. */ + * from the queue. Returns the state of the queue before the call. */ virtual int deactivate (int pulse = 0); /** * Reactivate the queue so that threads can enqueue and dequeue - * messages again. Returns WAS_INACTIVE if queue was inactive - * before the call and WAS_ACTIVE if queue was active before the - * call. + * messages again. Returns the state of the queue before the call. */ virtual int activate (void); - /// Returns true if <deactivated_> is enabled. + /// Returns the current state of the queue, which can either + /// be <ACTIVATED>, <DEACTIVATED>, or <PULSED>. + virtual int state (void); + + /// Returns true if the state of the queue is <DEACTIVATED>, + /// but false if the queue's is <ACTIVATED> or <PULSED>. virtual int deactivated (void); // = Notification hook. @@ -413,8 +415,7 @@ protected: * immediately return -1 with <errno> == ESHUTDOWN. If <pulse> is * non-0 then only the waiting threads are notified and the queue's state * is not changed. In either case, however, no messages are removed - * from the queue. Returns WAS_INACTIVE if queue was inactive before - * the call and WAS_ACTIVE if queue was active before the call. */ + * from the queue. Returns the state of the queue before the call. */ virtual int deactivate_i (int pulse = 0); /// Activate the queue. @@ -457,8 +458,9 @@ protected: /// Current number of messages in the queue. size_t cur_count_; - /// Indicates that the queue is inactive. - int deactivated_; + /// Indicates the state of the queue, which can be + /// <ACTIVATED>, <DEACTIVATED>, or <PULSED>. + int state_; /// The notification strategy used when a new message is enqueued. ACE_Notification_Strategy *notification_strategy_; @@ -1132,19 +1134,21 @@ public: * activated again will return -1 with <errno> == ESHUTDOWN. If <pulse> is * non-0 then only the waiting threads are notified and the queue's state * is not changed. In either case, however, no messages are removed - * from the queue. Returns WAS_INACTIVE if queue was inactive before - * the call and WAS_ACTIVE if queue was active before the call. */ - virtual int deactivate (int pulse); + * from the queue. Returns the state of the queue before the call. */ + virtual int deactivate (int pulse = 0); /** * Reactivate the queue so that threads can enqueue and dequeue - * messages again. Returns WAS_INACTIVE if queue was inactive - * before the call and WAS_ACTIVE if queue was active before the - * call. + * messages again. Returns the state of the queue before the call. */ virtual int activate (void); - /// Returns true if <deactivated_> is enabled. + /// Returns the current state of the queue, which can either + /// be <ACTIVATED>, <DEACTIVATED>, or <PULSED>. + virtual int state (void); + + /// Returns true if the state of the queue is <DEACTIVATED>, + /// but false if the queue's is <ACTIVATED> or <PULSED>. virtual int deactivated (void); // = Notification hook. diff --git a/ace/Message_Queue_T.i b/ace/Message_Queue_T.i index 3791a4d2c25..6561ca2a85f 100644 --- a/ace/Message_Queue_T.i +++ b/ace/Message_Queue_T.i @@ -151,7 +151,15 @@ ACE_Message_Queue<ACE_SYNCH_USE>::deactivated (void) { ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::deactivated"); - return this->deactivated_; + return this->state_ == ACE_Message_Queue_Base::DEACTIVATED; +} + +template <ACE_SYNCH_DECL> ACE_INLINE int +ACE_Message_Queue<ACE_SYNCH_USE>::state (void) +{ + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::state"); + + return this->state_; } #if 0 @@ -292,6 +300,14 @@ ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::deactivated (void) return this->queue_.deactivated (); } +template <class ACE_MESSAGE_TYPE, ACE_SYNCH_DECL> ACE_INLINE int +ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::state (void) +{ + ACE_TRACE ("ACE_Message_Queue_Ex<ACE_MESSAGE_TYPE, ACE_SYNCH_USE>::state"); + + return this->queue_.state (); +} + #if 0 // The Sun Forte 6 (CC 5.1) compiler is only happy if this is in the // header file (j.russell.noseworthy@objectsciences.com) |