Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Timeprobe.h
blob2e4c19076675d22df58f6a06eb8c4abb0d65dd26
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Timeprobe.h
7 * @author Irfan Pyarali
9 * If users want to use time probes, the ACE_COMPILE_TIMEPROBES
10 * flag must be defined when compiling ACE. This can be achieved
11 * by doing one of the following:
13 * . Use make probe = 1, if you are using the make utility.
15 * . Define ACE_COMPILE_TIMEPROBES in config.h
17 * . Define ACE_COMPILE_TIMEPROBES in the VC project file.
19 * . Other regular methods will also work.
21 * It is not necessary to define ACE_COMPILE_TIMEPROBES when using
22 * time probes, you simply need ACE_ENABLE_TIMEPROBES. You can use
23 * the ACE_TIMEPROBE_* macros to program the time probes, and use
24 * the ACE_ENABLE_TIMEPROBE to enable the time probes. If you
25 * define ACE_ENABLE_TIMEPROBE in your code, but forget to compile
26 * ACE with ACE_COMPILE_TIMEPROBES, you will end up with linker
27 * errors.
29 * Remember that ACE_COMPILE_TIMEPROBES means that the ACE library
30 * will contain code for time probes. This is only useful when
31 * compiling ACE. ACE_ENABLE_TIMEPROBES means that the
32 * ACE_TIMEPROBE_* macros should spring to life.
34 //=============================================================================
36 #ifndef ACE_TIMEPROBE_H
37 #define ACE_TIMEPROBE_H
38 #include /**/ "ace/pre.h"
40 #include /**/ "ace/config-lite.h"
41 #include /**/ "ace/ACE_export.h"
42 #include "ace/Malloc_Allocator.h"
44 #if !defined (ACE_LACKS_PRAGMA_ONCE)
45 # pragma once
46 #endif /* ACE_LACKS_PRAGMA_ONCE */
48 /* Enable ACE Timeprobes */
49 #if defined (ACE_ENABLE_TIMEPROBES)
50 #if !defined (ACE_COMPILE_TIMEPROBES)
51 #define ACE_COMPILE_TIMEPROBES
52 #endif /* ACE_COMPILE_TIMEPROBES */
53 #endif /* ACE_ENABLE_TIMEPROBES */
55 #if defined (ACE_COMPILE_TIMEPROBES)
57 #include "ace/OS_NS_time.h"
58 #include "ace/OS_NS_Thread.h"
60 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
62 /**
63 * @class ACE_Event_Descriptions
65 * @brief Event Descriptions.
67 class ACE_Export ACE_Event_Descriptions
69 public:
70 /// Event descriptions
71 const char **descriptions_;
73 /// Minimum id of this description set
74 u_long minimum_id_;
76 /// Comparison
77 bool operator== (const ACE_Event_Descriptions &rhs) const;
80 /**
81 * @class ACE_timeprobe_t
83 * @brief Time probe record.
85 class ACE_Export ACE_timeprobe_t
87 public:
88 /// Events are record as strings or numbers.
89 union event
91 u_long event_number_;
92 const char *event_description_;
95 /// Type of event.
96 enum event_type
98 NUMBER,
99 STRING
102 /// Event.
103 event event_;
105 /// Type of event.
106 event_type event_type_;
108 /// Timestamp.
109 ACE_hrtime_t time_;
111 /// Id of thread posting the time probe.
112 ACE_thread_t thread_;
115 ACE_END_VERSIONED_NAMESPACE_DECL
117 #if defined (__ACE_INLINE__)
118 #include "ace/Timeprobe.inl"
119 #endif /* __ACE_INLINE__ */
121 #include "ace/Synch_Traits.h"
122 #include "ace/Null_Mutex.h"
123 #include "ace/Singleton.h"
124 #include "ace/Timeprobe_T.h"
126 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
128 // If ACE_MT_TIMEPROBES is defined, use a Thread_Mutex to lock the
129 // internal state of ACE_Timerprobe. This allows multiple threads to
130 // use the same ACE_Timerprobe.
131 # if defined (ACE_MT_TIMEPROBES)
132 typedef ACE_SYNCH_MUTEX ACE_TIMEPROBE_MUTEX;
133 # else /* ACE_MT_TIMEPROBES */
134 typedef ACE_SYNCH_NULL_MUTEX ACE_TIMEPROBE_MUTEX;
135 # endif /* ACE_MT_TIMEPROBES */
137 typedef ACE_New_Allocator ACE_TIMEPROBE_ALLOCATOR;
139 typedef ACE_Timeprobe_Ex<ACE_TIMEPROBE_MUTEX, ACE_TIMEPROBE_ALLOCATOR>
140 ACE_TIMEPROBE_WITH_LOCKING;
142 // If ACE_TSS_TIMEPROBES is defined, store the ACE_Timeprobe singleton
143 // in thread specific storage. This allows multiple threads to use
144 // their own instance of ACE_Timerprobe, without interfering with each
145 // other.
146 # if defined (ACE_TSS_TIMEPROBES)
147 # define ACE_TIMEPROBE_SINGLETON_TYPE ACE_TSS_Singleton
148 # define ACE_TIMEPROBE_SINGLETON_LOCK_TYPE ACE_SYNCH_NULL_MUTEX
149 # else /* ACE_TSS_TIMEPROBES */
150 # define ACE_TIMEPROBE_SINGLETON_TYPE ACE_Singleton
151 # define ACE_TIMEPROBE_SINGLETON_LOCK_TYPE ACE_SYNCH_MUTEX
152 # endif /* ACE_TSS_TIMEPROBES */
154 ACE_SINGLETON_DECLARE (ACE_TIMEPROBE_SINGLETON_TYPE, \
155 ACE_TIMEPROBE_WITH_LOCKING, \
156 ACE_TIMEPROBE_SINGLETON_LOCK_TYPE)
158 typedef ACE_TIMEPROBE_SINGLETON_TYPE<ACE_TIMEPROBE_WITH_LOCKING, ACE_TIMEPROBE_SINGLETON_LOCK_TYPE>
159 ACE_TIMEPROBE_SINGLETON;
161 ACE_END_VERSIONED_NAMESPACE_DECL
163 #endif /* ACE_COMPILE_TIMEPROBES */
165 // If ACE_ENABLE_TIMEPROBES is defined, the macros below will
166 // work. Otherwise, they just vanish. Using this macro, you can
167 // control which files/libraries are probed.
168 #if defined (ACE_ENABLE_TIMEPROBES) && defined (ACE_COMPILE_TIMEPROBES)
170 # define ACE_TIMEPROBE_RESET ACE_TIMEPROBE_SINGLETON::instance ()->reset ()
172 # define ACE_TIMEPROBE(id) ACE_TIMEPROBE_SINGLETON::instance ()->timeprobe (id)
174 # define ACE_TIMEPROBE_PRINT ACE_TIMEPROBE_SINGLETON::instance ()->print_times ()
176 # define ACE_TIMEPROBE_PRINT_ABSOLUTE ACE_TIMEPROBE_SINGLETON::instance ()->print_absolute_times ()
178 # define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id) \
179 static int ace_timeprobe_##descriptions##_return = \
180 ACE_TIMEPROBE_SINGLETON::instance ()->event_descriptions \
181 (descriptions, minimum_id)
183 # define ACE_FUNCTION_TIMEPROBE(X) \
184 ACE_Function_Timeprobe<ACE_TIMEPROBE_WITH_LOCKING> function_timeprobe \
185 (*ACE_TIMEPROBE_SINGLETON::instance (), X)
187 #else /* ACE_ENABLE_TIMEPROBES && ACE_COMPILE_TIMEPROBES */
189 # define ACE_TIMEPROBE_RESET
190 # define ACE_TIMEPROBE(id)
191 # define ACE_TIMEPROBE_PRINT
192 # define ACE_TIMEPROBE_PRINT_ABSOLUTE
193 # define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id)
194 # define ACE_FUNCTION_TIMEPROBE(X)
196 #endif /* ACE_ENABLE_TIMEPROBES && ACE_COMPILE_TIMEPROBES */
197 #include /**/ "ace/post.h"
198 #endif /* ACE_TIMEPROBE_H */