|
ReUseX
0.0.5
3D Point Cloud Processing for Building Reuse
|
One project's jobs on a JobScheduler. Every member is thread-safe. More...
#include <JobScheduler.hpp>
Public Member Functions | |
| ~JobQueue () | |
| Closes the queue: queued jobs are reported cancelled, a running job is asked to stop, and the destructor waits until it has AND until every event already raised has reached the listeners — so an object owning the queue may destroy it and then its listener's captures safely. | |
| JobQueue (const JobQueue &)=delete | |
| JobQueue & | operator= (const JobQueue &)=delete |
| const std::string & | key () const noexcept |
| const std::filesystem::path & | project () const noexcept |
| std::string | submit (JobStage stage, std::string parameters={}, std::string submitted_by={}) |
| Enqueue a stage run. | |
| bool | cancel (std::string_view id) |
| Request cancellation (queued: cancelled now; running: cancel token set; terminal: no-op). | |
| std::optional< JobRecord > | job (std::string_view id) const |
| Snapshot of one of this queue's jobs, or nullopt if unknown or evicted. | |
| std::vector< JobRecord > | jobs () const |
| Every retained job of this queue, most recently submitted first. | |
| std::size_t | queued_count () const |
| Jobs of this queue still waiting to start. | |
| bool | is_busy () const |
| True while one of this queue's jobs is executing. | |
| bool | has_work () const |
| True while a job is queued or running, or an event is still being delivered to the listeners — read under ONE lock, so a job moving from queued to running can never make it read false. | |
| void | wait_idle () |
| Block until this queue has nothing queued, nothing running and every event delivered. | |
| WriterLease | try_acquire_writer (std::chrono::milliseconds timeout) |
| Try to take the project's exclusive writer lock (see JobRunner). | |
| std::size_t | add_listener (JobListener listener) |
| Register a listener for this queue's events. Returns a removal token. | |
| void | remove_listener (std::size_t token) |
Friends | |
| class | JobScheduler |
| Implementation detail. | |
One project's jobs on a JobScheduler. Every member is thread-safe.
Definition at line 93 of file JobScheduler.hpp.
| reusex::pipeline::JobQueue::~JobQueue | ( | ) |
Closes the queue: queued jobs are reported cancelled, a running job is asked to stop, and the destructor waits until it has AND until every event already raised has reached the listeners — so an object owning the queue may destroy it and then its listener's captures safely.
Must not run on a thread that is inside one of this queue's listeners.
|
delete |
References JobQueue().
Referenced by JobQueue(), and operator=().
| std::size_t reusex::pipeline::JobQueue::add_listener | ( | JobListener | listener | ) |
Register a listener for this queue's events. Returns a removal token.
| bool reusex::pipeline::JobQueue::cancel | ( | std::string_view | id | ) |
Request cancellation (queued: cancelled now; running: cancel token set; terminal: no-op).
| bool reusex::pipeline::JobQueue::has_work | ( | ) | const |
True while a job is queued or running, or an event is still being delivered to the listeners — read under ONE lock, so a job moving from queued to running can never make it read false.
| bool reusex::pipeline::JobQueue::is_busy | ( | ) | const |
True while one of this queue's jobs is executing.
| std::optional< JobRecord > reusex::pipeline::JobQueue::job | ( | std::string_view | id | ) | const |
Snapshot of one of this queue's jobs, or nullopt if unknown or evicted.
| std::vector< JobRecord > reusex::pipeline::JobQueue::jobs | ( | ) | const |
Every retained job of this queue, most recently submitted first.
|
noexcept |
References JobQueue().
|
noexcept |
| std::size_t reusex::pipeline::JobQueue::queued_count | ( | ) | const |
Jobs of this queue still waiting to start.
| void reusex::pipeline::JobQueue::remove_listener | ( | std::size_t | token | ) |
| std::string reusex::pipeline::JobQueue::submit | ( | JobStage | stage, |
| std::string | parameters = {}, | ||
| std::string | submitted_by = {} ) |
Enqueue a stage run.
Returns the new job id.
| parameters | JSON object string; "" means "stage defaults". |
| submitted_by | Who asked for it (JobRecord::submitted_by); "" when nobody in particular did (the CLI, local mode). |
| std::runtime_error | if parameters is not a JSON object, or the queue or its scheduler is shutting down. |
References submit().
Referenced by submit().
|
nodiscard |
Try to take the project's exclusive writer lock (see JobRunner).
| void reusex::pipeline::JobQueue::wait_idle | ( | ) |
Block until this queue has nothing queued, nothing running and every event delivered.
Do not call it from a listener.
|
friend |
Implementation detail.
Definition at line 153 of file JobScheduler.hpp.
References JobScheduler.
Referenced by JobScheduler.