Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Timeprobe.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Timeprobe.h
00006  *
00007  *  $Id: Timeprobe.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
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/OS.h"
00043 
00044 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00045 # pragma once
00046 #endif /* ACE_LACKS_PRAGMA_ONCE */
00047 
00048 #if defined (ACE_ENABLE_TIMEPROBES)
00049   #if !defined (ACE_COMPILE_TIMEPROBES)
00050     #define ACE_COMPILE_TIMEPROBES
00051   #endif /* ACE_COMPILE_TIMEPROBES */
00052 #endif /* ACE_ENABLE_TIMEPROBES */
00053 
00054 #if defined (ACE_COMPILE_TIMEPROBES)
00055 
00056 /**
00057  * @class ACE_Event_Descriptions
00058  *
00059  * @brief Event Descriptions.
00060  */
00061 class ACE_Export ACE_Event_Descriptions
00062 {
00063 public:
00064   /// Event descriptions
00065   const char **descriptions_;
00066 
00067   /// Minimum id of this description set
00068   u_long minimum_id_;
00069 
00070   /// Comparison
00071   int operator== (const ACE_Event_Descriptions &rhs) const;
00072 };
00073 
00074 /**
00075  * @class ACE_timeprobe_t
00076  *
00077  * @brief Time probe record.
00078  */
00079 class ACE_Export ACE_timeprobe_t
00080 {
00081 public:
00082   /// Events are record as strings or numbers.
00083   union event
00084   {
00085     u_long event_number_;
00086     const char *event_description_;
00087   };
00088 
00089   /// Type of event.
00090   enum event_type
00091   {
00092     NUMBER,
00093     STRING
00094   };
00095 
00096   /// Event.
00097   event event_;
00098 
00099   /// Type of event.
00100   event_type event_type_;
00101 
00102   /// Timestamp.
00103   ACE_hrtime_t time_;
00104 
00105   /// Id of thread posting the time probe.
00106   ACE_thread_t thread_;
00107 };
00108 
00109 #if defined (__ACE_INLINE__)
00110 #include "ace/Timeprobe.i"
00111 #endif /* __ACE_INLINE__ */
00112 
00113 #include "ace/Synch.h"
00114 #include "ace/Singleton.h"
00115 #include "ace/Timeprobe_T.h"
00116 
00117 // If ACE_MT_TIMEPROBES is defined, use a Thread_Mutex to lock the
00118 // internal state of ACE_Timerprobe.  This allows multiple threads to
00119 // use the same ACE_Timerprobe.
00120 #  if defined (ACE_MT_TIMEPROBES)
00121 typedef ACE_SYNCH_MUTEX ACE_TIMEPROBE_MUTEX;
00122 #  else /* ACE_MT_TIMEPROBES */
00123 typedef ACE_SYNCH_NULL_MUTEX ACE_TIMEPROBE_MUTEX;
00124 #  endif /* ACE_MT_TIMEPROBES */
00125 
00126 typedef ACE_Timeprobe<ACE_TIMEPROBE_MUTEX>
00127         ACE_TIMEPROBE_WITH_LOCKING;
00128 
00129 // If ACE_TSS_TIMEPROBES is defined, store the ACE_Timeprobe singleton
00130 // in thread specific storage.  This allows multiple threads to use
00131 // their own instance of ACE_Timerprobe, without interfering with each
00132 // other.
00133 #  if defined (ACE_TSS_TIMEPROBES)
00134 #    define ACE_TIMEPROBE_SINGLETON_TYPE ACE_TSS_Singleton
00135 #    define ACE_TIMEPROBE_SINGLETON_LOCK_TYPE ACE_SYNCH_NULL_MUTEX
00136 #  else /* ACE_TSS_TIMEPROBES */
00137 #    define ACE_TIMEPROBE_SINGLETON_TYPE ACE_Singleton
00138 #    define ACE_TIMEPROBE_SINGLETON_LOCK_TYPE ACE_SYNCH_MUTEX
00139 #  endif /* ACE_TSS_TIMEPROBES */
00140 
00141 typedef ACE_TIMEPROBE_SINGLETON_TYPE<ACE_TIMEPROBE_WITH_LOCKING, ACE_TIMEPROBE_SINGLETON_LOCK_TYPE>
00142         ACE_TIMEPROBE_SINGLETON;
00143 
00144 ACE_SINGLETON_DECLARE (ACE_TIMEPROBE_SINGLETON_TYPE, \
00145                        ACE_TIMEPROBE_WITH_LOCKING, \
00146                        ACE_TIMEPROBE_SINGLETON_LOCK_TYPE);
00147 
00148 #endif /* ACE_COMPILE_TIMEPROBES */
00149 
00150 // If ACE_ENABLE_TIMEPROBES is defined, the macros below will
00151 // work. Otherwise, they just vanish.  Using this macro, you can
00152 // control which files/libraries are probed.
00153 #if defined (ACE_ENABLE_TIMEPROBES) && defined (ACE_COMPILE_TIMEPROBES)
00154 
00155 #  define ACE_TIMEPROBE_RESET ACE_TIMEPROBE_SINGLETON::instance ()->reset ()
00156 #  define ACE_TIMEPROBE(id) ACE_TIMEPROBE_SINGLETON::instance ()->timeprobe (id)
00157 #  define ACE_TIMEPROBE_PRINT ACE_TIMEPROBE_SINGLETON::instance ()->print_times ()
00158 #  define ACE_TIMEPROBE_PRINT_ABSOLUTE ACE_TIMEPROBE_SINGLETON::instance ()->print_absolute_times ()
00159 #  define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id) static int ace_timeprobe_##descriptions##_return = ACE_TIMEPROBE_SINGLETON::instance ()->event_descriptions (descriptions, minimum_id)
00160 #  define ACE_FUNCTION_TIMEPROBE(X) ACE_Function_Timeprobe<ACE_TIMEPROBE_WITH_LOCKING> function_timeprobe (*ACE_TIMEPROBE_SINGLETON::instance (), X)
00161 
00162 #else /* ACE_ENABLE_TIMEPROBES && ACE_COMPILE_TIMEPROBES */
00163 
00164 #  define ACE_TIMEPROBE_RESET
00165 #  define ACE_TIMEPROBE(id)
00166 #  define ACE_TIMEPROBE_PRINT
00167 #  define ACE_TIMEPROBE_PRINT_ABSOLUTE
00168 #  define ACE_TIMEPROBE_EVENT_DESCRIPTIONS(descriptions, minimum_id)
00169 #  define ACE_FUNCTION_TIMEPROBE(X)
00170 
00171 #endif /* ACE_ENABLE_TIMEPROBES && ACE_COMPILE_TIMEPROBES */
00172 #include "ace/post.h"
00173 #endif /* ACE_TIMEPROBE_H */

Generated on Mon Jun 16 11:21:48 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002