1 #ifndef ACE_METRICS_CACHE_CPP
2 #define ACE_METRICS_CACHE_CPP
4 //#define ACE_BUILD_DLL
6 #include "ace/Metrics_Cache_T.h"
8 #if defined (ACE_COMPILE_TIMEPROBES)
10 #include "ace/Metrics_Cache.h"
12 #if !defined (__ACE_INLINE__)
13 #include "ace/Metrics_Cache_T.inl"
14 #endif /* __ACE_INLINE__ */
16 /// Const strings for timeprobe event type descriptions.
17 static const char * event_description_strings
[] =
25 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 /////////////////////////////////
28 // class ACE_Metrics_Timeprobe //
29 /////////////////////////////////
31 template <class ACE_LOCK
, class ALLOCATOR
>
32 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::ACE_Metrics_Timeprobe (u_int id
,
36 ACE_Timeprobe
<ACE_LOCK
> (size
),
46 ACE_NEW_MALLOC_ARRAY (name_tmp
,
47 (char *) this->allocator ()->malloc (ACE_OS::strlen(name
)+1),
49 ACE_OS::strlen(name
)+1);
50 ACE_OS::memcpy (name_tmp
, name
, ACE_OS::strlen (name
)+1);
53 this->event_descriptions (event_description_strings
,
54 sizeof(event_description_strings
)/sizeof(const char *));
57 template <class ACE_LOCK
, class ALLOCATOR
>
58 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::
59 ACE_Metrics_Timeprobe (ALLOCATOR
*alloc
,
63 : ACE_Timeprobe_Ex
<ACE_LOCK
, ALLOCATOR
> (size
),
73 ACE_NEW_MALLOC_ARRAY (name_tmp
,
74 (char *) alloc
->malloc(ACE_OS::strlen(name
)+1),
76 ACE_OS::strlen(name
)+1);
77 ACE_OS::memcpy (name_tmp
, name
, ACE_OS::strlen (name
)+1);
80 this->event_descriptions (event_description_strings
,
81 sizeof(event_description_strings
)/sizeof(const char *));
84 template <class ACE_LOCK
, class ALLOCATOR
>
85 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::~ACE_Metrics_Timeprobe ()
89 this->allocator ()->free ((void*) name_
);
94 // Returns true if a timeprobe matches the passed id.
96 template <class ACE_LOCK
, class ALLOCATOR
>
98 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::is_event (const ACE_Metrics_Timeprobe
<ACE_LOCK
,
100 ACE_METRICS_TIMEPROBE_DATA_TYPE
&t
,
101 ACE_Metrics_Timeprobe
<ACE_LOCK
,
105 return (t
.event_
.event_number_
== (u_long
) id
) ? 1 : 0;
108 template <class ACE_LOCK
, class ALLOCATOR
>
110 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::probe_name (void)
115 template <class ACE_LOCK
, class ALLOCATOR
>
117 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::probe_name (char * name
)
120 ACE_NEW_MALLOC_ARRAY (name_tmp
,
121 (char *) this->allocator ()->malloc (ACE_OS::strlen(name
)+1),
123 ACE_OS::strlen(name
)+1);
124 ACE_OS::memcpy (name_tmp
, name
, ACE_OS::strlen (name
)+1);
128 this->allocator ()->free (name_
);
134 template <class ACE_LOCK
, class ALLOCATOR
>
136 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::probe_id (void)
142 template <class ACE_LOCK
, class ALLOCATOR
>
144 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::probe_id (u_int id
)
150 // Flush the ACE metrics timeprobe into shared memory.
152 template <class ACE_LOCK
, class ALLOCATOR
> void
153 ACE_Metrics_Timeprobe
<ACE_LOCK
, ALLOCATOR
>::
154 flush_ACE_Metrics_Timeprobe ()
159 /////////////////////////////
160 // Class ACE_Metrics_Cache //
161 /////////////////////////////
166 template <class ACE_LOCK
, class ALLOCATOR
>
167 ACE_Metrics_Cache
<ACE_LOCK
, ALLOCATOR
>::
168 ACE_Metrics_Cache (u_long table_size
,
171 : probe_set_size_ (0),
176 table_size_ (table_size
),
177 interval_start_ (ACE_Time_Value::zero
),
178 interval_end_ (ACE_Time_Value::zero
),
179 interval_initialized_ (0),
183 // Initialize probe and count arrays.
185 // Ensure that the high res timer global scale factor
186 // is set before any of its static methods are used
187 ACE_High_Res_Timer::global_scale_factor ();
189 enqueue_count_
[0] = 0;
190 enqueue_count_
[1] = 0;
191 dequeue_count_
[0] = 0;
192 dequeue_count_
[1] = 0;
193 enqueue_probes_
[0] = 0;
194 enqueue_probes_
[1] = 0;
195 dequeue_probes_
[0] = 0;
196 dequeue_probes_
[1] = 0;
201 template <class ACE_LOCK
, class ALLOCATOR
>
202 ACE_Metrics_Cache
<ACE_LOCK
, ALLOCATOR
>::~ACE_Metrics_Cache ()
206 // Obtain an allocator pointer correctly thunked for the current
207 // address space. If there is no allocator stored in the instance,
208 // the singleton allocator in the current process is used.
210 template <class ACE_LOCK
, class ALLOCATOR
> ALLOCATOR
*
211 ACE_Metrics_Cache
<ACE_LOCK
, ALLOCATOR
>::allocator (void)
213 ALLOCATOR
* alloc
= allocator_
;
216 : ACE_Singleton
<ALLOCATOR
, ACE_LOCK
>::instance ();
220 // Flush the ACE metrics cache into shared memory.
222 template <class ACE_LOCK
, class ALLOCATOR
> void
223 ACE_Metrics_Cache
<ACE_LOCK
, ALLOCATOR
>::
224 flush_ACE_Metrics_Cache ()
228 ACE_END_VERSIONED_NAMESPACE_DECL
230 #endif /* defined (ACE_COMPILE_TIMEPROBES) */
232 #endif /* ACE_METRICS_CACHE_CPP */