18 #include "pandabase.h"
20 #include "pStatFrameData.h"
21 #include "pStatClientImpl.h"
22 #include "pStatCollectorDef.h"
24 #include "lightMutex.h"
25 #include "reMutexHolder.h"
26 #include "lightMutexHolder.h"
29 #include "weakPointerTo.h"
30 #include "vector_int.h"
31 #include "atomicAdjust.h"
32 #include "numeric_types.h"
64 INLINE
void set_client_name(
const string &name);
65 INLINE
string get_client_name()
const;
66 INLINE
void set_max_rate(
double rate);
67 INLINE
double get_max_rate()
const;
69 INLINE
int get_num_collectors()
const;
71 MAKE_SEQ(get_collectors, get_num_collectors, get_collector);
73 string get_collector_name(
int index)
const;
74 string get_collector_fullname(
int index)
const;
76 INLINE
int get_num_threads()
const;
78 MAKE_SEQ(get_threads, get_num_threads, get_thread);
79 INLINE
string get_thread_name(
int index)
const;
80 INLINE
string get_thread_sync_name(
int index)
const;
81 INLINE
Thread *get_thread_object(
int index)
const;
86 INLINE
double get_real_time()
const;
88 INLINE
static bool connect(
const string &hostname =
string(),
int port = -1);
89 INLINE
static void disconnect();
90 INLINE
static bool is_connected();
92 INLINE
static void resume_after_pause();
94 static void main_tick();
95 static void thread_tick(
const string &sync_name);
97 void client_main_tick();
98 void client_thread_tick(
const string &sync_name);
99 INLINE
bool client_connect(
string hostname,
int port);
100 void client_disconnect();
101 INLINE
bool client_is_connected()
const;
103 INLINE
void client_resume_after_pause();
108 INLINE
bool has_impl()
const;
109 INLINE PStatClientImpl *get_impl();
110 INLINE
const PStatClientImpl *get_impl()
const;
112 PStatCollector make_collector_with_relname(
int parent_index,
string relname);
113 PStatCollector make_collector_with_name(
int parent_index,
const string &name);
119 bool is_active(
int collector_index,
int thread_index)
const;
120 bool is_started(
int collector_index,
int thread_index)
const;
122 void start(
int collector_index,
int thread_index);
123 void start(
int collector_index,
int thread_index,
double as_of);
124 void stop(
int collector_index,
int thread_index);
125 void stop(
int collector_index,
int thread_index,
double as_of);
127 void clear_level(
int collector_index,
int thread_index);
128 void set_level(
int collector_index,
int thread_index,
double level);
129 void add_level(
int collector_index,
int thread_index,
double increment);
130 double get_level(
int collector_index,
int thread_index)
const;
132 static void start_clock_wait();
133 static void start_clock_busy_wait();
134 static void stop_clock_wait();
137 class InternalThread;
138 void add_collector(Collector *collector);
139 void add_thread(InternalThread *thread);
141 INLINE Collector *get_collector_ptr(
int collector_index)
const;
142 INLINE InternalThread *get_thread_ptr(
int thread_index)
const;
153 MultiThingsByName _threads_by_name, _threads_by_sync_name;
158 class PerThreadData {
171 INLINE Collector(
int parent_index,
const string &name);
172 INLINE
int get_parent_index()
const;
173 INLINE
const string &get_name()
const;
174 INLINE
bool is_active()
const;
178 void make_def(
const PStatClient *client,
int this_index);
192 ThingsByName _children;
193 PerThread _per_thread;
195 typedef Collector *CollectorPointer;
196 AtomicAdjust::Pointer _collectors;
197 AtomicAdjust::Integer _collectors_size;
198 AtomicAdjust::Integer _num_collectors;
203 class InternalThread {
205 InternalThread(
Thread *thread);
206 InternalThread(
const string &name,
const string &sync_name =
"Main");
224 typedef InternalThread *ThreadPointer;
229 PStatClientImpl *_impl;
250 friend class Collector;
253 friend class PStatClientImpl;
257 #include "pStatClient.I"
267 INLINE
static bool connect(
const string & =
string(),
int = -1) {
return false; }
272 INLINE
static void main_tick() { }
273 INLINE
static void thread_tick(
const string &) { }
static bool connect(const string &=string(), int=-1)
Attempts to establish a connection to the indicated PStatServer.
The primary interface to the low-level networking layer in this package.
static void resume_after_pause()
Resumes the PStatClient after the simulation has been paused for a while.
static void disconnect()
Closes the connection previously established.
static Thread * get_current_thread()
Returns a pointer to the currently-executing Thread object.
This is our own Panda specialization on the default STL vector.
A dynamic array with an unlimited number of bits.
static Thread * get_main_thread()
Returns a pointer to the "main" Thread object–this is the Thread that started the whole process...
virtual void activate_hook(Thread *thread)
Called when the thread is activated (resumes execution).
A lightweight class that represents a single element that may be timed and/or counted via stats...
A trivial implementation for atomic adjustments for systems that don't require multiprogramming, and therefore don't require special atomic operations.
Contains the raw timing and level data for a single frame.
bool is_started() const
Returns true if the thread has been started, false if it has not, or if join() has already been calle...
A lightweight class that represents a single thread of execution to PStats.
A thread; that is, a lightweight process.
Encapsulates all the communication with a particular instance of a given rendering backend...
static bool is_connected()
Returns true if the client believes it is connected to a working PStatServer, false otherwise...
Defines the details about the Collectors: the name, the suggested color, etc.
This is a standard, non-reentrant mutex, similar to the Mutex class.
Manages the communications to report statistics via a network connection to a remote PStatServer...
virtual void deactivate_hook(Thread *thread)
Called when the thread is deactivated (swapped for another running thread).
bool start(ThreadPriority priority, bool joinable)
Starts the thread executing.