Why: Threads#

class Thread#

Thread class with priority scheduling.

The Thread class provides thread creation and management with support for priority scheduling and move semantics.

Public Types

enum class Priority#

Thread priority levels.

Values:

enumerator None#

No specific priority.

enumerator Low#

Low priority.

enumerator Medium#

Medium priority.

enumerator Highest#

Highest priority.

Public Functions

Thread(std::function<void()>, Priority prio = Priority::None)#

Constructor.

Parameters:
  • func – The function to execute in the new thread

  • prio – The priority level for the thread (default: Priority::None)

~Thread()#

Destructor.

Thread(const Thread&) = delete#

Copy constructor (deleted - threads cannot be copied).

Thread &operator=(const Thread&) = delete#

Copy assignment operator (deleted - threads cannot be copied).

Thread(Thread &&other)#

Move constructor.

Parameters:

other – The thread to move from

Thread &operator=(Thread &&other)#

Move assignment operator.

Parameters:

other – The thread to move from

Returns:

Reference to this thread

Priority priority() const#

Get the thread’s priority level.

Returns:

The current priority of the thread

std::string_view prioritystr() const#

Get the thread’s priority as a string.

Returns:

String representation of the thread’s priority

Public Static Functions

static Thread self()#

Get a Thread object representing the current thread.

Returns:

Thread object for the calling thread

static void init()#

Initialize the threading subsystem.

static void deinit()#

Deinitialize the threading subsystem.