TGenericDataBackgroundCompute

[TGenericDataBackgroundCompute](API\Plugins\ModelingComponents\TGenericDataBackgroundCompute) is an infrastructure object that implements a common UI pattern in interactive 3D tools, where we want to run an expensive parameterized computation (via a TGenericDataOperator) in a background thread so as to not block the UI.

Choose your operating system:

Windows

macOS

Linux

References

Module

ModelingComponents

Header

/Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingComponents/Public/MeshOpPreviewHelpers.h

Include

#include "MeshOpPreviewHelpers.h"

Syntax

template<typename ResultDataType>
class TGenericDataBackgroundCompute

Remarks

TGenericDataBackgroundCompute is an infrastructure object that implements a common UI pattern in interactive 3D tools, where we want to run an expensive parameterized computation (via a TGenericDataOperator) in a background thread so as to not block the UI. If the user changes parameters while the Operator is running, it should be canceled and restarted.

The TGenericDataOperator are provided by the owner via a IGenericDataOperatorFactory implementation. The owner must also Tick() this object regularly to allow results to be extracted from the background thread and appropriate delegates fired when that occurs.

Variables

Name Description

Protected variable

TUniquePtr< Com...

 

BackgroundCompute

This object manages the background computes

Protected variable

bool

 

bResultValid

State flag, if true then we have valid result

Protected variable

TUniquePtr< Res...

 

CurrentResult

Current result value

Public variable

FOnOpCompleted

 

OnOpCompleted

OnOpCompleted is fired via Tick() when an Operator finishes, with the operator pointer as argument

Public variable

FOnResultUpdate...

 

OnResultUpdated

OnResultUpdated is fired via Tick() when an Operator finishes, with the computed result as argument

Functions

Name Description

Public function

void

 

Cancel()

Terminate any active computation without returning anything

Public function Const

float

 

GetElapsedComputeTime()

Public function Const

bool

 

HaveValidResult()

Public function

void

 

InvalidateResult()

Control flow Request that the current computation be canceled and a new one started

Public function

void

 

Setup

(
    FactoryType* OpGenerator
)

Required calls to setup/update/shutdown this object

Public function

TUniquePtr< ...

 

Shutdown()

Terminate any active computation and return the current Result

Public function

void

 

Tick

(
    float DeltaTime
)

Tick the background computation to check for updated results

Protected function

void

 

UpdateResults()

Update CurrentResult if a new result is available from BackgroundCompute, and fires relevant signals

Typedefs