Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Metrics_Cache_T.h
blob9488c81b7aec8a1f081d95769f7d2a7cf4ea624d
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Metrics_Cache_T.h
7 * @author Chris Gill <cdgill@cse.wustl.edu>
8 */
9 //=============================================================================
12 #ifndef ACE_METRICS_CACHE_T_H
13 #define ACE_METRICS_CACHE_T_H
15 #include /**/ "ace/config-all.h"
17 // helpful macro definitions
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #if defined (ACE_COMPILE_TIMEPROBES)
24 #include "ace/Timeprobe.h"
25 #include "ace/Timeprobe_T.h"
27 // Defaults for initializing timeprobes and timeprobe arays.
28 #define METRICS_MIN_TIMEPROBE_TABLE_SIZE 256 * 4
29 #define METRICS_MAX_TIMEPROBE_TABLE_SIZE 256 * 256
30 #define METRICS_DEFAULT_TIMEPROBE_TABLE_SIZE METRICS_MIN_TIMEPROBE_TABLE_SIZE
31 #define METRICS_DEFAULT_TIMEPROBE_COUNT 6
33 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
35 /**
36 * @class ACE_Metrics_Timeprobe
38 * @brief This class implements a timeprobe for use in a Metrics framework.
40 * This class provides a probe for specific thread and method call
41 * metrics timing points.
43 template <class ACE_LOCK, class ALLOCATOR>
44 class ACE_Metrics_Timeprobe :
45 public ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>
47 public:
48 typedef ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>
49 ACE_METRICS_TIMEPROBE_TYPE;
51 typedef ACE_timeprobe_t ACE_METRICS_TIMEPROBE_DATA_TYPE;
52 typedef ACE_METRICS_TIMEPROBE_TYPE* ACE_METRICS_TIMEPROBE_BASED_PTR_TYPE;
53 typedef char* ACE_METRICS_NAME_BASED_PTR_TYPE;
55 /// Enumerated timeprobe event types.
56 enum event_id
58 WORK_START = 0,
59 WORK_STOP = 1,
60 WORK_SUSPEND = 2,
61 WORK_RESUME = 3
64 /// Default constructor: plugs in the above event descriptions.
65 ACE_Metrics_Timeprobe (u_int id = 0,
66 const char *name = 0,
67 u_long size = METRICS_DEFAULT_TIMEPROBE_TABLE_SIZE);
69 /// Constructor with allocator: plugs in the above event descriptions.
70 ACE_Metrics_Timeprobe (ALLOCATOR *allocatorPtr,
71 u_int id = 0,
72 const char *name = 0,
73 u_long size = METRICS_DEFAULT_TIMEPROBE_TABLE_SIZE);
75 /// Destructor.
76 virtual ~ACE_Metrics_Timeprobe ();
78 /// Returns true if a timeprobe event matches the passed id.
79 int is_event (const ACE_METRICS_TIMEPROBE_DATA_TYPE &t,
80 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::event_id id);
82 /// Accessor and mutator for probe name.
83 const char * probe_name ();
84 void probe_name (char * name);
86 /// Accessor for probe id.
87 u_int probe_id ();
89 /// Mutator for probe id.
90 void probe_id (u_int id);
92 /// Flush the ACE metrics timeprobe into shared memory.
93 void flush_ACE_Metrics_Timeprobe ();
95 protected:
96 /// Identifier for the timeprobe.
97 u_int id_;
99 /// Name of the timeprobe.
100 char* name_;
102 private:
103 // Declare but do not define.
104 ACE_Metrics_Timeprobe (const ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> &);
105 void operator =(const ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> &);
109 * @class ACE_Metrics_Cache
111 * @brief This class implements a cache for metrics timeprobe data.
113 * This class allows probes to be recorded into a single cache that
114 * monitors and other higher level metrics classes can query.
116 template <class ACE_LOCK, class ALLOCATOR>
117 class ACE_Metrics_Cache
119 public:
120 typedef ACE_Metrics_Cache <ACE_LOCK, ALLOCATOR> ACE_METRICS_CACHE_TYPE;
122 /// Default constructor.
123 ACE_Metrics_Cache (u_long table_size
124 = METRICS_DEFAULT_TIMEPROBE_TABLE_SIZE,
125 u_long number_of_probes
126 = METRICS_DEFAULT_TIMEPROBE_COUNT,
127 ALLOCATOR * allocatorPtr = (ALLOCATOR*)ALLOCATOR::instance());
129 /// Destructor.
130 ~ACE_Metrics_Cache ();
132 // = Dispatching metrics.
134 /// Report start, stop, suspend, and resume times of a dispatch
135 /// enqueue: stores data metrics on the supplier side.
136 void report_enqueue_start (u_long i);
137 void report_enqueue_stop (u_long i);
138 void report_enqueue_suspend (u_long i);
139 void report_enqueue_resume (u_long i);
141 /// Report start, stop, suspend, and resume times of a dispatch
142 /// dequeue: stores data metrics on the supplier side..
143 void report_dequeue_start (u_long i);
144 void report_dequeue_stop (u_long i);
145 void report_dequeue_suspend (u_long i);
146 void report_dequeue_resume (u_long i);
148 /// Reset the metrics data on the consumer side.
149 void reset_base_statistics ();
151 /// Flips the supplier and consumer sides.
152 void flip_supplier_and_consumer ();
154 /// Flush the ACE metrics cache into shared memory.
155 void flush_ACE_Metrics_Cache ();
157 /// Set the enable state for metrics collection.
158 void metrics_enabled(int enabled);
160 /// Return the enable state for metrics collection.
161 int metrics_enabled() const;
163 protected:
164 /// Obtain an allocator pointer correctly thunked for the current
165 /// address space. If there is no allocator stored in the instance,
166 /// the singleton allocator in the current process is used.
167 ALLOCATOR * allocator ();
169 // = Implementation members.
171 /// Number of probes in each supplier/consumer set.
172 u_long probe_set_size_;
174 /// Probe data counts for each supplier/consumer set.
175 u_long * enqueue_count_ [2];
176 u_long * dequeue_count_ [2];
178 /// Probes for each supplier/consumer set.
179 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> ** enqueue_probes_ [2];
180 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> ** dequeue_probes_ [2];
182 /// Names for the probes.
183 char ** enqueue_names_;
184 char ** dequeue_names_;
186 /// Index from which probe events are being consumed.
187 /// for WSOA, it's the data being sent to the logger
188 int consumer_index_;
190 /// Index to which probe events are being supplied.
191 /// for WSOA, it's the data being recorded from the probes
192 int supplier_index_;
194 /// Size of the timestamp table in each probe.
195 u_long table_size_;
197 /// Interval start and stop timestamps.
198 ACE_Time_Value interval_start_;
200 /// Interval start and stop timestamps.
201 ACE_Time_Value interval_end_;
203 /// Flag to indicate whether or not start time of interval has been
204 /// initialized since the last reset.
205 int interval_initialized_;
207 /// Indicator of whether metrics is enabled.
208 int metrics_enabled_;
210 private:
211 /// Allocation strategy object.
212 ALLOCATOR* allocator_;
214 // Declare but do not define.
215 ACE_Metrics_Cache (const ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR> &);
216 void operator = (const ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR> &);
219 ACE_END_VERSIONED_NAMESPACE_DECL
221 #if defined (__ACE_INLINE__)
222 #include "ace/Metrics_Cache_T.inl"
223 #endif /* __ACE_INLINE__ */
225 #include "ace/Metrics_Cache_T.cpp"
227 #endif /* defined (ACE_COMPILE_TIMEPROBES) */
229 #endif /* ACE_METRICS_CACHE_T_H */