ReUseX  0.0.5
3D Point Cloud Processing for Building Reuse
Loading...
Searching...
No Matches
reusex::pipeline::JobQueue Class Reference

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.

Detailed Description

One project's jobs on a JobScheduler. Every member is thread-safe.

Definition at line 93 of file JobScheduler.hpp.

Constructor & Destructor Documentation

◆ ~JobQueue()

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.

◆ JobQueue()

reusex::pipeline::JobQueue::JobQueue ( const JobQueue & )
delete

References JobQueue().

Referenced by JobQueue(), and operator=().

Member Function Documentation

◆ add_listener()

std::size_t reusex::pipeline::JobQueue::add_listener ( JobListener listener)

Register a listener for this queue's events. Returns a removal token.

◆ cancel()

bool reusex::pipeline::JobQueue::cancel ( std::string_view id)

Request cancellation (queued: cancelled now; running: cancel token set; terminal: no-op).

Returns
false if this queue has no such job.

◆ has_work()

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.

◆ is_busy()

bool reusex::pipeline::JobQueue::is_busy ( ) const

True while one of this queue's jobs is executing.

◆ job()

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.

◆ jobs()

std::vector< JobRecord > reusex::pipeline::JobQueue::jobs ( ) const

Every retained job of this queue, most recently submitted first.

◆ key()

const std::string & reusex::pipeline::JobQueue::key ( ) const
noexcept

◆ operator=()

JobQueue & reusex::pipeline::JobQueue::operator= ( const JobQueue & )
delete

References JobQueue().

◆ project()

const std::filesystem::path & reusex::pipeline::JobQueue::project ( ) const
noexcept

References project().

Referenced by project().

◆ queued_count()

std::size_t reusex::pipeline::JobQueue::queued_count ( ) const

Jobs of this queue still waiting to start.

◆ remove_listener()

void reusex::pipeline::JobQueue::remove_listener ( std::size_t token)

◆ submit()

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
parametersJSON object string; "" means "stage defaults".
submitted_byWho asked for it (JobRecord::submitted_by); "" when nobody in particular did (the CLI, local mode).
Exceptions
std::runtime_errorif parameters is not a JSON object, or the queue or its scheduler is shutting down.

References submit().

Referenced by submit().

◆ try_acquire_writer()

WriterLease reusex::pipeline::JobQueue::try_acquire_writer ( std::chrono::milliseconds timeout)
nodiscard

Try to take the project's exclusive writer lock (see JobRunner).

◆ wait_idle()

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.

◆ JobScheduler

friend class JobScheduler
friend

Implementation detail.

Definition at line 153 of file JobScheduler.hpp.

References JobScheduler.

Referenced by JobScheduler.


The documentation for this class was generated from the following file: