33 class PStatClientImpl;
59 void set_client_name(
const std::string &name);
60 std::string get_client_name()
const;
61 void set_max_rate(
double rate);
62 double get_max_rate()
const;
64 INLINE
int get_num_collectors()
const;
66 MAKE_SEQ(get_collectors, get_num_collectors, get_collector);
68 std::string get_collector_name(
int index)
const;
69 std::string get_collector_fullname(
int index)
const;
71 INLINE
int get_num_threads()
const;
73 MAKE_SEQ(get_threads, get_num_threads, get_thread);
74 INLINE std::string get_thread_name(
int index)
const;
75 INLINE std::string get_thread_sync_name(
int index)
const;
76 INLINE PT(
Thread) get_thread_object(
int index)
const;
81 double get_real_time()
const;
83 MAKE_PROPERTY(client_name, get_client_name, set_client_name);
84 MAKE_PROPERTY(max_rate, get_max_rate, set_max_rate);
85 MAKE_SEQ_PROPERTY(collectors, get_num_collectors, get_collector);
86 MAKE_SEQ_PROPERTY(threads, get_num_threads, get_thread);
87 MAKE_PROPERTY(main_thread, get_main_thread);
88 MAKE_PROPERTY(current_thread, get_current_thread);
89 MAKE_PROPERTY(real_time, get_real_time);
91 INLINE
static bool connect(
const std::string &hostname = std::string(),
int port = -1);
92 INLINE
static void disconnect();
95 INLINE
static void resume_after_pause();
97 static void main_tick();
98 static void thread_tick(
const std::string &sync_name);
100 void client_main_tick();
101 void client_thread_tick(
const std::string &sync_name);
102 bool client_connect(std::string hostname,
int port);
103 void client_disconnect();
104 bool client_is_connected()
const;
106 void client_resume_after_pause();
111 INLINE
bool has_impl()
const;
112 INLINE PStatClientImpl *get_impl();
113 INLINE
const PStatClientImpl *get_impl()
const;
114 void make_impl()
const;
116 PStatCollector make_collector_with_relname(
int parent_index, std::string relname);
117 PStatCollector make_collector_with_name(
int parent_index,
const std::string &name);
121 PStatThread make_gpu_thread(
const std::string &name);
123 bool is_active(
int collector_index,
int thread_index)
const;
124 bool is_started(
int collector_index,
int thread_index)
const;
126 void start(
int collector_index,
int thread_index);
127 void start(
int collector_index,
int thread_index,
double as_of);
128 void stop(
int collector_index,
int thread_index);
129 void stop(
int collector_index,
int thread_index,
double as_of);
131 void clear_level(
int collector_index,
int thread_index);
132 void set_level(
int collector_index,
int thread_index,
double level);
133 void add_level(
int collector_index,
int thread_index,
double increment);
134 double get_level(
int collector_index,
int thread_index)
const;
136 static void start_clock_wait();
137 static void start_clock_busy_wait();
138 static void stop_clock_wait();
141 class InternalThread;
142 void add_collector(Collector *collector);
143 void add_thread(InternalThread *thread);
145 INLINE Collector *get_collector_ptr(
int collector_index)
const;
146 INLINE InternalThread *get_thread_ptr(
int thread_index)
const;
157 MultiThingsByName _threads_by_name, _threads_by_sync_name;
161 class PerThreadData {
172 class EXPCL_PANDA_PSTATCLIENT Collector {
174 INLINE Collector(
int parent_index,
const std::string &name);
175 INLINE
int get_parent_index()
const;
176 INLINE
const std::string &get_name()
const;
177 INLINE
bool is_active()
const;
181 void make_def(
const PStatClient *client,
int this_index);
194 ThingsByName _children;
195 PerThread _per_thread;
197 typedef Collector *CollectorPointer;
198 AtomicAdjust::Pointer _collectors;
199 AtomicAdjust::Integer _collectors_size;
200 AtomicAdjust::Integer _num_collectors;
205 class InternalThread {
207 InternalThread(
Thread *thread);
208 InternalThread(
const std::string &name,
const std::string &sync_name =
"Main");
212 std::string _sync_name;
226 typedef InternalThread *ThreadPointer;
227 AtomicAdjust::Pointer _threads;
228 AtomicAdjust::Integer _threads_size;
229 AtomicAdjust::Integer _num_threads;
231 mutable PStatClientImpl *_impl;
252 friend class Collector;
255 friend class PStatClientImpl;
268 void set_client_name(
const std::string &name);
269 std::string get_client_name()
const;
270 void set_max_rate(
double rate);
271 double get_max_rate()
const;
274 std::string get_collector_name(
int index)
const;
275 std::string get_collector_fullname(
int index)
const;
277 INLINE
int get_num_threads()
const {
return 0; }
279 INLINE std::string get_thread_name(
int index)
const {
return ""; }
280 INLINE std::string get_thread_sync_name(
int index)
const {
return ""; }
281 INLINE PT(
Thread) get_thread_object(
int index)
const {
return nullptr; }
286 double get_real_time()
const;
289 INLINE
static bool connect(
const std::string & = std::string(),
int = -1) {
return false; }
290 INLINE
static void disconnect() { }
292 INLINE
static void resume_after_pause() { }
294 static void main_tick();
295 static void thread_tick(
const std::string &);
298 void client_main_tick();
299 void client_thread_tick(
const std::string &sync_name);
300 bool client_connect(std::string hostname,
int port);
301 void client_disconnect();
302 bool client_is_connected()
const;
304 void client_resume_after_pause();
311 PStatCollector make_collector_with_relname(
int parent_index, std::string relname);
314 bool is_active(
int collector_index,
int thread_index)
const;
315 bool is_started(
int collector_index,
int thread_index)
const;
317 void start(
int collector_index,
int thread_index);
318 void start(
int collector_index,
int thread_index,
double as_of);
319 void stop(
int collector_index,
int thread_index);
320 void stop(
int collector_index,
int thread_index,
double as_of);
322 void clear_level(
int collector_index,
int thread_index);
323 void set_level(
int collector_index,
int thread_index,
double level);
324 void add_level(
int collector_index,
int thread_index,
double increment);
325 double get_level(
int collector_index,
int thread_index)
const;