Engine → Core → dedicated_thread.h
jobs::dedicated_thread
| Type | Class |
| Namespace | conjure::core::jobs |
| Include File Path | engine/include/conjure/core/jobs/dedicated_thread.h |
| Source File Path | engine/src/core/jobs/dedicated_thread.cpp |
| API ↗ | Jobs and threading |
Syntax
Constructors
| Access | Signature | Description |
|---|---|---|
| public | dedicated_thread(
std::string name,
std::function<void(std::stop_token)> body); | Starts the thread immediately. The name is applied to the OS thread (truncated on a code point boundary to 15 bytes on Linux and macOS and 63 UTF-16 units on Windows). An empty body asserts and leaves the object non-joinable. If the operating system refuses to create the thread, the std::system_error that std::jthread throws is not caught (engine code never catches) and ends the process like an allocation failure. |
| public | dedicated_thread(
dedicated_thread &&) noexcept = default; |
Important
Additional constructor overloads have been deleted.
Destructors
| Access | Signature | Description |
|---|---|---|
| public | ~dedicated_thread(); | Requests a stop and joins when the thread is still running. |
Variables
| Access | Name | Type | Default | Description |
|---|---|---|---|---|
| private | mName | std::string | {} | |
| private | mThread | std::jthread | {} |
Functions
Public
get_id
get_id[[nodiscard]] std::thread::id get_id() const noexcept;Identifier of the underlying thread; default-constructed when not joinable.
join
joinvoid join();Waits for the body to return. Does not request a stop; no-op when not joinable.
joinable
joinable[[nodiscard]] bool joinable() const noexcept;True while the thread has been started and not yet joined.
name
name[[nodiscard]] const std::string &name() const noexcept;The name given at construction.
request_stop
request_stopvoid request_stop() noexcept;Signals the body's stop token. Does not wait.
stop_requested
stop_requested[[nodiscard]] bool stop_requested() const noexcept;True once request_stop() has been called (or the destructor has started).
Operator Overloads
Public
operator=
operator=dedicated_thread &operator=(
dedicated_thread &&) noexcept = default;