2 #ifndef ACE_METRICS_CACHE_T_INL
3 #define ACE_METRICS_CACHE_T_INL
5 #if defined (ACE_COMPILE_TIMEPROBES)
7 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
9 /////////////////////////////
10 // Class ACE_Metrics_Cache //
11 /////////////////////////////
14 template <class ACE_LOCK, class ALLOCATOR>
16 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_start (u_long i)
18 if (i < this->probe_set_size_)
21 this->enqueue_count_ [this->supplier_index_] [i];
24 if (! this->interval_initialized_)
26 this->interval_initialized_ = 1;
27 ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
28 ACE_High_Res_Timer::hrtime_to_tv (this->interval_start_,
30 this->interval_end_.set (this->interval_start_.sec(),
31 this->interval_start_.usec());
34 // Take the metrics timeprobe last, to avoid measuring the above
35 // metrics processing.
36 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
37 this->enqueue_probes_ [this->supplier_index_][i];
39 timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_START);
44 template <class ACE_LOCK, class ALLOCATOR>
46 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_stop (u_long i)
48 if (i < this->probe_set_size_)
50 // Take the metrics timeprobe first, to avoid measuring the below
51 // metrics processing.
52 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
53 this->enqueue_probes_ [this->supplier_index_][i];
55 timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_STOP);
57 ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
58 ACE_High_Res_Timer::hrtime_to_tv (this->interval_end_,
61 u_long & count = enqueue_count_ [this->supplier_index_][i];
68 template <class ACE_LOCK, class ALLOCATOR>
70 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_suspend (u_long i)
72 if (i < this->probe_set_size_)
74 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
75 this->enqueue_probes_ [this->supplier_index_][i];
77 timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_SUSPEND);
79 this->enqueue_count_ [this->supplier_index_] [i];
85 template <class ACE_LOCK, class ALLOCATOR>
87 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_resume (u_long i)
89 if (i < this->probe_set_size_)
92 this->enqueue_count_ [this->supplier_index_] [i];
94 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
95 this->enqueue_probes_ [this->supplier_index_][i];
97 timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_RESUME);
102 template <class ACE_LOCK, class ALLOCATOR>
104 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_start (u_long i)
106 if (i < this->probe_set_size_)
109 this->dequeue_count_ [this->supplier_index_] [i];
112 if (! this->interval_initialized_)
114 this->interval_initialized_ = 1;
115 ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
116 ACE_High_Res_Timer::hrtime_to_tv (this->interval_start_,
118 this->interval_end_.set (this->interval_start_.sec(),
119 this->interval_start_.usec());
122 // Take the metrics timeprobe last, to avoid measuring the above
123 // metrics processing.
124 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
125 this->dequeue_probes_ [this->supplier_index_][i];
127 timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_START);
132 template <class ACE_LOCK, class ALLOCATOR>
134 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_stop (u_long i)
136 if (i < this->probe_set_size_)
138 // Take the metrics timeprobe first, to avoid measuring the
139 // metrics processing below.
140 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
141 this->dequeue_probes_ [this->supplier_index_][i];
143 probe->timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_STOP);
145 ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
146 ACE_High_Res_Timer::hrtime_to_tv (this->interval_end_,
149 u_long & count = dequeue_count_ [this->supplier_index_] [i];
155 template <class ACE_LOCK, class ALLOCATOR>
157 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_suspend (u_long i)
159 if (i < this->probe_set_size_)
162 this->dequeue_count_ [this->supplier_index_] [i];
164 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
165 this->dequeue_probes_ [this->supplier_index_][i];
167 timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_SUSPEND);
172 template <class ACE_LOCK, class ALLOCATOR>
174 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_resume (u_long i)
176 if (i < this->probe_set_size_)
179 this->dequeue_count_ [this->supplier_index_] [i];
181 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
182 this->dequeue_probes_ [this->supplier_index_][i];
184 timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_RESUME);
189 template <class ACE_LOCK, class ALLOCATOR>
191 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::reset_base_statistics ()
193 this->interval_initialized_ = 0;
194 this->interval_start_.set (0, 0);
195 this->interval_end_.set (0, 0);
197 for (u_int i = 0; i < this->probe_set_size_; ++i)
199 this->enqueue_count_ [this->consumer_index_] [i] = 0;
200 this->dequeue_count_ [this->consumer_index_] [i] = 0;
202 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
203 this->enqueue_probes_ [this->consumer_index_][i];
206 this->dequeue_probes_ [this->consumer_index_][i];
212 // Flips the supplier and consumer positions.
214 template <class ACE_LOCK, class ALLOCATOR>
216 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::flip_supplier_and_consumer ()
218 int temp = consumer_index_;
219 consumer_index_ = supplier_index_;
220 supplier_index_ = temp;
223 template <class ACE_LOCK, class ALLOCATOR>
225 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::metrics_enabled(int enabled)
227 metrics_enabled_ = enabled;
230 template <class ACE_LOCK, class ALLOCATOR>
232 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::metrics_enabled() const
234 return metrics_enabled_;
237 ACE_END_VERSIONED_NAMESPACE_DECL
241 #endif /* ACE_METRICS_CACHE_T_INL */