SWMMVis  6.0.0-alpha.4
Qt6/C++ GIS-based graphical user interface for the SWMMVis engine (6.0.0-alpha.4)
Loading...
Searching...
No Matches
openswmmvis::GuiExtensionHost::Job Struct Reference

Host-owned job state shared between its worker and queued GUI continuations. More...

Inheritance diagram for openswmmvis::GuiExtensionHost::Job:
Collaboration diagram for openswmmvis::GuiExtensionHost::Job:

Public Member Functions

 Job (GuiExtensionHost *owner, QString caption)
 Create retained job state before scheduling its worker.
 
void postFlush ()
 Post the single pending flush after releasing the state mutex.
 
bool reserveFlush ()
 Reserve a flush while the caller holds mutex.
 
void publishCancellation ()
 Commit GUI cancellation metadata without invoking a user completion callback.
 
bool requestCancellation ()
 Atomically request cancellation before worker settlement.
 
void cancel () override
 Request cooperative cancellation.
 
bool isFinished () const override
 Inspect worker completion.
 
bool isCancelled () const override
 Check cooperative cancellation from a worker.
 
void setProgress (double fraction, const QString &text) override
 Queue progress to the host without touching widgets from the worker.
 
void postToMainThread (std::function< void()> callback) override
 Queue a GUI-thread continuation while the host is alive.
 
bool beginWork ()
 Enter execution unless cancellation won while the worker was queued.
 
void settle (const QString &message)
 Latch outcome at worker return, preventing a later cancel from changing it.
 
void flush (bool callbacks=true)
 Publish one latched state packet; no worker touches widgets or the registry.
 
- Public Member Functions inherited from OpenSWMM::Sdk::IJob
virtual ~IJob ()=default
 Destroy a job implementation; handles returned by the host are borrowed.
 
- Public Member Functions inherited from OpenSWMM::Sdk::IJobContext
virtual ~IJobContext ()=default
 Destroy a context after the worker has returned; extensions borrow it.
 

Public Attributes

GuiExtensionHost * host
 Borrowed owner; outlives the joined worker.
 
QUuid operationId = QUuid::createUuid()
 Unique accepted worker identity.
 
QString id
 Durable crash-marker suffix, matching operationId.
 
QString title
 Copied progress and recovery caption.
 
std::atomic< bool > cancelled {false}
 Worker-visible cooperative request.
 
std::atomic< bool > finished {false}
 True after immutable worker settlement.
 
QPointer< QProgressDialog > progress
 GUI-only guarded progress widget.
 
std::mutex mutex
 Linearizes start, cancellation, progress and completion.
 
bool posted = false
 At most one queued GUI state flush is pending.
 
bool entered = false
 Actual worker entry, latched under the state mutex.
 
bool startedPublished = false
 Worker entry has been published on the GUI thread.
 
bool cancellationPublished = false
 The winning cancellation was observed once.
 
bool progressDirty = false
 Latest finite progress has not been flushed.
 
bool settled = false
 Native terminal outcome was latched at worker return.
 
bool terminalPublished = false
 GUI publication committed the immutable outcome.
 
double fraction = 0.
 Latest finite normalized worker fraction.
 
QString stage
 Latest legacy display stage; the registry bounds its public copy.
 
QString error
 Legacy terminal diagnostic; the registry bounds its public copy.
 
ProcessPhase outcome = ProcessPhase::Queued
 Latched terminal classification.
 
QDateTime startedAt
 Worker entry timestamp, copied to the registry.
 
QDateTime finishedAt
 Worker settlement timestamp, copied to the registry.
 
std::function< void(bool, const QString &)> completion
 GUI-only user callback.
 
std::function< void()> publicationCancellation
 Atomic-only private hook, protected by mutex.
 

Detailed Description

Host-owned job state shared between its worker and queued GUI continuations.

Constructor & Destructor Documentation

◆ Job()

openswmmvis::GuiExtensionHost::Job::Job ( GuiExtensionHost *  owner,
QString  caption 
)
inlineexplicit

Create retained job state before scheduling its worker.

Parameters
[in]ownerBorrowed host that will join the worker before destruction.
[in]captionOwning user-visible operation title.

Member Function Documentation

◆ beginWork()

bool openswmmvis::GuiExtensionHost::Job::beginWork ( )
inline

Enter execution unless cancellation won while the worker was queued.

Returns
True when the user worker should execute.
Here is the call graph for this function:

◆ cancel()

void openswmmvis::GuiExtensionHost::Job::cancel ( )
inlineoverridevirtual

Request cooperative cancellation.

Note
May be called from any thread.

Implements OpenSWMM::Sdk::IJob.

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

◆ flush()

void openswmmvis::GuiExtensionHost::Job::flush ( bool  callbacks = true)
inline

Publish one latched state packet; no worker touches widgets or the registry.

Parameters
[in]callbacksFalse during shutdown: settle metadata/cleanup but suppress user code.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isCancelled()

bool openswmmvis::GuiExtensionHost::Job::isCancelled ( ) const
inlineoverridevirtual

Check cooperative cancellation from a worker.

Returns
True after user/host cancellation; check during long operations and before publication.

Implements OpenSWMM::Sdk::IJobContext.

◆ isFinished()

