1 #ifndef ACE_METRICS_CACHE_CPP
2 #define ACE_METRICS_CACHE_CPP
4 #include "ace/Metrics_Cache_T.h"
6 #if defined (ACE_COMPILE_TIMEPROBES)
8 #include "ace/Metrics_Cache.h"
10 #if !defined (__ACE_INLINE__)
11 #include "ace/Metrics_Cache_T.inl"
12 #endif /* __ACE_INLINE__ */
14 /// Const strings for timeprobe event type descriptions.
15 static const char * event_description_strings
[] =
23 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
25 /////////////////////////////////
26 // class ACE_Metrics_Timeprobe //
27 /////////////////////////////////
29 template <class ACE_LOCK
, class ALLOCATOR
>
30 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::ACE_Metrics_Timeprobe (u_int id
,
34 ACE_Timeprobe
<ACE_LOCK
> (size
),
44 ACE_NEW_MALLOC_ARRAY (name_tmp
,
45 (char *) this->allocator ()->malloc (ACE_OS::strlen(name
)+1),
47 ACE_OS::strlen(name
)+1);
48 ACE_OS::memcpy (name_tmp
, name
, ACE_OS::strlen (name
)+1);
51 this->event_descriptions (event_description_strings
,
52 sizeof(event_description_strings
)/sizeof(const char *));
55 template <class ACE_LOCK
, class ALLOCATOR
>
56 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::
57 ACE_Metrics_Timeprobe (ALLOCATOR
*alloc
,
61 : ACE_Timeprobe_Ex
<ACE_LOCK
, ALLOCATOR
> (size
),
71 ACE_NEW_MALLOC_ARRAY (name_tmp
,
72 (char *) alloc
->malloc(ACE_OS::strlen(name
)+1),
74 ACE_OS::strlen(name
)+1);
75 ACE_OS::memcpy (name_tmp
, name
, ACE_OS::strlen (name
)+1);
78 this->event_descriptions (event_description_strings
,
79 sizeof(event_description_strings
)/sizeof(const char *));
82 template <class ACE_LOCK
, class ALLOCATOR
>
83 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::~ACE_Metrics_Timeprobe ()
87 this->allocator ()->free ((void*) name_
);
92 // Returns true if a timeprobe matches the passed id.
94 template <class ACE_LOCK
, class ALLOCATOR
>
96 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::is_event (const ACE_Metrics_Timeprobe
<ACE_LOCK
,
98 ACE_METRICS_TIMEPROBE_DATA_TYPE
&t
,
99 ACE_Metrics_Timeprobe
<ACE_LOCK
,
103 return (t
.event_
.event_number_
== (u_long
) id
) ? 1 : 0;
106 template <class ACE_LOCK
, class ALLOCATOR
>
108 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::probe_name ()
113 template <class ACE_LOCK
, class ALLOCATOR
>
115 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::probe_name (char * name
)
118 ACE_NEW_MALLOC_ARRAY (name_tmp
,
119 (char *) this->allocator ()->malloc (ACE_OS::strlen(name
)+1),
121 ACE_OS::strlen(name
)+1);
122 ACE_OS::memcpy (name_tmp
, name
, ACE_OS::strlen (name
)+1);
126 this->allocator ()->free (name_
);
132 template <class ACE_LOCK
, class ALLOCATOR
>
134 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::probe_id ()
140 template <class ACE_LOCK
, class ALLOCATOR
>
142 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::probe_id (u_int id
)
148 // Flush the ACE metrics timeprobe into shared memory.
150 template <class ACE_LOCK
, class ALLOCATOR
> void
151 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::
152 flush_ACE_Metrics_Timeprobe ()
157 /////////////////////////////
158 // Class ACE_Metrics_Cache //
159 /////////////////////////////
164 template <class ACE_LOCK
, class ALLOCATOR
>
165 ACE_Metrics_Cache
<ACE_LOCK
, ALLOCATOR
>::
166 ACE_Metrics_Cache (u_long table_size
,
169 : probe_set_size_ (0),
174 table_size_ (table_size
),
175 interval_start_ (ACE_Time_Value::zero
),
176 interval_end_ (ACE_Time_Value::zero
),
177 interval_initialized_ (0),
181 // Initialize probe and count arrays.
183 // Ensure that the high res timer global scale factor
184 // is set before any of its static methods are used
185 ACE_High_Res_Timer::global_scale_factor ();
187 enqueue_count_
[0] = 0;
188 enqueue_count_
[1] = 0;
189 dequeue_count_
[0] = 0;
190 dequeue_count_
[1] = 0;
191 enqueue_probes_
[0] = 0;
192 enqueue_probes_
[1] = 0;
193 dequeue_probes_
[0] = 0;
194 dequeue_probes_
[1] = 0;
199 template <class ACE_LOCK
, class ALLOCATOR
>
200 ACE_Metrics_Cache
<ACE_LOCK
, ALLOCATOR
>::~ACE_Metrics_Cache ()
204 // Obtain an allocator pointer correctly thunked for the current
205 // address space. If there is no allocator stored in the instance,
206 // the singleton allocator in the current process is used.
208 template <class ACE_LOCK
, class ALLOCATOR
> ALLOCATOR
*
209 ACE_Metrics_Cache
<ACE_LOCK
, ALLOCATOR
>::allocator ()
211 ALLOCATOR
* alloc
= allocator_
;
214 : ACE_Singleton
<ALLOCATOR
, ACE_LOCK
>::instance ();
218 // Flush the ACE metrics cache into shared memory.
220 template <class ACE_LOCK
, class ALLOCATOR
> void
221 ACE_Metrics_Cache
<ACE_LOCK
, ALLOCATOR
>::
222 flush_ACE_Metrics_Cache ()
226 ACE_END_VERSIONED_NAMESPACE_DECL
228 #endif /* defined (ACE_COMPILE_TIMEPROBES) */
230 #endif /* ACE_METRICS_CACHE_CPP */