17 work_func_ = std::move(callable);
25 dependencies_.push_back(dependency);
32 for (
const auto& dep : dependencies)
36 dependencies_.push_back(dep);
44 for (
const auto& dep : dependencies)
48 dependencies_.push_back(dep);
56 fallback_func_ = std::move(
fallback);
69 return "No work function specified. Use work() or work_with_result() before build().";
82 auto job = std::make_unique<dag_job>(name_);
85 job->add_dependencies(dependencies_);
88 if (work_with_result_func_)
91 auto result_func = std::move(work_with_result_func_);
92 job->set_work([j =
job.get(), func = std::move(result_func)]() -> common::VoidResult {
98 job->set_work(std::move(work_func_));
104 job->set_fallback(std::move(fallback_func_));
115 work_func_ =
nullptr;
116 work_with_result_func_ =
nullptr;
117 fallback_func_ =
nullptr;
118 dependencies_.clear();
119 has_return_type_ =
false;
Fluent builder for creating dag_job instances.
auto on_failure(std::function< common::VoidResult()> fallback) -> dag_job_builder &
Sets the fallback function for failure recovery.
auto reset() -> dag_job_builder &
Resets the builder to its initial state.
auto build() -> std::unique_ptr< dag_job >
Builds and returns the configured dag_job.
auto is_valid() const -> bool
Validates the builder configuration.
auto get_validation_error() const -> std::optional< std::string >
Gets the validation error message.
std::function< common::VoidResult(dag_job &)> work_with_result_func_
dag_job_builder(const std::string &name="dag_job")
Constructs a new builder with an optional job name.
std::function< common::VoidResult()> work_func_
auto work(std::function< common::VoidResult()> callable) -> dag_job_builder &
Sets the work function to execute.
auto depends_on(job_id dependency) -> dag_job_builder &
Adds a single dependency.
Represents a unit of work (task) to be executed, typically by a job queue.
Fluent builder for creating dag_job instances with dependencies.
Core threading foundation of the thread system library.
std::uint64_t job_id
Unique job identifier for DAG scheduler.
constexpr job_id INVALID_JOB_ID
Invalid job ID constant.
@ fallback
Execute fallback job if available.