bool openswmmvis::GuiExtensionHost::Job::isFinished ( ) const
inlineoverridevirtual

Inspect worker completion.

Returns
True once the worker returns, before its GUI continuation necessarily executes.

Implements OpenSWMM::Sdk::IJob.

◆ postFlush()

void openswmmvis::GuiExtensionHost::Job::postFlush ( )
inline

Post the single pending flush after releasing the state mutex.

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

◆ postToMainThread()

void openswmmvis::GuiExtensionHost::Job::postToMainThread ( std::function< void()>  callback)
inlineoverridevirtual

Queue a GUI-thread continuation while the host is alive.

Parameters
[in]callbackOwning callback; capture data values and guarded QObject pointers.
Note
Queued callbacks are suppressed after shutdown begins.

Implements OpenSWMM::Sdk::IJobContext.

Here is the call graph for this function:

◆ publishCancellation()

void openswmmvis::GuiExtensionHost::Job::publishCancellation ( )
inline

Commit GUI cancellation metadata without invoking a user completion callback.

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

◆ requestCancellation()

bool openswmmvis::GuiExtensionHost::Job::requestCancellation ( )
inline

Atomically request cancellation before worker settlement.

Returns
True for an active accepted/repeated request; false after settlement.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reserveFlush()

bool openswmmvis::GuiExtensionHost::Job::reserveFlush ( )
inline

Reserve a flush while the caller holds mutex.

Returns
True when the caller must post one GUI invocation after unlocking.
Here is the caller graph for this function:

◆ setProgress()

void openswmmvis::GuiExtensionHost::Job::setProgress ( double  fraction,
const QString &  text 
)
inlineoverridevirtual

Queue progress to the host without touching widgets from the worker.

Parameters
[in]fractionCompletion fraction clamped to [0,1].
[in]textOptional short stage description.

Implements OpenSWMM::Sdk::IJobContext.

Here is the call graph for this function:

◆ settle()

void openswmmvis::GuiExtensionHost::Job::settle ( const QString &  message)
inline

Latch outcome at worker return, preventing a later cancel from changing it.

Parameters
[in]messageWorker exception detail, empty on normal return.
Here is the call graph for this function:

Member Data Documentation

◆ cancellationPublished

bool openswmmvis::GuiExtensionHost::Job::cancellationPublished = false

The winning cancellation was observed once.

◆ cancelled

std::atomic<bool> openswmmvis::GuiExtensionHost::Job::cancelled {false}

Worker-visible cooperative request.

◆ completion

std::function<void(bool, const QString &)> openswmmvis::GuiExtensionHost::Job::completion

GUI-only user callback.

◆ entered

bool openswmmvis::GuiExtensionHost::Job::entered = false

Actual worker entry, latched under the state mutex.

◆ error

QString openswmmvis::GuiExtensionHost::Job::error

Legacy terminal diagnostic; the registry bounds its public copy.

◆ finished

std::atomic<bool> openswmmvis::GuiExtensionHost::Job::finished {false}

True after immutable worker settlement.

◆ finishedAt

QDateTime openswmmvis::GuiExtensionHost::Job::finishedAt

Worker settlement timestamp, copied to the registry.

◆ fraction

double openswmmvis::GuiExtensionHost::Job::fraction = 0.

Latest finite normalized worker fraction.

◆ host

GuiExtensionHost* openswmmvis::GuiExtensionHost::Job::host

Borrowed owner; outlives the joined worker.

◆ id

QString openswmmvis::GuiExtensionHost::Job::id

Durable crash-marker suffix, matching operationId.

◆ mutex

std::mutex openswmmvis::GuiExtensionHost::Job::mutex

Linearizes start, cancellation, progress and completion.

◆ operationId

QUuid openswmmvis::GuiExtensionHost::Job::operationId = QUuid::createUuid()

Unique accepted worker identity.

◆ outcome

ProcessPhase openswmmvis::GuiExtensionHost::Job::outcome = ProcessPhase::Queued

Latched terminal classification.

◆ posted

bool openswmmvis::GuiExtensionHost::Job::posted = false

At most one queued GUI state flush is pending.

◆ progress

QPointer<QProgressDialog> openswmmvis::GuiExtensionHost::Job::progress

GUI-only guarded progress widget.

◆ progressDirty

bool openswmmvis::GuiExtensionHost::Job::progressDirty = false

Latest finite progress has not been flushed.

◆ publicationCancellation

std::function<void()> openswmmvis::GuiExtensionHost::Job::publicationCancellation

Atomic-only private hook, protected by mutex.

◆ settled

bool openswmmvis::GuiExtensionHost::Job::settled = false

Native terminal outcome was latched at worker return.

◆ stage

QString openswmmvis::GuiExtensionHost::Job::stage

Latest legacy display stage; the registry bounds its public copy.

◆ startedAt

QDateTime openswmmvis::GuiExtensionHost::Job::startedAt

Worker entry timestamp, copied to the registry.

◆ startedPublished

bool openswmmvis::GuiExtensionHost::Job::startedPublished = false

Worker entry has been published on the GUI thread.

◆ terminalPublished

bool openswmmvis::GuiExtensionHost::Job::terminalPublished = false

GUI publication committed the immutable outcome.

◆ title

QString openswmmvis::GuiExtensionHost::Job::title

Copied progress and recovery caption.


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