class LongOperationTracker

Inherits: IScriptExportable

Tracks execution of a long running operation (usually asynchronous operations taking multiple seconds/minutes).

Provides standardized of providing information about progress of the operation.

Public

Constructors

LongOperationTracker

LongOperationTracker(String name, LongOperationFlags flags = LongOperationFlag::None, String description = StringUtility::kBlank, String category = StringUtility::kBlank)
name
Name that describes the operation being executed.
flags
Flags that describe how the operation is being executed.
description
Additional information about the operation.
category
Category that may be used for grouping similar operations together.

Methods

~LongOperationTracker

virtual ~LongOperationTracker() noexcept

GetName

const String &GetName() const

Name of the operation, to be used in UI and debugging.

GetDescription

const String &GetDescription() const

Description of the operation, to be used in UI and debugging.

GetCategory

const String &GetCategory() const

Category of the operation, if provided.

Can be used for grouping similar operations.

CanBeAborted

bool CanBeAborted() const

Returns true if the operation can be aborted.

ReportsProgress

bool ReportsProgress() const

Returns true if progress between range [0, 1] is being reported.

GetProgressPercent

float GetProgressPercent() const

Returns the current operation progress.

Values between [0, 1] are reported only if operation can report progress.

Internal

Methods

NotifyOperationStarted

void NotifyOperationStarted()

To be called by external code when the operation starts executing.

NotifyOperationFinished

void NotifyOperationFinished()

To be called by external code when the operation finished running and no errors were reported.

Does nothing if operation is already in one of the finished states (success, failed or error).

NotifyOperationAborted

void NotifyOperationAborted()

To be called by external code when the operation has processed the user's abort request.

Does nothing if operation is already in one of the finished states (success, failed or error).

NotifyOperationFailed

void NotifyOperationFailed(const String &error)

To be called by external code when the operation has failed with some error.

Does nothing if operation is already in one of the other finished states (success or error). If operation is already in a failed state appends the provided error message to the existing error message.

NotifyProgressChanged

void NotifyProgressChanged(float progressPercent)

Changes the progress percent of the operation.

Thread safe.

Protected

Fields

mMutex

Mutex mMutex

mState

mProgressPercent

float mProgressPercent

mError

String mError

Error reported if the operation failed.

mName

String mName

mDescription

String mDescription

mCategory

String mCategory

mFlags

LongOperationFlags mFlags