FOSSredder 0.5.0
Loading...
Searching...
No Matches
core::jobs::JobManager Class Reference

#include <JobManager.h>

Public Member Functions

 JobManager (std::shared_ptr< core::ports::diagnostics::IErrorReporter > errorReporter)
 Create a manager for generic job state and event delivery.
JobId submit (JobKind kind)
 Create a tracked job in the pending state.
SubscriptionId subscribe (const JobId &id, JobEventCallback cb)
 Subscribe to events for a job.
void unsubscribe (const JobId &id, SubscriptionId subId)
 Remove a job event subscription.
void cancel (const JobId &id)
 Mark a job as canceled and set its cancellation flag.
void pause (const JobId &id)
 Mark a running job as paused and set its pause flag.
void resume (const JobId &id)
 Resume a paused job and clear its pause flag.
std::optional< JobSnapshot > snapshot (const JobId &id) const
 Retrieve the latest state snapshot for a job.
std::shared_ptr< std::atomic< bool > > cancelFlag (const JobId &id) const
 Retrieve a job cancellation flag.
std::shared_ptr< std::atomic< bool > > pauseFlag (const JobId &id) const
 Retrieve a job pause flag.
void publish (const JobEvent &ev)
 Publish an event to subscribers and update the stored snapshot.
void fail (const JobId &id, const std::string &error)
 Mark a job as failed.
void finish (const JobId &id)
 Mark a job as finished.
void start (const JobId &id)
 Mark a job as running.

Detailed Description

Definition at line 26 of file JobManager.h.

Constructor & Destructor Documentation

◆ JobManager()

core::jobs::JobManager::JobManager ( std::shared_ptr< core::ports::diagnostics::IErrorReporter > errorReporter)
explicit

Create a manager for generic job state and event delivery.

Parameters
errorReporterReporter used when callbacks or flag updates throw.

Definition at line 50 of file JobManager.cpp.

Member Function Documentation

◆ cancel()

void core::jobs::JobManager::cancel ( const JobId & id)

Mark a job as canceled and set its cancellation flag.

Parameters
idJob identifier.

Definition at line 108 of file JobManager.cpp.

Here is the call graph for this function:

◆ cancelFlag()

std::shared_ptr< std::atomic< bool > > core::jobs::JobManager::cancelFlag ( const JobId & id) const

Retrieve a job cancellation flag.

Parameters
idJob identifier.
Returns
Shared cancellation flag, or null when the job is unknown.

Definition at line 194 of file JobManager.cpp.

◆ fail()

void core::jobs::JobManager::fail ( const JobId & id,
const std::string & error )

Mark a job as failed.

Parameters
idJob identifier.
errorError message to store and publish.

Definition at line 317 of file JobManager.cpp.

Here is the call graph for this function:

◆ finish()

void core::jobs::JobManager::finish ( const JobId & id)

Mark a job as finished.

Parameters
idJob identifier.

Definition at line 253 of file JobManager.cpp.

Here is the call graph for this function:

◆ pause()

void core::jobs::JobManager::pause ( const JobId & id)

Mark a running job as paused and set its pause flag.

Parameters
idJob identifier.

Definition at line 133 of file JobManager.cpp.

Here is the call graph for this function:

◆ pauseFlag()

std::shared_ptr< std::atomic< bool > > core::jobs::JobManager::pauseFlag ( const JobId & id) const

Retrieve a job pause flag.

Parameters
idJob identifier.
Returns
Shared pause flag, or null when the job is unknown.

Definition at line 201 of file JobManager.cpp.

◆ publish()

void core::jobs::JobManager::publish ( const JobEvent & ev)

Publish an event to subscribers and update the stored snapshot.

Parameters
evEvent to publish.

Definition at line 208 of file JobManager.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ resume()

void core::jobs::JobManager::resume ( const JobId & id)

Resume a paused job and clear its pause flag.

Parameters
idJob identifier.

Definition at line 157 of file JobManager.cpp.

Here is the call graph for this function:

◆ snapshot()

std::optional< JobSnapshot > core::jobs::JobManager::snapshot ( const JobId & id) const

Retrieve the latest state snapshot for a job.

Parameters
idJob identifier.
Returns
Snapshot when the job exists.

Definition at line 181 of file JobManager.cpp.

◆ start()

void core::jobs::JobManager::start ( const JobId & id)

Mark a job as running.

Parameters
idJob identifier.

Definition at line 231 of file JobManager.cpp.

Here is the call graph for this function:

◆ submit()

JobId core::jobs::JobManager::submit ( JobKind kind)

Create a tracked job in the pending state.

Parameters
kindKind of job to create.
Returns
Identifier of the created job.

Definition at line 58 of file JobManager.cpp.

◆ subscribe()

SubscriptionId core::jobs::JobManager::subscribe ( const JobId & id,
JobEventCallback cb )

Subscribe to events for a job.

Parameters
idJob identifier.
cbCallback to invoke when events are published.
Returns
Subscription identifier, or zero when the job or callback is invalid.

Definition at line 78 of file JobManager.cpp.

◆ unsubscribe()

void core::jobs::JobManager::unsubscribe ( const JobId & id,
SubscriptionId subId )

Remove a job event subscription.

Parameters
idJob identifier.
subIdSubscription identifier.

Definition at line 94 of file JobManager.cpp.


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