Timeprobe.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Timeprobe.h
00006  *
00007  *  $Id: Timeprobe.h 80826 2008-03-04 14:51:23Z wotte $
00008  *
00009  *  @author Irfan Pyarali
00010  *
00011  * If users want to use time probes, the ACE_COMPILE_TIMEPROBES
00012  * flag must be defined when compiling ACE.  This can be achieved
00013  * by doing one of the following:
00014  *
00015  * . Use make probe = 1, if you are using the make utility.
00016  *
00017  * . Define ACE_COMPILE_TIMEPROBES in config.h
00018  *
00019  * . Define ACE_COMPILE_TIMEPROBES in the VC project file.
00020  *
00021  * . Other regular methods will also work.
00022  *
00023  * It is not necessary to define ACE_COMPILE_TIMEPROBES when using
00024  * time probes, you simply need ACE_ENABLE_TIMEPROBES.  You can use
00025  * the ACE_TIMEPROBE_* macros to program the time probes, and use
00026  * the ACE_ENABLE_TIMEPROBE to enable the time probes.  If you
00027  * define ACE_ENABLE_TIMEPROBE in your code, but forget to compile
00028  * ACE with ACE_COMPILE_TIMEPROBES, you will end up with linker
00029  * errors.
00030  *
00031  * Remember that ACE_COMPILE_TIMEPROBES means that the ACE library
00032  * will contain code for time probes.  This is only useful when
00033  * compiling ACE. ACE_ENABLE_TIMEPROBES means that the
00034  * ACE_TIMEPROBE_* macros should spring to life.
00035  */
00036 //=============================================================================
00037 
00038 #ifndef ACE_TIMEPROBE_H
00039 #define ACE_TIMEPROBE_H
00040 #include /**/ "ace/pre.h"
00041 
00042 #include "ace/config-lite.h"
00043 #include /**/ "ace/ACE_export.h"
00044 #include "ace/Malloc_Allocator.h"
00045 
00046 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00047 # pragma once
00048 #endif /* ACE_LACKS_PRAGMA_ONCE */
00049 
00050 /* Enable ACE Timeprobes */
00051 #if defined (ACE_ENABLE_TIMEPROBES)
00052   #if !defined (ACE_COMPILE_TIMEPROBES)
00053     #define ACE_COMPILE_TIMEPROBES
00054   #endif /* ACE_COMPILE_TIMEPROBES */
00055 #endif /* ACE_ENABLE_TIMEPROBES */
00056 
00057 #if defined (ACE_COMPILE_TIMEPROBES)
00058 
00059 #include "ace/OS_NS_time.h"
00060 #include "ace/OS_NS_Thread.h"
00061 
00062 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00063 
00064 /**
00065  * @class ACE_Event_Descriptions
00066  *
00067  * @brief Event Descriptions.
00068  */
00069 class ACE_Export ACE_Event_Descriptions
00070 {
00071 public:
00072   /// Event descriptions
00073   const char **descriptions_;
00074 
00075   /// Minimum id of this description set
00076   u_long minimum_id_;
00077 
00078   /// Comparison
00079   bool operator== (const ACE_Event_Descriptions &rhs) const;
00080 };
00081 
00082 /**
00083  * @class ACE_timeprobe_t
00084  *
00085  * @brief Time probe record.
00086  */
00087 class ACE_Export ACE_timeprobe_t
00088 {
00089 public:
00090   /// Events are record as strings or numbers.
00091   union event
00092   {
00093     u_long event_number_;
00094     const char *event_description_;
00095   };
00096 
00097   /// Type of event.
00098   enum event_type
00099   {
00100     NUMBER,
00101     STRING
00102   };
00103 
00104   /// Event.
00105   event event_;
00106 
00107   /// Type of event.
00108   event_type event_type_;
00109 
00110   /// Timestamp.
00111   ACE_hrtime_t time_;
00112 
00113   /// Id of thread posting the time probe.
00114   ACE_thread_t thread_;
00115 };
00116 
00117 ACE_END_VERSIONED_NAMESPACE_DECL
00118 
00119 #if defined (__ACE_INLINE__)
00120 #include "ace/Timeprobe.inl"
00121 #endif /* __ACE_INLINE__ */
00122 
00123 #include "ace/Synch_Traits.h"
00124 #include "ace/Null_Mutex.h"
00125 #include "ace/Singleton.h"
00126 #include "ace/Timeprobe_T.h"
00127 
00128 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00129 
00130 // If ACE_MT_TIMEPROBES is defined, use a Thread_Mutex to lock the
00131 // internal state of ACE_Timerprobe.  This allows multiple threads to
00132 // use the same ACE_Timerprobe.
00133 #  if defined (ACE_MT_TIMEPROBES)
00134 typedef ACE_SYNCH_MUTEX ACE_TIMEPROBE_MUTEX;
00135 #  else /* ACE_MT_TIMEPROBES */
00136 typedef ACE_SYNCH_NULL_MUTEX ACE_TIMEPROBE_MUTEX;
00137 #  endif /* ACE_MT_TIMEPROBES */
00138 
00139 typedef ACE_New_Allocator ACE_TIMEPROBE_ALLOCATOR;
00140 
00141 typedef ACE_Timeprobe_Ex<ACE_TIMEPROBE_MUTEX, ACE_TIMEPROBE_ALLOCATOR>
00142         ACE_TIMEPROBE_WITH_LOCKING;
00143 
00144 // If ACE_TSS_TIMEPROBES is defined, store the ACE_Timeprobe singleton
00145 // in thread specific storage.  This allows multiple threads to use
00146 // their own instance of ACE_Timerprobe, without interfering with each
00147 // other.
00148 
00149 #  if defined (ACE_TSS_TIMEPROBES)
00150 #    define ACE_TIMEPROBE_SINGLETON_TYPE ACE_TSS_Singleton
00151 #    define ACE_TIMEPROBE_SINGLETON_LOCK_TYPE ACE_SYNCH_NULL_MUTEX
00152 #  else /* ACE_TSS_TIMEPROBES */
00153 #    define ACE_TIMEPROBE_SINGLETON_TYPE ACE_Singleton
00154 #    define ACE_TIMEPROBE_SINGLETON_LOCK_TYPE ACE_SYNCH_MUTEX
00155 #  endif /* ACE_TSS_TIMEPROBES */
00156 
00157 ACE_SINGLETON_DECLARE (ACE_TIMEPROBE_SINGLETON_TYPE, \
00158                        ACE_TIMEPROBE_WITH_LOCKING,   \
00159                        ACE_TIMEPROBE_SINGLETON_LOCK_TYPE)
00160 
00161 typedef ACE_TIMEPROBE_SINGLETON_TYPE<ACE_TIMEPROBE_WITH_LOCKING, ACE_TIMEPROBE_SINGLETON_LOCK_TYPE>
00162         ACE_TIMEPROBE_SINGLETON;
00163 
00164 ACE_END_VERSIONED_NAMESPACE_DECL
00165 
00166 #endif /* ACE_COMPILE_TIMEPROBES */
00167 
00168 // If ACE_ENABLE_TIMEPROBES is defined, the macros below will
00169 // work. Otherwise, they just vanish.  Using this macro, you can
00170 // control which files/libraries are probed.
00171 #if defined (ACE_ENABLE_TIMEPROBES) && defined (ACE_COMPILE_TIMEPROBES)
00172 
00173 #  define ACE_TIMEPROBE_RESET ACE_TIMEPROBE_SINGLETON::instance ()->reset ()
00174 
00175 #  define ACE_TIMEPROBE(id) ACE_TIMEPROBE_SINGLETON::instance ()->timeprobe (id)
00176 
00177 #  define ACE_TIMEPROBE_PRINT ACE_TIMEPROBE_SINGLETON::instance ()->print_times ()
00178 
00179 #  define ACE_TIMEPROBE_PRINT_ABSOLUTE ACE_TIMEPROBE_SINGLETON::instance ()->print_absolute_times ()
00180 
00181 #  define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id) \
00182 static int ace_timeprobe_##descriptions##_return = \
00183   ACE_TIMEPROBE_SINGLETON::instance ()->event_descriptions \
00184     (descriptions, minimum_id)
00185 
00186 #  define ACE_FUNCTION_TIMEPROBE(X) \
00187   ACE_Function_Timeprobe<ACE_TIMEPROBE_WITH_LOCKING> function_timeprobe \
00188     (*ACE_TIMEPROBE_SINGLETON::instance (), X)
00189 
00190 #else /* ACE_ENABLE_TIMEPROBES && ACE_COMPILE_TIMEPROBES */
00191 
00192 #  define ACE_TIMEPROBE_RESET
00193 #  define ACE_TIMEPROBE(id)
00194 #  define ACE_TIMEPROBE_PRINT
00195 #  define ACE_TIMEPROBE_PRINT_ABSOLUTE
00196 #  define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id)
00197 #  define ACE_FUNCTION_TIMEPROBE(X)
00198 
00199 #endif /* ACE_ENABLE_TIMEPROBES && ACE_COMPILE_TIMEPROBES */
00200 #include /**/ "ace/post.h"
00201 #endif /* ACE_TIMEPROBE_H */

Generated on Tue Feb 2 17:18:43 2010 for ACE by  doxygen 1.4.7