Panda3D
 All Classes Functions Variables Enumerations
pStatTimer.h
1 // Filename: pStatTimer.h
2 // Created by: drose (11Jul00)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef PSTATTIMER_H
16 #define PSTATTIMER_H
17 
18 #include "pandabase.h"
19 
20 #include "pStatCollector.h"
21 
22 class Thread;
23 
24 ////////////////////////////////////////////////////////////////////
25 // Class : PStatTimer
26 // Description : A lightweight class that can be used to automatically
27 // start and stop a PStatCollector around a section of
28 // code. It's intended to be used in the following way:
29 // create a local PStatTimer variable to start the
30 // Collector, and when the PStatTimer variable goes out
31 // of scope (for instance, at the end of the function),
32 // it will automatically stop the Collector.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDA_PSTATCLIENT PStatTimer {
35 public:
36 #ifdef DO_PSTATS
37  INLINE PStatTimer(PStatCollector &collector);
38  INLINE PStatTimer(PStatCollector &collector, Thread *current_thread);
39  INLINE ~PStatTimer();
40 
41 protected:
42  PStatCollector &_collector;
43  PStatThread _thread;
44 #else // DO_PSTATS
45 
46  INLINE PStatTimer(PStatCollector &) { }
47  INLINE PStatTimer(PStatCollector &, Thread *) { }
48  INLINE ~PStatTimer() { }
49 
50 #endif // DO_PSTATS
51 };
52 
53 #include "pStatTimer.I"
54 
55 #endif
56 
A lightweight class that can be used to automatically start and stop a PStatCollector around a sectio...
Definition: pStatTimer.h:34
A lightweight class that represents a single element that may be timed and/or counted via stats...
A lightweight class that represents a single thread of execution to PStats.
Definition: pStatThread.h:31
A thread; that is, a lightweight process.
Definition: thread.h:51