Initial Patch of Auction House bot rev. 135
[auctionmangos.git] / dep / ACE_wrappers / ace / Metrics_Cache_T.inl
blobe3cc3b8cc667160a6d062789be490d33a937c9d8
1 // -*- C++ -*-
2 //
3 // $Id: Metrics_Cache_T.inl 80826 2008-03-04 14:51:23Z wotte $
5 #ifndef ACE_METRICS_CACHE_T_INL
6 #define ACE_METRICS_CACHE_T_INL
8 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
10 /////////////////////////////
11 // Class ACE_Metrics_Cache //
12 /////////////////////////////
15 template <class ACE_LOCK, class ALLOCATOR>
16 ACE_INLINE void
17 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_start (u_long i)
19   if (i < this->probe_set_size_)
20     {
21       u_long & count =
22         this->enqueue_count_ [this->supplier_index_] [i];
23       ++count;
25       if (! this->interval_initialized_)
26         {
27           this->interval_initialized_ = 1;
28           ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
29           ACE_High_Res_Timer::hrtime_to_tv (this->interval_start_,
30                                                     hrtime_now);
31           this->interval_end_.set (this->interval_start_.sec(),
32                                    this->interval_start_.usec());
33         }
35       // Take the metrics timeprobe last, to avoid measuring the above
36       // metrics processing.
37       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
38         this->enqueue_probes_ [this->supplier_index_][i];
39       probe->
40         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_START);
41     }
45 template <class ACE_LOCK, class ALLOCATOR>
46 ACE_INLINE void
47 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_stop (u_long i)
49   if (i < this->probe_set_size_)
50     {
51       // Take the metrics timeprobe first, to avoid measuring the below
52       // metrics processing.
53       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
54         this->enqueue_probes_ [this->supplier_index_][i];
55       probe->
56         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_STOP);
58       ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
59       ACE_High_Res_Timer::hrtime_to_tv (this->interval_end_,
60                                             hrtime_now);
62       u_long & count = enqueue_count_ [this->supplier_index_][i];
63       ++count;
64     }
69 template <class ACE_LOCK, class ALLOCATOR>
70 ACE_INLINE void
71 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_suspend (u_long i)
73   if (i < this->probe_set_size_)
74     {
75       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
76         this->enqueue_probes_ [this->supplier_index_][i];
77       probe->
78         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_SUSPEND);
79       u_long & count =
80         this->enqueue_count_ [this->supplier_index_] [i];
81       ++count;
82     }
86 template <class ACE_LOCK, class ALLOCATOR>
87 ACE_INLINE void
88 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_resume (u_long i)
90   if (i < this->probe_set_size_)
91     {
92       u_long & count =
93         this->enqueue_count_ [this->supplier_index_] [i];
94       ++count;
95       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
96         this->enqueue_probes_ [this->supplier_index_][i];
97       probe->
98         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_RESUME);
99     }
103 template <class ACE_LOCK, class ALLOCATOR>
104 ACE_INLINE void
105 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_start (u_long i)
107   if (i < this->probe_set_size_)
108     {
109       u_long & count =
110         this->dequeue_count_ [this->supplier_index_] [i];
111       ++count;
113       if (! this->interval_initialized_)
114         {
115           this->interval_initialized_ = 1;
116           ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
117           ACE_High_Res_Timer::hrtime_to_tv (this->interval_start_,
118                                                     hrtime_now);
119           this->interval_end_.set (this->interval_start_.sec(),
120                                    this->interval_start_.usec());
121         }
123       // Take the metrics timeprobe last, to avoid measuring the above
124       // metrics processing.
125       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
126         this->dequeue_probes_ [this->supplier_index_][i];
127       probe->
128         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_START);
129     }
133 template <class ACE_LOCK, class ALLOCATOR>
134 ACE_INLINE void
135 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_stop (u_long i)
137   if (i < this->probe_set_size_)
138     {
139       // Take the metrics timeprobe first, to avoid measuring the
140       // metrics processing below.
141       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
142         this->dequeue_probes_ [this->supplier_index_][i];
144       probe->timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_STOP);
146       ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
147       ACE_High_Res_Timer::hrtime_to_tv (this->interval_end_,
148                                                     hrtime_now);
150       u_long & count = dequeue_count_ [this->supplier_index_] [i];
151       ++count;
152     }
156 template <class ACE_LOCK, class ALLOCATOR>
157 ACE_INLINE void
158 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_suspend (u_long i)
160   if (i < this->probe_set_size_)
161     {
162       u_long & count =
163         this->dequeue_count_ [this->supplier_index_] [i];
164       ++count;
165       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
166         this->dequeue_probes_ [this->supplier_index_][i];
167       probe->
168         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_SUSPEND);
169     }
173 template <class ACE_LOCK, class ALLOCATOR>
174 ACE_INLINE void
175 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_resume (u_long i)
177   if (i < this->probe_set_size_)
178     {
179       u_long & count =
180         this->dequeue_count_ [this->supplier_index_] [i];
181       ++count;
182       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
183         this->dequeue_probes_ [this->supplier_index_][i];
184       probe->
185         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_RESUME);
186     }
190 template <class ACE_LOCK, class ALLOCATOR>
191 ACE_INLINE void
192 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::reset_base_statistics ()
194   this->interval_initialized_ = 0;
195   this->interval_start_.set (0, 0);
196   this->interval_end_.set (0, 0);
198   for (u_int i = 0; i < this->probe_set_size_; ++i)
199     {
200       this->enqueue_count_ [this->consumer_index_] [i] = 0;
201       this->dequeue_count_ [this->consumer_index_] [i] = 0;
203       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
204         this->enqueue_probes_ [this->consumer_index_][i];
205       probe->reset ();
206       probe =
207         this->dequeue_probes_ [this->consumer_index_][i];
208       probe->reset ();
209     }
213 // Flips the supplier and consumer positions.
215 template <class ACE_LOCK, class ALLOCATOR>
216 ACE_INLINE void
217 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::flip_supplier_and_consumer ()
219   int temp = consumer_index_;
220   consumer_index_ = supplier_index_;
221   supplier_index_ = temp;
224 template <class ACE_LOCK, class ALLOCATOR>
225 ACE_INLINE void
226 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::metrics_enabled(int enabled)
228    metrics_enabled_ = enabled;
231 template <class ACE_LOCK, class ALLOCATOR>
232 ACE_INLINE int
233 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::metrics_enabled(void) const
235    return metrics_enabled_;
238 ACE_END_VERSIONED_NAMESPACE_DECL
240 #endif /* ACE_METRICS_CACHE_T_INL */