57 typename = std::enable_if_t<std::is_invocable_r_v<R, F>>>
58 explicit future_job(F&& callable,
const std::string& name =
"future_job")
87 [[nodiscard]]
auto do_work() -> common::VoidResult
override {
91 std::make_exception_ptr(
92 std::runtime_error(
"Job cancelled before execution")
99 if constexpr (std::is_void_v<R>) {
106 promise_->set_exception(std::current_exception());
109 "Exception thrown during job execution"
bool is_cancelled() const
Checks if the token has been canceled.
A job that wraps a callable and provides a future for its result.
auto get_future() -> std::future< R >
Get the future associated with this job.
std::shared_ptr< std::promise< R > > promise_
future_job(F &&callable, const std::string &name="future_job")
Constructs a future_job from a callable.
std::function< R()> callable_
auto do_work() -> common::VoidResult override
Executes the callable and sets the promise value.
Represents a unit of work (task) to be executed, typically by a job queue.
cancellation_token cancellation_token_
The cancellation token associated with this job.
Error codes and utilities for the thread system.
Base job class for schedulable work units in the thread system.
Core threading foundation of the thread system library.
common::VoidResult make_error_result(error_code code, const std::string &message="")
Create a common::VoidResult error from a thread::error_code.