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
Public Functions
-
~Thread()#
Destructor - cleans up thread resources.
-
Thread &operator=(const Thread&) = delete#
Copy assignment operator (deleted - threads cannot be copied)
-
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 std::expected<Thread, OSError> create(std::function<void()>, Priority prio = Priority::None)#
Create a new thread.
- Parameters:
func – The function to execute in the new thread
prio – The priority level for the thread (default: Priority::None)
- Returns:
std::expected containing the Thread object on success, or OSError on failure
-
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.
-
~Thread()#