32#include "reusex/core/stages.hpp"
33#include "reusex/pipeline/job_types.hpp"
34#include "reusex/pipeline/stages.hpp"
104 const std::filesystem::path &
project() const noexcept;
124 std::optional<JobRecord>
job(std::string_view
id)
const;
130 std::vector<JobRecord>
jobs()
const;
171 std::unique_ptr<Impl> impl_;
size_t queued_count() const
Number of jobs still waiting to start.
std::string submit(JobStage stage, std::string parameters={})
Enqueue a stage run.
bool is_busy() const
True while a job is executing.
size_t add_listener(JobListener listener)
Register a listener. Returns a token for remove_listener().
void wait_idle()
Block until the queue is empty and no job is running.
JobRunner(const JobRunner &)=delete
JobRunner(std::filesystem::path project, StageExecutor executor, JobRunnerOptions options)
As above, with an explicit job-store policy.
const std::filesystem::path & project() const noexcept
The project every job of this runner targets.
~JobRunner()
Requests cancellation of anything in flight and joins the worker.
std::vector< JobRecord > jobs() const
Snapshot of every retained job, most recently submitted first.
void remove_listener(size_t token)
Unregister a listener. Safe to call with an unknown token.
JobRunner(std::filesystem::path project, StageExecutor executor=default_stage_executor())
WriterLease try_acquire_writer(std::chrono::milliseconds timeout)
Try to take the project's exclusive writer lock, giving up after timeout.
bool cancel(std::string_view id)
Request cancellation.
std::optional< JobRecord > job(std::string_view id) const
Snapshot of one job, or nullopt if the id is unknown or evicted.
JobRunner & operator=(const JobRunner &)=delete
std::function< void(const JobEvent &)> JobListener
Listener callback.
JobStage
A pipeline stage that can be executed as a job.
StageExecutor default_stage_executor()
The executor that actually runs the pipeline (a thin wrap of run_stage).
std::function< StageResult(const StageContext &)> StageExecutor
Stage execution strategy.
std::unique_lock< std::timed_mutex > WriterLease
Exclusive right to write to a runner's project.
Tuning knobs for the job store.
size_t max_terminal_jobs
Terminal (succeeded/failed/cancelled) jobs retained before the oldest are dropped.