summaryrefslogtreecommitdiff
path: root/ACE/ace/Metrics_Cache_T.inl
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:30 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2006-07-24 15:50:30 +0000
commitc44379cc7d9c7aa113989237ab0f56db12aa5219 (patch)
tree66a84b20d47f2269d8bdc6e0323f338763424d3a /ACE/ace/Metrics_Cache_T.inl
parent3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (diff)
downloadATCD-c44379cc7d9c7aa113989237ab0f56db12aa5219.tar.gz
Repo restructuring
Diffstat (limited to 'ACE/ace/Metrics_Cache_T.inl')
-rw-r--r--ACE/ace/Metrics_Cache_T.inl240
1 files changed, 240 insertions, 0 deletions
diff --git a/ACE/ace/Metrics_Cache_T.inl b/ACE/ace/Metrics_Cache_T.inl
new file mode 100644
index 00000000000..e0f542ab366
--- /dev/null
+++ b/ACE/ace/Metrics_Cache_T.inl
@@ -0,0 +1,240 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#ifndef ACE_METRICS_CACHE_T_INL
+#define ACE_METRICS_CACHE_T_INL
+
+ACE_BEGIN_VERSIONED_NAMESPACE_DECL
+
+/////////////////////////////
+// Class ACE_Metrics_Cache //
+/////////////////////////////
+
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_start (u_long i)
+{
+ if (i < this->probe_set_size_)
+ {
+ u_long & count =
+ this->enqueue_count_ [this->supplier_index_] [i];
+ ++count;
+
+ if (! this->interval_initialized_)
+ {
+ this->interval_initialized_ = 1;
+ ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
+ ACE_High_Res_Timer::hrtime_to_tv (this->interval_start_,
+ hrtime_now);
+ this->interval_end_.set (this->interval_start_.sec(),
+ this->interval_start_.usec());
+ }
+
+ // Take the metrics timeprobe last, to avoid measuring the above
+ // metrics processing.
+ ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
+ this->enqueue_probes_ [this->supplier_index_][i];
+ probe->
+ timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_START);
+ }
+}
+
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_stop (u_long i)
+{
+ if (i < this->probe_set_size_)
+ {
+ // Take the metrics timeprobe first, to avoid measuring the below
+ // metrics processing.
+ ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
+ this->enqueue_probes_ [this->supplier_index_][i];
+ probe->
+ timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_STOP);
+
+ ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
+ ACE_High_Res_Timer::hrtime_to_tv (this->interval_end_,
+ hrtime_now);
+
+ u_long & count = enqueue_count_ [this->supplier_index_][i];
+ ++count;
+ }
+
+}
+
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_suspend (u_long i)
+{
+ if (i < this->probe_set_size_)
+ {
+ ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
+ this->enqueue_probes_ [this->supplier_index_][i];
+ probe->
+ timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_SUSPEND);
+ u_long & count =
+ this->enqueue_count_ [this->supplier_index_] [i];
+ ++count;
+ }
+}
+
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_resume (u_long i)
+{
+ if (i < this->probe_set_size_)
+ {
+ u_long & count =
+ this->enqueue_count_ [this->supplier_index_] [i];
+ ++count;
+ ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
+ this->enqueue_probes_ [this->supplier_index_][i];
+ probe->
+ timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_RESUME);
+ }
+}
+
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_start (u_long i)
+{
+ if (i < this->probe_set_size_)
+ {
+ u_long & count =
+ this->dequeue_count_ [this->supplier_index_] [i];
+ ++count;
+
+ if (! this->interval_initialized_)
+ {
+ this->interval_initialized_ = 1;
+ ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
+ ACE_High_Res_Timer::hrtime_to_tv (this->interval_start_,
+ hrtime_now);
+ this->interval_end_.set (this->interval_start_.sec(),
+ this->interval_start_.usec());
+ }
+
+ // Take the metrics timeprobe last, to avoid measuring the above
+ // metrics processing.
+ ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
+ this->dequeue_probes_ [this->supplier_index_][i];
+ probe->
+ timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_START);
+ }
+}
+
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_stop (u_long i)
+{
+ if (i < this->probe_set_size_)
+ {
+ // Take the metrics timeprobe first, to avoid measuring the
+ // metrics processing below.
+ ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
+ this->dequeue_probes_ [this->supplier_index_][i];
+
+ probe->timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_STOP);
+
+ ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
+ ACE_High_Res_Timer::hrtime_to_tv (this->interval_end_,
+ hrtime_now);
+
+ u_long & count = dequeue_count_ [this->supplier_index_] [i];
+ ++count;
+ }
+}
+
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_suspend (u_long i)
+{
+ if (i < this->probe_set_size_)
+ {
+ u_long & count =
+ this->dequeue_count_ [this->supplier_index_] [i];
+ ++count;
+ ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
+ this->dequeue_probes_ [this->supplier_index_][i];
+ probe->
+ timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_SUSPEND);
+ }
+}
+
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_resume (u_long i)
+{
+ if (i < this->probe_set_size_)
+ {
+ u_long & count =
+ this->dequeue_count_ [this->supplier_index_] [i];
+ ++count;
+ ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
+ this->dequeue_probes_ [this->supplier_index_][i];
+ probe->
+ timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_RESUME);
+ }
+}
+
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::reset_base_statistics ()
+{
+ this->interval_initialized_ = 0;
+ this->interval_start_.set (0, 0);
+ this->interval_end_.set (0, 0);
+
+ for (u_int i = 0; i < this->probe_set_size_; ++i)
+ {
+ this->enqueue_count_ [this->consumer_index_] [i] = 0;
+ this->dequeue_count_ [this->consumer_index_] [i] = 0;
+
+ ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
+ this->enqueue_probes_ [this->consumer_index_][i];
+ probe->reset ();
+ probe =
+ this->dequeue_probes_ [this->consumer_index_][i];
+ probe->reset ();
+ }
+}
+
+
+// Flips the supplier and consumer positions.
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::flip_supplier_and_consumer ()
+{
+ int temp = consumer_index_;
+ consumer_index_ = supplier_index_;
+ supplier_index_ = temp;
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE void
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::metrics_enabled(int enabled)
+{
+ metrics_enabled_ = enabled;
+}
+
+template <class ACE_LOCK, class ALLOCATOR>
+ACE_INLINE int
+ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::metrics_enabled(void) const
+{
+ return metrics_enabled_;
+}
+
+ACE_END_VERSIONED_NAMESPACE_DECL
+
+#endif /* ACE_METRICS_CACHE_T_INL */