Navigation
API > API/Plugins > API/Plugins/ModelingOperators
TBackgroundModelingComputeSource is a container that can be used to repeatedly execute a background computation. The assumption is that this background computation may need to be canceled and restarted, ie if input parameters change due to user input/actions.
Clients of the template must provide an OpType, which is the operation to execute, and a OpTypeFactory, which creates OpType instances on demand. The APIs that must be provided in these types are minimal: OpTypeFactory:
- TUniquePtr
MakeNewOperator() OpType: - void CalculateResult(FProgressCancel*)
The Client cancels the active computation and spawns a new one by calling NotifyActiveComputeInvalidated(). This does not immediately terminate the computation, it waits for a delay of .CancelActiveOpDelaySeconds for this active compute to finish. This both (1) allows for partial updates to appear at UI levels if the compute is fast enough and (2) avoids constantly respawning new computes as the user (for example) drags a slider parameter.
However as a result of this delay the Client must Tick() this class regularly.
CheckStatus() can be used to determine if the computation has finished, in which case a new result is available. ExtractResult() will return this result.
Note that a cancelled computation does not necessarily immediately terminate even after the timeout. This requires that the OpType implementation test the provided ProgressCancel instance frequently. When the Operator is "cancelled" it is moved to a separate task that waits for the owning FAsyncTask to finish and then deletes it (and the contained Operator)
| Name | TBackgroundModelingComputeSource |
| Type | class |
| Header File | /Engine/Plugins/Runtime/MeshModelingToolset/Source/ModelingOperators/Public/BackgroundModelingComputeSource.h |
| Include Path | #include "BackgroundModelingComputeSource.h" |
Syntax
template<typename OpType, typename OpTypeFactory>
class TBackgroundModelingComputeSource
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TBackgroundModelingComputeSource
(
OpTypeFactory* OperatorSourceIn |
BackgroundModelingComputeSource.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
~TBackgroundModelingComputeSource() |
BackgroundModelingComputeSource.h |
Structs
| Name | Remarks |
|---|---|
| FStatus |
Enums
Protected
| Name | Remarks |
|---|---|
| EBackgroundComputeTaskState |
Variables
Public
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| CancelActiveOpDelaySeconds | double | Default wait delay for cancel/restart cycle | BackgroundModelingComputeSource.h | |
| MaxActiveTaskCount | int32 | Maximum number of active tasks to allow to run in the background until we wait to launch more | BackgroundModelingComputeSource.h |
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bWaitingForActiveTasksToFinish | bool | BackgroundModelingComputeSource.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void CancelActiveCompute() |
Cancel the active computation immediately and do not start a new one | BackgroundModelingComputeSource.h | |
FStatus CheckStatus() |
Return status of the active background computation. | BackgroundModelingComputeSource.h | |
TUniquePtr< OpType > ExtractResult() |
BackgroundModelingComputeSource.h | ||
double GetElapsedComputeTime() |
BackgroundModelingComputeSource.h | ||
bool IsWaitingForBackgroundTasks
(
int32& NumTasks |
If waiting for background tasks, returns true, and sets NumTasks to the number of active tasks. | BackgroundModelingComputeSource.h | |
void NotifyActiveComputeInvalidated () |
Cancel the active computation if one is running, after a delay of CancelActiveOpDelaySeconds. | BackgroundModelingComputeSource.h | |
void Tick
(
float DeltaTime |
Tick the active computation. | BackgroundModelingComputeSource.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void StartNewCompute() |
BackgroundModelingComputeSource.h |