LogCabin
|
Provides a convenient way to get identifiers for threads. More...
Namespaces | |
namespace | Internal |
Functions | |
uint64_t | getId () |
Return a unique identifier associated with this thread. | |
void | setName (const std::string &name) |
Set the friendly name for the current thread. | |
std::string | getName () |
Get the friendly name for the current thread. | |
Variables | |
const uint64_t | NONE |
A thread ID that will never be assigned to any thread. |
Provides a convenient way to get identifiers for threads.
This is better than std::this_thread::get_id() in a few ways:
uint64_t LogCabin::Core::ThreadId::getId | ( | ) |
Return a unique identifier associated with this thread.
Returns a unique identifier for the current thread.
The return value has two properties:
Definition at line 72 of file ThreadId.cc.
void LogCabin::Core::ThreadId::setName | ( | const std::string & | name | ) |
Set the friendly name for the current thread.
This can be later retrieved with getName(). Calling setName with an empty string will reset the thread to its default name.
Definition at line 80 of file ThreadId.cc.
std::string LogCabin::Core::ThreadId::getName | ( | ) |
Get the friendly name for the current thread.
This is useful in messages to users.
You should arrange for setName() to be called when the thread is created; otherwise you'll see an unhelpful name like "thread 3".
Definition at line 92 of file ThreadId.cc.
const uint64_t LogCabin::Core::ThreadId::NONE |
A thread ID that will never be assigned to any thread.
Definition at line 37 of file ThreadId.h.