Navigation
API > API/Runtime > API/Runtime/Core
An abstract base class for task implementation. Implements internal logic of task prerequisites, nested tasks and deep task retraction. Implements intrusive ref-counting and so can be used with TRefCountPtr. It doesn't store task body, instead it expects a derived class to provide a task body as a parameter to `TryExecute_ method.
| Name | FTaskBase |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Tasks/TaskPrivate.h |
| Include Path | #include "Tasks/TaskPrivate.h" |
Syntax
class FTaskBase : private UE::FInheritedContextBase
Inheritance Hierarchy
- FInheritedContextBase → FTaskBase
- FTaskBase
Derived Classes
FTaskBase derived class hierarchy
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Tasks/TaskPrivate.h | |||
| Tasks/TaskPrivate.h | |||
FTaskBase
(
uint32 InitRefCount, |
Tasks/TaskPrivate.h |
Destructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
virtual ~FTaskBase() |
Tasks/TaskPrivate.h |
Classes
| Name | Remarks |
|---|---|
| FPrerequisites | Stores backlinks to prerequsites, either execution prerequisites or nested tasks (completion prerequisites). |
| FSubsequents | The task is completed when its subsequents list is closed and no more can be added |
Constants
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| ExecutionFlag | uint32 | ExecutionFlag_ is set at the beginning of execution as the most significant bit of NumLocks_ and indicates a switch of `NumLocks_ from "execution prerequisites" (a number of uncompleted prerequisites that block task execution) to "completion prerequisites" (a number of nested uncompleted tasks that block task completion) |
Tasks/TaskPrivate.h |
| NumInitialLocks | uint32 | The number of times that the task should be unlocked before it can be scheduled or completed initial count is 1 for launching the task (it can't be scheduled before it's launched) reaches 0 the task is scheduled for execution. | Tasks/TaskPrivate.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ExecutingThreadId | std::atomic< uint32 > | Tasks/TaskPrivate.h | ||
| ExtendedPriority | EExtendedTaskPriority | Tasks/TaskPrivate.h | ||
| LowLevelTask | LowLevelTasks::FTask | Tasks/TaskPrivate.h | ||
| NumLocks | std::atomic< uint32 > | Tasks/TaskPrivate.h | ||
| Pipe | FPipe * | Tasks/TaskPrivate.h | ||
| Prerequisites | FPrerequisites< TInlineAllocator< 1 > > | Tasks/TaskPrivate.h | ||
| RefCount | std::atomic< uint32 > | Tasks/TaskPrivate.h | ||
| StateChangeEvent | FEventCount | Tasks/TaskPrivate.h | ||
| Subsequents | FSubsequents< TInlineAllocator< 1 > > | Tasks/TaskPrivate.h | ||
| TaskTriggered | std::atomic< bool > | Note: Only ever set when the task is launched from Trigger() | Tasks/TaskPrivate.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddNested
(
FTaskBase& Nested |
Adds a nested task that must be completed before the parent (this) is completed | Tasks/TaskPrivate.h | |
bool AddPrerequisites
(
const HigherLevelTaskType& Prerequisite |
The task will be executed only when all prerequisites are completed. | Tasks/TaskPrivate.h | |
void AddPrerequisites
(
const PrerequisiteCollectionType& InPrerequisites |
The task will be executed only when all prerequisites are completed. | Tasks/TaskPrivate.h | |
bool AddPrerequisites
(
const HigherLevelTaskType& Prerequisite |
The task will be executed only when all prerequisites are completed. | Tasks/TaskPrivate.h | |
bool AddPrerequisites
(
FTaskBase& Prerequisite |
The task will be executed only when all prerequisites are completed. | Tasks/TaskPrivate.h | |
void AddRef() |
Ref-count | Tasks/TaskPrivate.h | |
bool AddSubsequent
(
FTaskBase& Subsequent |
The task unlocks all its subsequents on completion. | Tasks/TaskPrivate.h | |
EExtendedTaskPriority GetExtendedPriority() |
Tasks/TaskPrivate.h | ||
FPipe * GetPipe() |
Tasks/TaskPrivate.h | ||
ETaskPriority GetPriority() |
Tasks/TaskPrivate.h | ||
uint32 GetRefCount
(
std::memory_order MemoryOrder |
Tasks/TaskPrivate.h | ||
TaskTrace::FId GetTraceId() |
Tasks/TaskPrivate.h | ||
bool IsAwaitable () |
Returns true if it's valid to wait for the task completion. | Tasks/TaskPrivate.h | |
bool IsCompleted() |
Tasks/TaskPrivate.h | ||
bool IsNamedThreadTask() |
Tasks/TaskPrivate.h | ||
void Release() |
Tasks/TaskPrivate.h | ||
void ReleaseInternalReference () |
Releases internal reference and maintains low-level task state. | Tasks/TaskPrivate.h | |
| A piped task is executed after the previous task from this pipe is completed. | Tasks/TaskPrivate.h | ||
bool Trigger
(
uint64 TaskSize |
Tries to schedule task execution but has additional tracking to ensure a task is not scheduled more than once. | Tasks/TaskPrivate.h | |
bool TryLaunch
(
uint64 TaskSize |
Tries to schedule task execution. | Tasks/TaskPrivate.h | |
bool TryRetractAndExecute
(
FTimeout Timeout, |
Tries to pull out the task from the system and execute it. | Tasks/TaskPrivate.h | |
void Wait () |
Waits for task's completion. | Tasks/TaskPrivate.h | |
| Waits for task's completion, with optional timeout. | Tasks/TaskPrivate.h | ||
void WaitWithNamedThreadsSupport() |
Mimics the old tasks (TaskGraph) behaviour on named threads: waiting for a task on a named thread pulls other tasks from this named thread queue and executes them | Tasks/TaskPrivate.h |
Protected
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void AddPrerequisites
(
const PrerequisiteCollectionType& InPrerequisites, |
The task will be executed only when all prerequisites are completed. | Tasks/TaskPrivate.h | |
void ClearPipe() |
Tasks/TaskPrivate.h | ||
void Close() |
Closes task by unlocking its subsequents and flagging it as completed | Tasks/TaskPrivate.h | |
void ExecuteTask() |
Tasks/TaskPrivate.h | ||
void Init
(
const TCHAR* InDebugName, |
Tasks/TaskPrivate.h | ||
bool TryExecuteTask () |
Tries to get execution permission and if successful, executes given task body and completes the task if there're no pending nested tasks. | Tasks/TaskPrivate.h | |
void UnlockPrerequisites() |
Tasks/TaskPrivate.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Tasks/TaskPrivate.h | |||
| Tasks/TaskPrivate.h |