summaryrefslogtreecommitdiff
path: root/ace/Metrics_Cache.h
blob: c82f8697a14584a17d9d7b9bfdca6db3fb70bd34 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/* -*- C++ -*- */

//=============================================================================
/**
 *  @file    Metrics_Cache.h
 *
 *  $Id$
 *
 *  @author Chris Gill
 */
//=============================================================================


#ifndef ACE_METRICS_CACHE_H
#define ACE_METRICS_CACHE_H

#include "ace/OS.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#if defined (ACE_METRICS_COLLECTION)

#if defined (ACE_ENABLE_TIMEPROBES) && defined (ACE_COMPILE_TIMEPROBES)

/**
 * Call the appropriate 'report_ + NAME + _start' function. The start function makes a time probe measurement.
 *
 * ACE: The cache is a double-sided space of ACE_Timeprobe objects. For example if there is 10 probes there
 * will be a two lists of 10 probes all initialized. When a record is made, the appropriate probe is found,
 * add the measurement is made.
 *
 * TAO: The cache is still double sided but this time the X argument is a handle_t. The appropriate monitor
 *      map is located in the Metrics_Cache, find the data, and if there is nothing wrong with the data
 *      make a time measurement. The data is actually a ACE_Metrics_Timeprobe (Why not TAO_Metrics_Timeprobe?)
 *
 * USAGE_LEVEL: ACE+TAO
 *
 * @param METRICS_PTR - Pointer to a initialized metrics cache
 * @param NAME - Name of defining function (e.g. ACE: enqueue/dequeue)
 * @param X - Argument (ACE: u_int, TAO: RtecScheduler::handle_t)
 */
#  define START_DISPATCH_METRIC(METRICS_PTR,NAME,X) \
do { if((METRICS_PTR->metrics_enabled())) { \
METRICS_PTR->report_##NAME##_start(X); \
} } while (0)

/**
 * Call the appropriate 'report_ + NAME + _stop' function. The stop function makes a time probe measurement.
 *
 * ACE & TAO: Same as START_DISPATCH_METRIC
 *
 * USAGE_LEVEL: ACE+TAO
 *
 * @param METRICS_PTR - Pointer to a initialized metrics cache
 * @param NAME - Name of defining function (e.g. ACE: enqueue/dequeue)
 * @param X - Argument (ACE: u_int, TAO: RtecScheduler::handle_t)
 */
#  define STOP_DISPATCH_METRIC(METRICS_PTR,NAME,X) \
do { if((METRICS_PTR->metrics_enabled())) { \
METRICS_PTR->report_##NAME##_stop(X); \
} } while (0)

/**
 * Call the appropriate 'report_ + NAME + _suspend' function. The suspend function makes a time probe measurement.
 * This marks when the object under observation has been suspended.
 *
 * USAGE_LEVEL: ACE+TAO
 *
 * @param METRICS_PTR - Pointer to a initialized metrics cache
 * @param NAME - Name of defining function (e.g. ACE: enqueue/dequeue)
 * @param X - Argument (ACE: u_int, TAO: RtecScheduler::handle_t) 
 */
#  define PAUSE_DISPATCH_METRIC(METRICS_PTR,NAME,X) \
do { if((METRICS_PTR->metrics_enabled())) { \
METRICS_PTR->report_##NAME##_suspend(X); \
} } while (0)

/**
 * Call the appropriate 'report_ + NAME + _resume' function. The suspend function makes a time probe measurement.
 * This marks when the object under observation that was suspended is not resuming normal execution.
 *
 * USAGE_LEVEL: ACE+TAO
 *
 * @param METRICS_PTR - Pointer to a initialized metrics cache
 * @param NAME - Name of defining function (e.g. ACE: enqueue/dequeue)
 * @param X - Argument (ACE: u_int, TAO: RtecScheduler::handle_t) 
 */
#  define RESUME_DISPATCH_METRIC(METRICS_PTR,NAME,X) \
do { if((METRICS_PTR->metrics_enabled())) { \
METRICS_PTR->report_##NAME##_resume(X); \
} } while (0)


/**
 * Mystery macros. I could not find where there were functions like 'report_base_metrics_start ()'. All the
 * start and stop functions had an argument to find the probe in the cache
 */
#  define START_METRIC(METRICS_PTR,NAME) \
do { if((METRICS_PTR->metrics_enabled())) { \
METRICS_PTR->report_##NAME##_start(); \
} } while (0)

#  define STOP_METRIC(METRICS_PTR,NAME) \
do { if((METRICS_PTR->metrics_enabled())) { \
METRICS_PTR->report_##NAME##_stop(); \
} } while (0)

#if defined (__ACE_INLINE__)
#include "ace/Metrics_Cache.i"
#endif /* __ACE_INLINE__ */

#include "ace/Metrics_Cache_T.h"
#include "ace/Synch.h"
#include "ace/Singleton.h"

#if defined (_MSC_VER)
// Disable warning of using Microsoft Extension.
#pragma warning(disable:4231)
#endif /* _MSC_VER */

#if defined (_MSC_VER)
// Default back the warning of using Microsoft Extension.
#pragma warning(default:4231)
#endif /* _MSC_VER */

#else
#error ACE_Compile_Timeprobes must be defined in order to collect metrics
#endif /* ACE_ENABLE_TIMEPROBES & ACE_COMPILE_TIMEPROBES */

#else

#  define REGISTER_METRICS_PROBE_RETURN(METRICS_PTR,METRICS_REGION,PROBE_NAME,PROBE_TYPE,METRICS_HANDLE)
#  define REGISTER_METRICS_REPORTING_PROBE_RETURN(METRICS_PTR,METRICS_REGION,PROBE_NAME,PROBE_TYPE,METRICS_LOGGER_REF,METRICS_HANDLE)
#  define START_DISPATCH_METRIC(METRICS_PTR,NAME,X)
#  define STOP_DISPATCH_METRIC(METRICS_PTR,NAME,X)
#  define PAUSE_DISPATCH_METRIC(METRICS_PTR,NAME,X)
#  define RESUME_DISPATCH_METRIC(METRICS_PTR,NAME,X)
#  define START_METRIC(METRICS_PTR,NAME)
#  define STOP_METRIC(METRICS_PTR,NAME)

#endif /* ACE_ENABLE_TIMEPROBES && ACE_COMPILE_TIMEPROBES */

#endif /* ACE_METRICS_CACHE_H */