Metrics_Cache_T.inl

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Metrics_Cache_T.inl,v 4.2 2005/10/28 16:14:53 ossama Exp
00004 
00005 #ifndef ACE_METRICS_CACHE_T_INL
00006 #define ACE_METRICS_CACHE_T_INL
00007 
00008 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00009 
00010 /////////////////////////////
00011 // Class ACE_Metrics_Cache //
00012 /////////////////////////////
00013 
00014 
00015 template <class ACE_LOCK, class ALLOCATOR>
00016 ACE_INLINE void
00017 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_start (u_long i)
00018 {
00019   if (i < this->probe_set_size_)
00020     {
00021       u_long & count =
00022         this->enqueue_count_ [this->supplier_index_] [i];
00023       ++count;
00024 
00025       if (! this->interval_initialized_)
00026         {
00027           this->interval_initialized_ = 1;
00028           ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
00029           ACE_High_Res_Timer::hrtime_to_tv (this->interval_start_,
00030                                                     hrtime_now);
00031           this->interval_end_.set (this->interval_start_.sec(),
00032                                    this->interval_start_.usec());
00033         }
00034 
00035       // Take the metrics timeprobe last, to avoid measuring the above
00036       // metrics processing.
00037       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
00038         this->enqueue_probes_ [this->supplier_index_][i];
00039       probe->
00040         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_START);
00041     }
00042 }
00043 
00044 
00045 template <class ACE_LOCK, class ALLOCATOR>
00046 ACE_INLINE void
00047 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_stop (u_long i)
00048 {
00049   if (i < this->probe_set_size_)
00050     {
00051       // Take the metrics timeprobe first, to avoid measuring the below
00052       // metrics processing.
00053       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
00054         this->enqueue_probes_ [this->supplier_index_][i];
00055       probe->
00056         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_STOP);
00057 
00058       ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
00059       ACE_High_Res_Timer::hrtime_to_tv (this->interval_end_,
00060                                             hrtime_now);
00061 
00062       u_long & count = enqueue_count_ [this->supplier_index_][i];
00063       ++count;
00064     }
00065 
00066 }
00067 
00068 
00069 template <class ACE_LOCK, class ALLOCATOR>
00070 ACE_INLINE void
00071 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_suspend (u_long i)
00072 {
00073   if (i < this->probe_set_size_)
00074     {
00075       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
00076         this->enqueue_probes_ [this->supplier_index_][i];
00077       probe->
00078         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_SUSPEND);
00079       u_long & count =
00080         this->enqueue_count_ [this->supplier_index_] [i];
00081       ++count;
00082     }
00083 }
00084 
00085 
00086 template <class ACE_LOCK, class ALLOCATOR>
00087 ACE_INLINE void
00088 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_enqueue_resume (u_long i)
00089 {
00090   if (i < this->probe_set_size_)
00091     {
00092       u_long & count =
00093         this->enqueue_count_ [this->supplier_index_] [i];
00094       ++count;
00095       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
00096         this->enqueue_probes_ [this->supplier_index_][i];
00097       probe->
00098         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_RESUME);
00099     }
00100 }
00101 
00102 
00103 template <class ACE_LOCK, class ALLOCATOR>
00104 ACE_INLINE void
00105 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_start (u_long i)
00106 {
00107   if (i < this->probe_set_size_)
00108     {
00109       u_long & count =
00110         this->dequeue_count_ [this->supplier_index_] [i];
00111       ++count;
00112 
00113       if (! this->interval_initialized_)
00114         {
00115           this->interval_initialized_ = 1;
00116           ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
00117           ACE_High_Res_Timer::hrtime_to_tv (this->interval_start_,
00118                                                     hrtime_now);
00119           this->interval_end_.set (this->interval_start_.sec(),
00120                                    this->interval_start_.usec());
00121         }
00122 
00123       // Take the metrics timeprobe last, to avoid measuring the above
00124       // metrics processing.
00125       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
00126         this->dequeue_probes_ [this->supplier_index_][i];
00127       probe->
00128         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_START);
00129     }
00130 }
00131 
00132 
00133 template <class ACE_LOCK, class ALLOCATOR>
00134 ACE_INLINE void
00135 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_stop (u_long i)
00136 {
00137   if (i < this->probe_set_size_)
00138     {
00139       // Take the metrics timeprobe first, to avoid measuring the
00140       // metrics processing below.
00141       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
00142         this->dequeue_probes_ [this->supplier_index_][i];
00143 
00144       probe->timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_STOP);
00145 
00146       ACE_hrtime_t hrtime_now = ACE_OS::gethrtime ();
00147       ACE_High_Res_Timer::hrtime_to_tv (this->interval_end_,
00148                                                     hrtime_now);
00149 
00150       u_long & count = dequeue_count_ [this->supplier_index_] [i];
00151       ++count;
00152     }
00153 }
00154 
00155 
00156 template <class ACE_LOCK, class ALLOCATOR>
00157 ACE_INLINE void
00158 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_suspend (u_long i)
00159 {
00160   if (i < this->probe_set_size_)
00161     {
00162       u_long & count =
00163         this->dequeue_count_ [this->supplier_index_] [i];
00164       ++count;
00165       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
00166         this->dequeue_probes_ [this->supplier_index_][i];
00167       probe->
00168         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_SUSPEND);
00169     }
00170 }
00171 
00172 
00173 template <class ACE_LOCK, class ALLOCATOR>
00174 ACE_INLINE void
00175 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::report_dequeue_resume (u_long i)
00176 {
00177   if (i < this->probe_set_size_)
00178     {
00179       u_long & count =
00180         this->dequeue_count_ [this->supplier_index_] [i];
00181       ++count;
00182       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
00183         this->dequeue_probes_ [this->supplier_index_][i];
00184       probe->
00185         timeprobe (ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::WORK_RESUME);
00186     }
00187 }
00188 
00189 
00190 template <class ACE_LOCK, class ALLOCATOR>
00191 ACE_INLINE void
00192 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::reset_base_statistics ()
00193 {
00194   this->interval_initialized_ = 0;
00195   this->interval_start_.set (0, 0);
00196   this->interval_end_.set (0, 0);
00197 
00198   for (u_int i = 0; i < this->probe_set_size_; ++i)
00199     {
00200       this->enqueue_count_ [this->consumer_index_] [i] = 0;
00201       this->dequeue_count_ [this->consumer_index_] [i] = 0;
00202 
00203       ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> * probe =
00204         this->enqueue_probes_ [this->consumer_index_][i];
00205       probe->reset ();
00206       probe =
00207         this->dequeue_probes_ [this->consumer_index_][i];
00208       probe->reset ();
00209     }
00210 }
00211 
00212 
00213 // Flips the supplier and consumer positions.
00214 
00215 template <class ACE_LOCK, class ALLOCATOR>
00216 ACE_INLINE void
00217 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::flip_supplier_and_consumer ()
00218 {
00219   int temp = consumer_index_;
00220   consumer_index_ = supplier_index_;
00221   supplier_index_ = temp;
00222 }
00223 
00224 template <class ACE_LOCK, class ALLOCATOR>
00225 ACE_INLINE void
00226 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::metrics_enabled(int enabled)
00227 {
00228    metrics_enabled_ = enabled;
00229 }
00230 
00231 template <class ACE_LOCK, class ALLOCATOR>
00232 ACE_INLINE int
00233 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::metrics_enabled(void) const
00234 {
00235    return metrics_enabled_;
00236 }
00237 
00238 ACE_END_VERSIONED_NAMESPACE_DECL
00239 
00240 #endif /* ACE_METRICS_CACHE_T_INL */

Generated on Thu Nov 9 09:41:56 2006 for ACE by doxygen 1.3.6