LogCabin
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Namespaces | Functions | Variables
LogCabin::Core::ThreadId Namespace Reference

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.

Detailed Description

Provides a convenient way to get identifiers for threads.

This is better than std::this_thread::get_id() in a few ways:


Function Documentation

Return a unique identifier associated with this thread.

Returns a unique identifier for the current thread.

The return value has two properties:

  • It will never be zero.
  • It will be unique for this thread (i.e., no other thread has ever been returned this value or ever will be returned this value)

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.

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.


Variable Documentation

A thread ID that will never be assigned to any thread.

Definition at line 37 of file ThreadId.h.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines