Zrythm
v2.0.0-DEV
a highly automated and intuitive digital audio workstation
Loading...
Searching...
No Matches
rt_thread_id.h
1
// SPDX-FileCopyrightText: © 2024 Alexandros Theodotou <alex@zrythm.org>
2
// SPDX-License-Identifier: LicenseRef-ZrythmLicense
3
4
#pragma once
5
6
#include <atomic>
7
14
class
RTThreadId
15
{
16
private
:
17
// Atomic counter for generating unique IDs
18
static
std::atomic<unsigned int> next_id;
19
20
// The unique ID for this thread
21
unsigned
int
id;
22
23
public
:
24
RTThreadId ();
25
26
using
IdType =
unsigned
int;
27
28
[[nodiscard]] IdType get ()
const
;
29
bool
operator== (
const
RTThreadId &other)
const
;
30
bool
operator!= (
const
RTThreadId &other)
const
;
31
};
32
33
// Thread-local instance for easy access to the current thread's ID
34
extern
thread_local
RTThreadId
current_thread_id;
RTThreadId
Real-time safe thread identifier.
Definition
rt_thread_id.h:15
src
utils
rt_thread_id.h
Generated by
1.15.0