MIRA
|
A thread monitor class. More...
#include <thread/ThreadMonitor.h>
Classes | |
struct | BasicThreadIdentity |
Serializable thread id. More... | |
struct | ThreadIdentity |
Extend basic thread id by boost thread id (not serializable). More... | |
struct | ThreadInfoBase |
Runtime thread info. More... | |
struct | ThreadInfoTempl |
Combine thread identity (template param) and runtime info. More... | |
Public Types | |
typedef Base::Type | Type |
Public Member Functions | |
Constructor and destructor | |
ThreadMonitor () | |
Default constructor. More... | |
virtual | ~ThreadMonitor () |
The destructor. More... | |
Add and remove threads. | |
void | addThisThread (const std::string &pName) |
Add the calling thread to the thread monitor. More... | |
void | removeThisThread () |
Remove the calling thread from the monitor. More... | |
void | removeThread (const boost::thread &pThread) |
Remove a thread from the monitor. More... | |
void | removeThread (const boost::thread::id &pThreadID) |
Remove a thread from the monitor. More... | |
void | removeThread (ThreadID pThreadID) |
Remove a thread from the monitor. More... | |
Static Public Member Functions | |
static Type & | instance () |
Returns a reference to the singleton instance. More... | |
static bool | isDestroyed () |
Returns true, if the singleton was already destroyed. More... | |
Static Protected Member Functions | |
static Type * | makeInstance () |
static void | destroyInstance (void) |
Thread information | |
using | BasicThreadInfo = ThreadInfoTempl< BasicThreadIdentity > |
Basic (serializable) thread info. More... | |
using | BasicThreadInfoVector = std::vector< BasicThreadInfo > |
Vector of serializable thread info. More... | |
using | ThreadInfo = ThreadInfoTempl< ThreadIdentity > |
Thread info including local thread id data. More... | |
using | ThreadInfoVector = std::vector< ThreadInfo > |
Vector of local id thread data. More... | |
ThreadInfoVector | getThreadInformation () |
Collect information about all threads of the current process. More... | |
BasicThreadInfoVector | getBasicThreadInformation () |
Collect basic (serializable) information about all threads of the current process. More... | |
A thread monitor class.
A thread monitor, which collects information about the resources of all running threads.
To add a new thread to the monitor, the method addThisThread must be called within the created thread. To remove a thread, the method removeThisThread or removeThread should be called. If a thread is stopped without calling removeThisThread first, it will be automatically removed from the internal thread list when getThreadInformation() is called.
The method getThreadInformation returns a vector of all threads of the current process (not only the threads which are added using addThisThread). For each thread, the creation time and the used CPU time in user mode and kernel mode are determined. For threads which were added using addThisThread, the registered name is included in the returned data.
The method getBasicThreadInformation can be used to query only the serializable subset of thread information (i.e. excluding some internal thread reference data).
Example:
Basic (serializable) thread info.
using BasicThreadInfoVector = std::vector<BasicThreadInfo> |
Vector of serializable thread info.
using ThreadInfo = ThreadInfoTempl<ThreadIdentity> |
Thread info including local thread id data.
using ThreadInfoVector = std::vector<ThreadInfo> |
Vector of local id thread data.
|
inherited |
ThreadMonitor | ( | ) |
Default constructor.
|
virtual |
The destructor.
void addThisThread | ( | const std::string & | pName | ) |
Add the calling thread to the thread monitor.
[in] | pName | The name of the thread. |
void removeThisThread | ( | ) |
Remove the calling thread from the monitor.
void removeThread | ( | const boost::thread & | pThread | ) |
Remove a thread from the monitor.
[in] | pThread | The thread, which should be removed. |
void removeThread | ( | const boost::thread::id & | pThreadID | ) |
Remove a thread from the monitor.
[in] | pThreadID | The boost thread ID. |
void removeThread | ( | ThreadID | pThreadID | ) |
Remove a thread from the monitor.
[in] | pThreadID | The native thread ID. |
ThreadInfoVector getThreadInformation | ( | ) |
Collect information about all threads of the current process.
BasicThreadInfoVector getBasicThreadInformation | ( | ) |
Collect basic (serializable) information about all threads of the current process.
|
inlinestaticinherited |
Returns a reference to the singleton instance.
XSingleton | If the singleton was already destroyed (dead reference) or not yet created (when using ExplicitInstantiation). |
|
inlinestaticinherited |
Returns true, if the singleton was already destroyed.
Trying to access it will result in an exception.
|
inlinestaticprotectedinherited |
|
inlinestaticprotectedinherited |