Provides concurrency primitives and abstractions for multithreaded programming. It features the powerful message_manager
class for managing asynchronous message queues with flexible ordering (FIFO, FILO, or RANDOM), as well as threaded_object
, which uses CRTP to encapsulate worker-thread logic with built-in synchronization. These classes simplify threaded operations, interprocess synchronization, and message dispatch under varying concurrency scenarios.
More...
Provides concurrency primitives and abstractions for multithreaded programming. It features the powerful message_manager
class for managing asynchronous message queues with flexible ordering (FIFO, FILO, or RANDOM), as well as threaded_object
, which uses CRTP to encapsulate worker-thread logic with built-in synchronization. These classes simplify threaded operations, interprocess synchronization, and message dispatch under varying concurrency scenarios.
◆ process_id_type
Defines a platform-independent type for process identifiers.
On Windows, this is defined as DWORD, representing the native process ID type. On Unix-based systems (Linux, macOS), this is defined as pid_t, the standard type for process IDs.
◆ thread_id_type
◆ THREADNAME_INFO
◆ get_current_process_id()
Retrieves the current process's identifier in a platform-independent manner.
On Windows, this function wraps the GetCurrentProcessId() call. On Unix-based systems, it calls getpid().
- Returns
- process_id_type The unique identifier of the current process.
◆ get_current_thread_id()
Retrieves the current thread's native identifier.
On Windows, the returned identifier is a HANDLE
to the current thread. On other platforms, this is a pthread_t
.
- Returns
- thread_id_type The native identifier of the current thread.
◆ get_max_shm_name_length()
std::size_t cbeam::concurrency::get_max_shm_name_length |
( |
| ) |
|
|
inline |
◆ get_thread_name()
Retrieves the name of the specified thread.
- Parameters
-
- Returns
- std::wstring The name of the thread, or an empty string if not available or on failure.
◆ set_thread_name() [1/3]
void cbeam::concurrency::set_thread_name |
( |
const char * | thread_name | ) |
|
|
inline |
Sets the name of the current thread.
- Parameters
-
thread_name | The name to set for the current thread. |
◆ set_thread_name() [2/3]
void cbeam::concurrency::set_thread_name |
( |
std::thread & | thread, |
|
|
const char * | thread_name ) |
|
inline |
Sets the name of a std::thread
on Windows.
- Parameters
-
thread | The std::thread object whose name is to be set. |
thread_name | The name to assign to that thread. |
◆ set_thread_name() [3/3]
void cbeam::concurrency::set_thread_name |
( |
uint32_t | dwThreadID, |
|
|
const char * | thread_name ) |
|
inline |
Sets the name for a thread with a specified Thread ID.
This Windows-specific function uses a debugger exception mechanism to associate a name with a thread in debugging tools like Visual Studio.
- Parameters
-
dwThreadID | The numeric thread ID. |
thread_name | The name to set for the thread. |
◆ to_string()
Returns a hexadecimal string representation of the given thread ID.
- Parameters
-
id | The thread identifier. |
mask | A bitmask to apply to the thread ID before conversion. May be used to achieve a shortened string representation. Defaults to all bits set. |
- Returns
- std::wstring The hexadecimal string representation of the thread ID.