00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef ACE_METRICS_CACHE_T_H
00015 #define ACE_METRICS_CACHE_T_H
00016
00017 #include "ace/config-all.h"
00018
00019
00020 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00021 # pragma once
00022 #endif
00023
00024 #if defined (ACE_COMPILE_TIMEPROBES)
00025
00026 #include "ace/Timeprobe.h"
00027 #include "ace/Timeprobe_T.h"
00028
00029
00030 #define METRICS_MIN_TIMEPROBE_TABLE_SIZE 256 * 4
00031 #define METRICS_MAX_TIMEPROBE_TABLE_SIZE 256 * 256
00032 #define METRICS_DEFAULT_TIMEPROBE_TABLE_SIZE METRICS_MIN_TIMEPROBE_TABLE_SIZE
00033 #define METRICS_DEFAULT_TIMEPROBE_COUNT 6
00034
00035 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 template <class ACE_LOCK, class ALLOCATOR>
00046 class ACE_Metrics_Timeprobe :
00047 public ACE_Timeprobe_Ex<ACE_LOCK, ALLOCATOR>
00048 {
00049 public:
00050
00051 typedef ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>
00052 ACE_METRICS_TIMEPROBE_TYPE;
00053
00054 typedef ACE_timeprobe_t ACE_METRICS_TIMEPROBE_DATA_TYPE;
00055 typedef ACE_METRICS_TIMEPROBE_TYPE* ACE_METRICS_TIMEPROBE_BASED_PTR_TYPE;
00056 typedef char* ACE_METRICS_NAME_BASED_PTR_TYPE;
00057
00058
00059 enum event_id
00060 {
00061 WORK_START = 0,
00062 WORK_STOP = 1,
00063 WORK_SUSPEND = 2,
00064 WORK_RESUME = 3
00065 };
00066
00067
00068 ACE_Metrics_Timeprobe (u_int id = 0,
00069 const char *name = 0,
00070 u_long size = METRICS_DEFAULT_TIMEPROBE_TABLE_SIZE);
00071
00072
00073 ACE_Metrics_Timeprobe (ALLOCATOR *allocatorPtr,
00074 u_int id = 0,
00075 const char *name = 0,
00076 u_long size = METRICS_DEFAULT_TIMEPROBE_TABLE_SIZE);
00077
00078
00079 virtual ~ACE_Metrics_Timeprobe ();
00080
00081
00082 int is_event (const ACE_METRICS_TIMEPROBE_DATA_TYPE &t,
00083 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR>::event_id id);
00084
00085
00086 const char * probe_name (void);
00087 void probe_name (char * name);
00088
00089
00090 u_int probe_id (void);
00091
00092
00093 void probe_id (u_int id);
00094
00095
00096 void flush_ACE_Metrics_Timeprobe ();
00097
00098 protected:
00099
00100
00101 u_int id_;
00102
00103
00104 char* name_;
00105
00106 private:
00107
00108
00109 ACE_Metrics_Timeprobe (const ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> &);
00110 void operator =(const ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> &);
00111 };
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121 template <class ACE_LOCK, class ALLOCATOR>
00122 class ACE_Metrics_Cache
00123 {
00124 public:
00125
00126 typedef ACE_Metrics_Cache <ACE_LOCK, ALLOCATOR> ACE_METRICS_CACHE_TYPE;
00127
00128
00129 ACE_Metrics_Cache (u_long table_size
00130 = METRICS_DEFAULT_TIMEPROBE_TABLE_SIZE,
00131 u_long number_of_probes
00132 = METRICS_DEFAULT_TIMEPROBE_COUNT,
00133 ALLOCATOR * allocatorPtr = (ALLOCATOR*)ALLOCATOR::instance());
00134
00135
00136 ~ACE_Metrics_Cache ();
00137
00138
00139
00140
00141
00142 void report_enqueue_start (u_long i);
00143 void report_enqueue_stop (u_long i);
00144 void report_enqueue_suspend (u_long i);
00145 void report_enqueue_resume (u_long i);
00146
00147
00148
00149 void report_dequeue_start (u_long i);
00150 void report_dequeue_stop (u_long i);
00151 void report_dequeue_suspend (u_long i);
00152 void report_dequeue_resume (u_long i);
00153
00154
00155 void reset_base_statistics ();
00156
00157
00158 void flip_supplier_and_consumer ();
00159
00160
00161 void flush_ACE_Metrics_Cache ();
00162
00163
00164 void metrics_enabled(int enabled);
00165
00166
00167 int metrics_enabled(void) const;
00168
00169 protected:
00170
00171
00172
00173
00174 ALLOCATOR * allocator (void);
00175
00176
00177
00178
00179 u_long probe_set_size_;
00180
00181
00182 u_long * enqueue_count_ [2];
00183 u_long * dequeue_count_ [2];
00184
00185
00186 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> ** enqueue_probes_ [2];
00187 ACE_Metrics_Timeprobe<ACE_LOCK, ALLOCATOR> ** dequeue_probes_ [2];
00188
00189
00190 char ** enqueue_names_;
00191 char ** dequeue_names_;
00192
00193
00194
00195 int consumer_index_;
00196
00197
00198
00199 int supplier_index_;
00200
00201
00202 u_long table_size_;
00203
00204
00205 ACE_Time_Value interval_start_;
00206
00207
00208 ACE_Time_Value interval_end_;
00209
00210
00211
00212 int interval_initialized_;
00213
00214
00215 int metrics_enabled_;
00216
00217 private:
00218
00219
00220 ALLOCATOR* allocator_;
00221
00222
00223 ACE_Metrics_Cache (const ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR> &);
00224 void operator = (const ACE_Metrics_Cache<ACE_LOCK, ALLOCATOR> &);
00225 };
00226
00227 ACE_END_VERSIONED_NAMESPACE_DECL
00228
00229 #if defined (__ACE_INLINE__)
00230 #include "ace/Metrics_Cache_T.inl"
00231 #endif
00232
00233 #if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
00234 #include "ace/Metrics_Cache_T.cpp"
00235 #endif
00236
00237 #if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
00238 #pragma implementation ("Metrics_Cache_T.cpp")
00239 #endif
00240
00241 #endif
00242
00243 #endif