diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-10-07 23:50:08 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-10-07 23:50:08 +0000 |
commit | e095eecfca25482b510bf86b84c7fddb11d592a7 (patch) | |
tree | 01c94324085158bbf64331947d9f26226c4a2c17 /ace | |
parent | f8530a7b1f9727baa2a1606e97df41c5d33e33bc (diff) | |
download | ATCD-e095eecfca25482b510bf86b84c7fddb11d592a7.tar.gz |
ChangeLogTag:Thu Oct 07 18:47:03 1999 Irfan Pyarali <irfan@cs.wustl.edu>
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Message_Block.h | 3 | ||||
-rw-r--r-- | ace/Message_Block.i | 20 | ||||
-rw-r--r-- | ace/Message_Queue.cpp | 8 | ||||
-rw-r--r-- | ace/Message_Queue.h | 48 | ||||
-rw-r--r-- | ace/Message_Queue.i | 58 | ||||
-rw-r--r-- | ace/Message_Queue_T.cpp | 11 | ||||
-rw-r--r-- | ace/Message_Queue_T.h | 18 | ||||
-rw-r--r-- | ace/Message_Queue_T.i | 31 | ||||
-rw-r--r-- | ace/OS.h | 2 |
9 files changed, 179 insertions, 20 deletions
diff --git a/ace/Message_Block.h b/ace/Message_Block.h index 9b4d240dcc7..e9bce3848e2 100644 --- a/ace/Message_Block.h +++ b/ace/Message_Block.h @@ -322,6 +322,9 @@ public: // Get the length of the message void length (size_t n); // Set the length of the message + size_t total_length (void) const; + // Get the length of the <Message_Block>s, including chained + // <Message_Block>s. // = Set/get <Message_Block> size info. size_t total_size (void) const; diff --git a/ace/Message_Block.i b/ace/Message_Block.i index 7d384afe5f9..d73d1f3f986 100644 --- a/ace/Message_Block.i +++ b/ace/Message_Block.i @@ -100,6 +100,22 @@ ACE_Message_Block::length (void) const return this->wr_ptr_ - this->rd_ptr_; } +ACE_INLINE size_t +ACE_Message_Block::total_length (void) const +{ + ACE_TRACE ("ACE_Message_Block::total_length"); + + size_t length = 0; + for (const ACE_Message_Block *i = this; + i != 0; + i = i->cont ()) + { + length += i->length (); + } + + return length; +} + // Sets the length of the "active" portion of the message. This is // defined as the offset from RD_PTR to WR_PTR. @@ -223,8 +239,8 @@ ACE_Message_Block::base (void) const ACE_INLINE void ACE_Message_Block::base (char *msg_data, - size_t msg_length, - Message_Flags msg_flags) + size_t msg_length, + Message_Flags msg_flags) { ACE_TRACE ("ACE_Message_Block::base"); this->rd_ptr_ = 0; diff --git a/ace/Message_Queue.cpp b/ace/Message_Queue.cpp index 574f3d5f6e8..efa5a891cb1 100644 --- a/ace/Message_Queue.cpp +++ b/ace/Message_Queue.cpp @@ -28,6 +28,7 @@ ACE_Message_Queue_Vx::dump (void) const ASYS_TEXT ("low_water_mark = %d\n") ASYS_TEXT ("high_water_mark = %d\n") ASYS_TEXT ("cur_bytes = %d\n") + ASYS_TEXT ("cur_length = %d\n") ASYS_TEXT ("cur_count = %d\n") ASYS_TEXT ("head_ = %u\n") ASYS_TEXT ("MSG_Q_ID = %u\n"), @@ -35,6 +36,7 @@ ACE_Message_Queue_Vx::dump (void) const this->low_water_mark_, this->high_water_mark_, this->cur_bytes_, + this->cur_length_, this->cur_count_, this->head_, this->tail_)); @@ -76,6 +78,7 @@ ACE_Message_Queue_Vx::open (size_t max_messages, this->low_water_mark_ = 0; this->deactivated_ = 0; this->cur_bytes_ = 0; + this->cur_length_ = 0; this->cur_count_ = 0; this->head_ = 0; this->notification_strategy_ = ns; @@ -268,6 +271,7 @@ ACE_Message_Queue_NT::ACE_Message_Queue_NT (size_t max_threads) : max_cthrs_ (max_threads), cur_thrs_ (0), cur_bytes_ (0), + cur_length_ (0), cur_count_ (0), deactivated_ (0), completion_port_ (ACE_INVALID_HANDLE) @@ -323,6 +327,7 @@ ACE_Message_Queue_NT::enqueue (ACE_Message_Block *new_item, { // Update the states once I succeed. this->cur_bytes_ += msize; + this->cur_length_ += temp->length (); return ++this->cur_count_; } } @@ -367,6 +372,7 @@ ACE_Message_Queue_NT::dequeue (ACE_Message_Block *&first_item, { // Really get a valid MB from the queue. --this->cur_count_; this->cur_bytes_ -= msize; + this->cur_length_ -= first_item->length (); return this->cur_count_; } else // I am woken up by deactivate (). @@ -422,12 +428,14 @@ ACE_Message_Queue_NT::dump (void) const ASYS_TEXT ("max_cthrs_ = %d\n") ASYS_TEXT ("cur_thrs_ = %d\n") ASYS_TEXT ("cur_bytes = %d\n") + ASYS_TEXT ("cur_length = %d\n") ASYS_TEXT ("cur_count = %d\n") ASYS_TEXT ("completion_port_ = %x\n"), this->deactivated_, this->max_cthrs_, this->cur_thrs_, this->cur_bytes_, + this->cur_length_, this->cur_count_, this->completion_port_)); ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); diff --git a/ace/Message_Queue.h b/ace/Message_Queue.h index 2b1a8f78243..75632ba2273 100644 --- a/ace/Message_Queue.h +++ b/ace/Message_Queue.h @@ -93,10 +93,23 @@ public: // = Queue statistic methods. virtual size_t message_bytes (void) = 0; - // Number of total bytes on the queue. + // Number of total bytes on the queue, i.e., sum of the message + // block sizes. + virtual size_t message_length (void) = 0; + // Number of total length on the queue, i.e., sum of the message + // block lengths. virtual size_t message_count (void) = 0; // Number of total messages on the queue. + // = Manual changes to these stats (used when queued message blocks + // change size or lengths). + virtual void message_bytes (size_t new_size) = 0; + // New value of the number of total bytes on the queue, i.e., sum of + // the message block sizes. + virtual void message_length (size_t new_length) = 0; + // New value of the number of total length on the queue, i.e., sum + // of the message block lengths. + // = Activation control methods. virtual int deactivate (void) = 0; @@ -191,10 +204,23 @@ public: // = Queue statistic methods. virtual size_t message_bytes (void); - // Number of total bytes on the queue. + // Number of total bytes on the queue, i.e., sum of the message + // block sizes. + virtual size_t message_length (void); + // Number of total length on the queue, i.e., sum of the message + // block lengths. virtual size_t message_count (void); // Number of total messages on the queue. + // = Manual changes to these stats (used when queued message blocks + // change size or lengths). + virtual void message_bytes (size_t new_size); + // New value of the number of total bytes on the queue, i.e., sum of + // the message block sizes. + virtual void message_length (size_t new_length); + // New value of the number of total length on the queue, i.e., sum + // of the message block lengths. + // = Flow control routines virtual size_t high_water_mark (void); // Get high watermark. @@ -343,10 +369,23 @@ public: // = Queue statistic methods (transient.) virtual size_t message_bytes (void); - // Number of total bytes on the queue. + // Number of total bytes on the queue, i.e., sum of the message + // block sizes. + virtual size_t message_length (void); + // Number of total length on the queue, i.e., sum of the message + // block lengths. virtual size_t message_count (void); // Number of total messages on the queue. + // = Manual changes to these stats (used when queued message blocks + // change size or lengths). + virtual void message_bytes (size_t new_size); + // New value of the number of total bytes on the queue, i.e., sum of + // the message block sizes. + virtual void message_length (size_t new_length); + // New value of the number of total length on the queue, i.e., sum + // of the message block lengths. + virtual size_t max_threads (void); // Get the max concurrent thread number. @@ -394,6 +433,9 @@ private: size_t cur_bytes_; // Current number of bytes in queue. + size_t cur_length_; + // Current length of messages in queue. + size_t cur_count_; // Current number of messages in the queue. diff --git a/ace/Message_Queue.i b/ace/Message_Queue.i index 2cdac504bbd..3aa86dbd3fd 100644 --- a/ace/Message_Queue.i +++ b/ace/Message_Queue.i @@ -39,8 +39,6 @@ ACE_INLINE size_t ACE_Message_Queue_Vx::high_water_mark (void) { ACE_TRACE ("ACE_Message_Queue_Vx::high_water_mark"); - // Don't need to guard, because this is fixed. - ACE_NOTSUP_RETURN ((size_t) -1); } @@ -48,8 +46,7 @@ ACE_INLINE void ACE_Message_Queue_Vx::high_water_mark (size_t) { ACE_TRACE ("ACE_Message_Queue_Vx::high_water_mark"); - // Don't need to guard, because this is fixed. - errno = ENOTSUP; + ACE_NOTSUP; } ACE_INLINE size_t @@ -65,13 +62,9 @@ ACE_INLINE void ACE_Message_Queue_Vx::low_water_mark (size_t) { ACE_TRACE ("ACE_Message_Queue_Vx::low_water_mark"); - // Don't need to guard, because this is fixed. - - errno = ENOTSUP; + ACE_NOTSUP; } -// Return the current number of bytes in the queue. - ACE_INLINE size_t ACE_Message_Queue_Vx::message_bytes (void) { @@ -79,7 +72,12 @@ ACE_Message_Queue_Vx::message_bytes (void) ACE_NOTSUP_RETURN ((size_t) -1); } -// Return the current number of messages in the queue. +ACE_INLINE size_t +ACE_Message_Queue_Vx::message_length (void) +{ + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_length"); + ACE_NOTSUP_RETURN ((size_t) -1); +} ACE_INLINE size_t ACE_Message_Queue_Vx::message_count (void) @@ -90,6 +88,20 @@ ACE_Message_Queue_Vx::message_count (void) return ::msgQNumMsgs (msgq ()); } +ACE_INLINE void +ACE_Message_Queue_Vx::message_bytes (size_t) +{ + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes"); + ACE_NOTSUP; +} + +ACE_INLINE void +ACE_Message_Queue_Vx::message_length (size_t) +{ + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_length"); + ACE_NOTSUP; +} + #endif /* VXWORKS */ #if defined (ACE_WIN32) && (ACE_HAS_WINNT4 != 0) @@ -134,6 +146,14 @@ ACE_Message_Queue_NT::message_bytes (void) } ACE_INLINE size_t +ACE_Message_Queue_NT::message_length (void) +{ + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_length"); + // Accessing to size_t must be atomic. + return this->cur_length_; +} + +ACE_INLINE size_t ACE_Message_Queue_NT::message_count (void) { ACE_TRACE ("ACE_Message_Queue_NT::message_count"); @@ -141,6 +161,24 @@ ACE_Message_Queue_NT::message_count (void) return this->cur_count_; } +ACE_INLINE void +ACE_Message_Queue_NT::message_bytes (size_t new_value) +{ + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes"); + ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->lock_); + + this->cur_bytes_ = new_value; +} + +ACE_INLINE void +ACE_Message_Queue_NT::message_length (size_t new_value) +{ + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_length"); + ACE_GUARD (ACE_Thread_Mutex, ace_mon, this->lock_); + + this->cur_length_ = new_value; +} + ACE_INLINE size_t ACE_Message_Queue_NT::max_threads (void) { diff --git a/ace/Message_Queue_T.cpp b/ace/Message_Queue_T.cpp index 46b14d8978e..9e83548881b 100644 --- a/ace/Message_Queue_T.cpp +++ b/ace/Message_Queue_T.cpp @@ -124,6 +124,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dump (void) const ASYS_TEXT ("low_water_mark = %d\n") ASYS_TEXT ("high_water_mark = %d\n") ASYS_TEXT ("cur_bytes = %d\n") + ASYS_TEXT ("cur_length = %d\n") ASYS_TEXT ("cur_count = %d\n") ASYS_TEXT ("head_ = %u\n") ASYS_TEXT ("tail_ = %u\n"), @@ -131,6 +132,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dump (void) const this->low_water_mark_, this->high_water_mark_, this->cur_bytes_, + this->cur_length_, this->cur_count_, this->head_, this->tail_)); @@ -183,6 +185,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::open (size_t hwm, this->low_water_mark_ = lwm; this->deactivated_ = 0; this->cur_bytes_ = 0; + this->cur_length_ = 0; this->cur_count_ = 0; this->tail_ = 0; this->head_ = 0; @@ -237,6 +240,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::close (void) this->cur_count_--; this->cur_bytes_ -= this->head_->total_size (); + this->cur_length_ -= this->head_->total_length (); ACE_Message_Block *temp = this->head_; this->head_ = this->head_->next (); @@ -312,6 +316,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_tail_i (ACE_Message_Block *new_item) // Make sure to count all the bytes in a composite message!!! this->cur_bytes_ += new_item->total_size (); + this->cur_length_ += new_item->total_length (); this->cur_count_++; @@ -343,6 +348,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_head_i (ACE_Message_Block *new_item) // Make sure to count all the bytes in a composite message!!! this->cur_bytes_ += new_item->total_size (); + this->cur_length_ += new_item->total_length (); this->cur_count_++; @@ -408,6 +414,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::enqueue_i (ACE_Message_Block *new_item) // Make sure to count all the bytes in a composite message!!! this->cur_bytes_ += new_item->total_size (); + this->cur_length_ += new_item->total_length (); this->cur_count_++; @@ -441,6 +448,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i (ACE_Message_Block *&first_item // Subtract off all of the bytes associated with this message. this->cur_bytes_ -= first_item->total_size (); + this->cur_length_ -= first_item->total_length (); this->cur_count_--; @@ -854,6 +862,7 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::remove_messages (ACE_Message_Block *&l this->cur_count_--; this->cur_bytes_ -= temp1->total_size (); + this->cur_length_ -= temp->total_length (); } return result; @@ -1058,6 +1067,7 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::enqueue_i (ACE_Message_Block *new_item return result; this->cur_bytes_ += new_item->total_size (); + this->cur_length_ += new_item->total_length (); this->cur_count_++; @@ -1244,6 +1254,7 @@ ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i (ACE_Message_Block *&fi // Make sure to subtract off all of the bytes associated with this // message. this->cur_bytes_ -= first_item->total_size (); + this->cur_length_ -= first_item->total_length (); this->cur_count_--; diff --git a/ace/Message_Queue_T.h b/ace/Message_Queue_T.h index bbf0a4cd182..6543244d54a 100644 --- a/ace/Message_Queue_T.h +++ b/ace/Message_Queue_T.h @@ -175,10 +175,23 @@ public: // = Queue statistic methods. virtual size_t message_bytes (void); - // Number of total bytes on the queue. + // Number of total bytes on the queue, i.e., sum of the message + // block sizes. + virtual size_t message_length (void); + // Number of total length on the queue, i.e., sum of the message + // block lengths. virtual size_t message_count (void); // Number of total messages on the queue. + // = Manual changes to these stats (used when queued message blocks + // change size or lengths). + virtual void message_bytes (size_t new_size); + // New value of the number of total bytes on the queue, i.e., sum of + // the message block sizes. + virtual void message_length (size_t new_length); + // New value of the number of total length on the queue, i.e., sum + // of the message block lengths. + // = Flow control methods. virtual size_t high_water_mark (void); @@ -307,6 +320,9 @@ protected: size_t cur_bytes_; // Current number of bytes in the queue. + size_t cur_length_; + // Current length of messages in the queue. + size_t cur_count_; // Current number of messages in the queue. diff --git a/ace/Message_Queue_T.i b/ace/Message_Queue_T.i index b5ddf46a60f..280b5ce9dcc 100644 --- a/ace/Message_Queue_T.i +++ b/ace/Message_Queue_T.i @@ -101,8 +101,6 @@ ACE_Message_Queue<ACE_SYNCH_USE>::low_water_mark (size_t lwm) this->low_water_mark_ = lwm; } -// Return the current number of bytes in the queue. - template <ACE_SYNCH_DECL> ACE_INLINE size_t ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes (void) { @@ -112,7 +110,14 @@ ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes (void) return this->cur_bytes_; } -// Return the current number of messages in the queue. +template <ACE_SYNCH_DECL> ACE_INLINE size_t +ACE_Message_Queue<ACE_SYNCH_USE>::message_length (void) +{ + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_length"); + ACE_GUARD_RETURN (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_, 0); + + return this->cur_length_; +} template <ACE_SYNCH_DECL> ACE_INLINE size_t ACE_Message_Queue<ACE_SYNCH_USE>::message_count (void) @@ -123,6 +128,24 @@ ACE_Message_Queue<ACE_SYNCH_USE>::message_count (void) return this->cur_count_; } +template <ACE_SYNCH_DECL> ACE_INLINE void +ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes (size_t new_value) +{ + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_bytes"); + ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_); + + this->cur_bytes_ = new_value; +} + +template <ACE_SYNCH_DECL> ACE_INLINE void +ACE_Message_Queue<ACE_SYNCH_USE>::message_length (size_t new_value) +{ + ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::message_length"); + ACE_GUARD (ACE_SYNCH_MUTEX_T, ace_mon, this->lock_); + + this->cur_length_ = new_value; +} + template <ACE_SYNCH_DECL> ACE_INLINE int ACE_Message_Queue<ACE_SYNCH_USE>::activate (void) { @@ -150,7 +173,7 @@ ACE_Message_Queue<ACE_SYNCH_USE>::deactivated (void) } template <ACE_SYNCH_DECL> ACE_INLINE ACE_SYNCH_MUTEX_T & -ACE_Message_Queue<ACE_SYNCH_USE>::lock (void) +ACE_Message_Queue<ACE_SYNCH_USE>::lock (void) { return this->lock_; } @@ -7983,8 +7983,10 @@ private: // Print a console message with the file and line number of the // unsupported function. # define ACE_NOTSUP_RETURN(FAILVALUE) do { errno = ENOTSUP; ACE_OS::fprintf (stderr, ACE_TEXT ("ACE_NOTSUP: %s, line %d\n"), __FILE__, __LINE__); return FAILVALUE; } while (0) +# define ACE_NOTSUP do { errno = ENOTSUP; ACE_OS::fprintf (stderr, ACE_TEXT ("ACE_NOTSUP: %s, line %d\n"), __FILE__, __LINE__); return; } while (0) # else /* ! ACE_HAS_VERBOSE_NOTSUP */ # define ACE_NOTSUP_RETURN(FAILVALUE) do { errno = ENOTSUP ; return FAILVALUE; } while (0) +# define ACE_NOTSUP do { errno = ENOTSUP; return; } while (0) # endif /* ! ACE_HAS_VERBOSE_NOTSUP */ # if defined (ACE_HAS_GNUC_BROKEN_TEMPLATE_INLINE_FUNCTIONS) |