Panda3D
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  */
18 INLINE PStatThread::
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  */
26 INLINE PStatThread::
27 PStatThread(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  */
37 INLINE PStatThread::
38 PStatThread(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  */
62 INLINE PStatThread::
63 PStatThread(const PStatThread &copy) :
64  _client(copy._client),
65  _index(copy._index)
66 {
67 }
68 
69 /**
70  *
71  */
72 INLINE void PStatThread::
73 operator = (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  */
81 INLINE int PStatThread::
82 get_index() const {
83  return _index;
84 }
PStatThread()
Normally, this constructor is called only from PStatClient.
Definition: pStatThread.I:19
A lightweight class that represents a single thread of execution to PStats.
Definition: pStatThread.h:28
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
Manages the communications to report statistics via a network connection to a remote PStatServer.
Definition: pStatClient.h:263