![]() |
ezEngine
Release 25.03
|
Base class for custom tasks. More...
#include <Task.h>
Public Member Functions | |
void | ConfigureTask (const char *szTaskName, ezTaskNesting nestingMode, ezOnTaskFinishedCallback callback=ezOnTaskFinishedCallback()) |
Sets the most important task properties. This has to be done before the task is added to a task group for the first time. More... | |
void | SetMultiplicity (ezUInt32 uiMultiplicity) |
Changes the multiplicity of this task. More... | |
ezUInt32 | GetMultiplicity () const |
bool | IsTaskFinished () const |
Returns whether the task has been finished. This includes being canceled. More... | |
bool | HasBeenCanceled () const |
Can be used inside an overridden 'Execute' function to terminate execution prematurely. | |
![]() | |
virtual | ~ezRefCounted ()=default |
Adds a virtual destructor. | |
![]() | |
ezRefCountingImpl ()=default | |
Constructor. | |
ezRefCountingImpl (const ezRefCountingImpl &rhs) | |
void | operator= (const ezRefCountingImpl &rhs) |
ezInt32 | AddRef () const |
Increments the reference counter. Returns the new reference count. | |
ezInt32 | ReleaseRef () const |
Decrements the reference counter. Returns the new reference count. | |
bool | IsReferenced () const |
Returns true if the reference count is greater than 0, false otherwise. | |
ezInt32 | GetRefCount () const |
Returns the current reference count. | |
Protected Member Functions | |
virtual void | Execute () |
Override this to implement the task's supposed functionality. More... | |
virtual void | ExecuteWithMultiplicity (ezUInt32 uiInvocation) const |
Override this to implement the task's supposed functionality. More... | |
Friends | |
class | ezTaskSystem |
Base class for custom tasks.
void ezTask::ConfigureTask | ( | const char * | szTaskName, |
ezTaskNesting | nestingMode, | ||
ezOnTaskFinishedCallback | callback = ezOnTaskFinishedCallback() |
||
) |
Sets the most important task properties. This has to be done before the task is added to a task group for the first time.
szTaskName | Will be displayed in profiling tools and is useful for debugging. |
nestingMode | See ezTaskNesting |
Callback | A callback to execute when the task is finished (or canceled). The most common use case for this is to deallocate the task at that time. |
|
inlineprotectedvirtual |
Override this to implement the task's supposed functionality.
This function is called for tasks that do not use multiplicity. They are executed a single time for each time they are added to the ezTaskSystem.
Reimplemented in ezUpdateTask, ezResourceManagerWorkerUpdateContent, ezDelegateTask< void >, ezAfterSaveDocumentTask, ezProcGenInternal::FindPlacementTilesTask, ezProcGenInternal::PlacementTask, ezProcGenInternal::VertexColorTask, ezParticleEffectUpdateTask, ezProcGenInternal::PreparePlacementTask, ezSaveDocumentTask, ezResourceManagerWorkerDataLoad, ezDelegateTask< T >, ezBakingInternal::SkyVisibilityTask, ArrayPtrTask< ElemType >, ezNavMeshSectorGenerationTask, and ezBakingInternal::PlaceProbesTask.
|
inlineprotectedvirtual |
Override this to implement the task's supposed functionality.
This function is called for tasks that use multiplicity. A task that uses multiplicity is automatically run N times by the ezTaskSystem, each time with an increasing invocation index. This allows to have a single task to handle something, but then decide dynamically how often to execute it, to subdivide the workload into multiple pieces. Since the same task is executed multiple times in parallel, tasks with multiplicity should not have any mutable state, which is why this function is const.
Reimplemented in ArrayPtrTask< ElemType >.
|
inline |
|
inline |
Returns whether the task has been finished. This includes being canceled.
void ezTask::SetMultiplicity | ( | ezUInt32 | uiMultiplicity | ) |
Changes the multiplicity of this task.
This has to be set before the task is scheduled, ie. before the task group that the task belongs to has all its dependencies fulfilled and has its tasks queued for execution. It is allowed to change the multiplicity after the task is added to the ezTaskSystem, as long as the calling code guarantees to set this value in time.
A task that has a multiplicity of zero (the default) will have its Execute() function called exactly once. A task with a multiplicity of N will have its ExecuteWithMultiplicity() function called exactly N times, potentially in parallel on multiple threads. Since N can be dynamically decided each frame, one can dynamically scale the amount of parallelism according to the workload.