00001
00002
00003 #ifndef ACE_METRICS_CACHE_CPP
00004 #define ACE_METRICS_CACHE_CPP
00005
00006
00007
00008 #include "ace/Metrics_Cache_T.h"
00009
00010 #if defined (ACE_COMPILE_TIMEPROBES)
00011
00012 #include "ace/Metrics_Cache.h"
00013
00014 #if !defined (__ACE_INLINE__)
00015 #include "ace/Metrics_Cache_T.inl"
00016 #endif
00017
00018
00019
00020 static const char * event_description_strings [] =
00021 {
00022 "start",
00023 "stop",
00024 "suspend",
00025 "resume"
00026 };
00027
00028 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00029
00030
00031
00032
00033
00034 template <class ACE_LOCK, class ALLOCATOR>
00035 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::ACE_Metrics_Timeprobe (u_int id,
00036 const char *name,
00037 u_long size)
00038 :
00039 ACE_Timeprobe<ACE_LOCK> (size),
00040 id_ (id),
00041 name_ (0)
00042 {
00043 if (name == 0)
00044 {
00045 name = "";
00046 }
00047
00048 char * name_tmp = 0;
00049 ACE_NEW_MALLOC_ARRAY (name_tmp,
00050 (char *) this->allocator ()->malloc (strlen(name)+1),
00051 char,
00052 strlen(name)+1);
00053 ACE_OS::memcpy (name_tmp, name, strlen (name)+1);
00054 name_ = name_tmp;
00055
00056 this->event_descriptions (event_description_strings,
00057 sizeof(event_description_strings)/sizeof(const char *));
00058 }
00059
00060 template <class ACE_LOCK, class ALLOCATOR>
00061 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::
00062 ACE_Metrics_Timeprobe (ALLOCATOR *alloc,
00063 u_int id,
00064 const char *name,
00065 u_long size)
00066 :
00067 ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR> (size),
00068 id_ (id),
00069 name_ (0)
00070 {
00071 if (name == 0)
00072 {
00073 name = "";
00074 }
00075
00076 char * name_tmp = 0;
00077 ACE_NEW_MALLOC_ARRAY (name_tmp,
00078 (char *) alloc->malloc(strlen(name)+1),
00079 char,
00080 strlen(name)+1);
00081 ACE_OS::memcpy (name_tmp, name, strlen (name)+1);
00082 name_ = name_tmp;
00083
00084 this->event_descriptions (event_description_strings,
00085 sizeof(event_description_strings)/sizeof(const char *));
00086 }
00087
00088 template <class ACE_LOCK, class ALLOCATOR>
00089 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::~ACE_Metrics_Timeprobe ()
00090 {
00091 if (name_)
00092 {
00093 this->allocator ()->free ((void*) name_);
00094 }
00095 }
00096
00097
00098
00099
00100 template <class ACE_LOCK, class ALLOCATOR>
00101 int
00102 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::is_event (const ACE_Metrics_Timeprobe<ACE_LOCK,
00103 ALLOCATOR>::
00104 ACE_METRICS_TIMEPROBE_DATA_TYPE &t,
00105 ACE_Metrics_Timeprobe<ACE_LOCK,
00106 ALLOCATOR>::
00107 event_id id)
00108 {
00109 return (t.event_.event_number_ == (u_long) id) ? 1 : 0;
00110 }
00111
00112 template <class ACE_LOCK, class ALLOCATOR>
00113 const char *
00114 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::probe_name (void)
00115 {
00116 return name_;
00117 }
00118
00119 template <class ACE_LOCK, class ALLOCATOR>
00120 void
00121 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::probe_name (char * name)
00122 {
00123 char * name_tmp = 0;
00124 ACE_NEW_MALLOC_ARRAY (name_tmp,
00125 (char *) this->allocator ()->malloc (strlen(name)+1),
00126 char,
00127 strlen(name)+1);
00128 ACE_OS::memcpy (name_tmp, name, strlen (name)+1);
00129
00130 if (name_)
00131 {
00132 this->allocator ()->free (name_);
00133 }
00134
00135 name_ = name_tmp;
00136 }
00137
00138 template <class ACE_LOCK, class ALLOCATOR>
00139 u_int
00140 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::probe_id (void)
00141 {
00142 return id_;
00143 }
00144
00145
00146 template <class ACE_LOCK, class ALLOCATOR>
00147 void
00148 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::probe_id (u_int id)
00149 {
00150 id_ = id;
00151 }
00152
00153
00154
00155
00156 template <class ACE_LOCK, class ALLOCATOR> void
00157 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::
00158 flush_ACE_Metrics_Timeprobe ()
00159 {
00160 }
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170 template <class ACE_LOCK, class ALLOCATOR>
00171 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::
00172 ACE_Metrics_Cache (u_long table_size,
00173 u_long number_of_probes,
00174 ALLOCATOR *alloc)
00175 : probe_set_size_ (0),
00176 enqueue_names_ (0),
00177 dequeue_names_ (0),
00178 consumer_index_ (0),
00179 supplier_index_ (1),
00180 table_size_ (table_size),
00181 interval_start_ (ACE_Time_Value::zero),
00182 interval_end_ (ACE_Time_Value::zero),
00183 interval_initialized_ (0),
00184 metrics_enabled_(1),
00185 allocator_ (alloc)
00186 {
00187 ACE_UNUSED_ARG(number_of_probes);
00188
00189
00190
00191
00192 ACE_High_Res_Timer::global_scale_factor ();
00193
00194 enqueue_count_ [0] = 0;
00195 enqueue_count_ [1] = 0;
00196 dequeue_count_ [0] = 0;
00197 dequeue_count_ [1] = 0;
00198 enqueue_probes_ [0] = 0;
00199 enqueue_probes_ [1] = 0;
00200 dequeue_probes_ [0] = 0;
00201 dequeue_probes_ [1] = 0;
00202 }
00203
00204
00205
00206 template <class ACE_LOCK, class ALLOCATOR>
00207 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::~ACE_Metrics_Cache ()
00208 {
00209 }
00210
00211
00212
00213
00214
00215
00216 template <class ACE_LOCK, class ALLOCATOR> ALLOCATOR *
00217 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::allocator (void)
00218 {
00219 ALLOCATOR * alloc = allocator_;
00220 return alloc
00221 ? alloc
00222 : ACE_Singleton<ALLOCATOR, ACE_LOCK>::instance ();
00223 }
00224
00225
00226
00227
00228 template <class ACE_LOCK, class ALLOCATOR> void
00229 ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR>::
00230 flush_ACE_Metrics_Cache ()
00231 {
00232 }
00233
00234 ACE_END_VERSIONED_NAMESPACE_DECL
00235
00236 #endif
00237
00238 #endif