Panda3D
Loading...
Searching...
No Matches
pStatThread.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file pStatThread.I
10 * @author drose
11 * @date 2000-07-11
12 */
13
14/**
15 * Normally, this constructor is called only from PStatClient. Use one of the
16 * constructors below to create your own Thread.
17 */
20}
21
22/**
23 * Normally, this constructor is called only from PStatClient. Use one of the
24 * constructors below to create your own Thread.
25 */
27PStatThread(PStatClient *client, int index) :
28 _client(client),
29 _index(index)
30{
31}
32
33/**
34 * Creates a new named thread. This will be used to unify tasks that share a
35 * common thread, and differentiate tasks that occur in different threads.
36 */
38PStatThread(Thread *thread, PStatClient *client) {
39#ifdef DO_PSTATS
40 if (client == nullptr) {
41 client = PStatClient::get_global_pstats();
42 }
43
44 int thread_index = thread->get_pstats_index();
45 if (thread_index != -1) {
46 (*this) = PStatThread(client, thread_index);
47
48 } else {
49 // This is the first time we have encountered this current Thread. Make a
50 // new PStatThread object for it.
51 (*this) = client->make_thread(thread);
52 }
53#else
54 _client = nullptr;
55 _index = 0;
56#endif
57}
58
59/**
60 *
61 */
62INLINE PStatThread::
63PStatThread(const PStatThread &copy) :
64 _client(copy._client),
65 _index(copy._index)
66{
67}
68
69/**
70 *
71 */
72INLINE void PStatThread::
73operator = (const PStatThread &copy) {
74 _client = copy._client;
75 _index = copy._index;
76}
77
78/**
79 * Returns the index number of this particular thread within the PStatClient.
80 */
81INLINE int PStatThread::
82get_index() const {
83 return _index;
84}
85
86/**
87 *
88 */
89INLINE PStatClient *PStatThread::
90get_client() const {
91 return _client;
92}
Manages the communications to report statistics via a network connection to a remote PStatServer.
A lightweight class that represents a single thread of execution to PStats.
Definition pStatThread.h:28
get_index
Returns the index number of this particular thread within the PStatClient.
Definition pStatThread.h:46
PStatThread()
Normally, this constructor is called only from PStatClient.
Definition pStatThread.I:19
A thread; that is, a lightweight process.
Definition thread.h:46
get_pstats_index
Returns the PStats index associated with this thread, or -1 if no index has yet been associated with ...
Definition thread.h:102