summaryrefslogtreecommitdiff
path: root/ACE/ace/Message_Queue_T.cpp
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2008-05-09 12:05:34 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2008-05-09 12:05:34 +0000
commit6895fd20790056373d17003a96395932eb7f1249 (patch)
treea5bc4d4b3354f059d997f0718fa3f7774333409f /ACE/ace/Message_Queue_T.cpp
parent0c009665908d617d2dcde99c1edcbe98a47af4b9 (diff)
downloadATCD-6895fd20790056373d17003a96395932eb7f1249.tar.gz
Fri May 9 12:04:15 UTC 2008 J.T. Conklin <jtc@acorntoolworks.com>
Diffstat (limited to 'ACE/ace/Message_Queue_T.cpp')
-rw-r--r--ACE/ace/Message_Queue_T.cpp46
1 files changed, 43 insertions, 3 deletions
diff --git a/ACE/ace/Message_Queue_T.cpp b/ACE/ace/Message_Queue_T.cpp
index 82f29e8656b..cf9469bc3e8 100644
--- a/ACE/ace/Message_Queue_T.cpp
+++ b/ACE/ace/Message_Queue_T.cpp
@@ -16,6 +16,11 @@
#include "ace/Notification_Strategy.h"
#include "ace/Truncate.h"
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+#include "ace/OS_NS_stdio.h"
+#include "ace/Monitor_Size.h"
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
+
ACE_BEGIN_VERSIONED_NAMESPACE_DECL
ACE_ALLOC_HOOK_DEFINE(ACE_Message_Queue)
@@ -924,14 +929,29 @@ template <ACE_SYNCH_DECL>
ACE_Message_Queue<ACE_SYNCH_USE>::ACE_Message_Queue (size_t hwm,
size_t lwm,
ACE_Notification_Strategy *ns)
- : not_empty_cond_ (lock_),
- not_full_cond_ (lock_)
+ : not_empty_cond_ (lock_)
+ , not_full_cond_ (lock_)
{
ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::ACE_Message_Queue");
if (this->open (hwm, lwm, ns) == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("open")));
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ ACE_NEW (this->monitor_,
+ ACE::MonitorControl::Size_Monitor);
+
+ /// Make a unique name using our hex address.
+ const int nibbles = 2 * sizeof (ptrdiff_t);
+ char buf[nibbles + 1];
+ ACE_OS::sprintf (buf, "%p", this);
+ buf[nibbles] = '\0';
+ ACE_CString name_str ("Message_Queue_");
+ name_str += buf;
+ this->monitor_->name (name_str.c_str ());
+ this->monitor_->add_to_registry ();
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
}
template <ACE_SYNCH_DECL>
@@ -941,6 +961,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::~ACE_Message_Queue (void)
if (this->head_ != 0 && this->close () == -1)
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("close")));
+
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->remove_from_registry ();
+ this->monitor_->remove_ref ();
+#endif /* ACE_HAS_MONITOR_POINTS==1 */
}
template <ACE_SYNCH_DECL> int
@@ -971,6 +996,14 @@ ACE_Message_Queue<ACE_SYNCH_USE>::flush_i (void)
temp->release ();
}
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ // The monitor should output only if the size has actually changed.
+ if (number_flushed > 0)
+ {
+ this->monitor_->receive (this->cur_length_);
+ }
+#endif
+
return number_flushed;
}
@@ -1345,6 +1378,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::dequeue_head_i (ACE_Message_Block *&first_item
first_item->prev (0);
first_item->next (0);
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->cur_length_);
+#endif
+
// Only signal enqueueing threads if we've fallen below the low
// water mark.
if (this->cur_bytes_ <= this->low_water_mark_
@@ -1860,6 +1897,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::notify (void)
{
ACE_TRACE ("ACE_Message_Queue<ACE_SYNCH_USE>::notify");
+#if defined (ACE_HAS_MONITOR_POINTS) && (ACE_HAS_MONITOR_POINTS == 1)
+ this->monitor_->receive (this->cur_length_);
+#endif
+
// By default, don't do anything.
if (this->notification_strategy_ == 0)
return 0;
@@ -1867,7 +1908,6 @@ ACE_Message_Queue<ACE_SYNCH_USE>::notify (void)
return this->notification_strategy_->notify ();
}
-
// = Initialization and termination methods.
template <ACE_SYNCH_DECL>
ACE_Dynamic_Message_Queue<ACE_SYNCH_USE>::ACE_Dynamic_Message_Queue (ACE_Dynamic_Message_Strategy & message_strategy,