Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/Async
Inheritance Hierarchy
- FInheritedContextBase
- FAsyncTaskBase
- FAsyncTask
- FAsyncTaskExecuterWithAbort
- FAsyncTaskExecuterWithProgressCancel
- FGroomBindingAsyncBuildTask
- FSkinnedAssetAsyncBuildTask
- FStaticMeshAsyncBuildTask
References
| Module | Core |
| Header | /Engine/Source/Runtime/Core/Public/Async/AsyncWork.h |
| Include | #include "Async/AsyncWork.h" |
Syntax
class FAsyncTaskBase :
private UE::FInheritedContextBase ,
private IQueuedWork
Remarks
FAsyncTask - template task for jobs queued to thread pools
Sample code:
class ExampleAsyncTask : public FNonAbandonableTask
{
friend class FAsyncTask
int32 ExampleData;
ExampleAsyncTask(int32 InExampleData) : ExampleData(InExampleData) { }
void DoWork() { ... do the work here }
FORCEINLINE TStatId GetStatId() const { RETURN_QUICK_DECLARE_CYCLE_STAT(ExampleAsyncTask, STATGROUP_ThreadPoolAsyncTasks); } };
void Example() {
start an example job FAsyncTask
or MyTask->StartSynchronousTask();
/to just do it now on this thread /Check if the task is done : if (MyTask->IsDone()) { }
/Spinning on IsDone is not acceptable( see EnsureCompletion ), but it is ok to check once a frame. /Ensure the task is done, doing the task on the current thread if it has not been started, waiting until completion in all cases. MyTask->EnsureCompletion(); delete Task; }
Destructors
| Type | Name | Description | |
|---|---|---|---|
| Destructor, not legal when a task is in process |
Functions
| Type | Name | Description | |
|---|---|---|---|
| bool | Cancel () |
Cancel the task, if possible. | |
| void | CheckIdle () |
Internal call to assert that we are idle | |
| void | DoTaskWork () |
Perform task's work | |
| void | EnsureCompletion
(
bool bDoWorkOnThisThreadIfNotStarted, |
Wait until the job is complete | |
| EQueuedWorkPriority | GetPriority () |
||
| void | |||
| bool | IsDone () |
Returns true if the work and TASK has completed, false while it's still in progress. | |
| bool | IsIdle () |
Returns true if the work has not been started or has been completed. | |
| bool | IsWorkDone () |
Returns true if the work has completed, false while it's still in progress. | |
| bool | Reschedule
(
FQueuedThreadPool* InQueuedPool, |
If not already being processed, will be rescheduled on given thread pool and priority. | |
| bool | SetPriority
(
EQueuedWorkPriority QueuedWorkPriority |
||
| void | StartBackgroundTask
(
FQueuedThreadPool* InQueuedPool, |
Queue this task for processing by the background thread pool | |
| void | StartSynchronousTask
(
EQueuedWorkPriority InQueuedWorkPriority, |
Run this task on this thread | |
| bool | Abandon task if possible, returns true on success, false otherwise. | ||
| bool | WaitCompletionWithTimeout
(
float TimeLimitSeconds |
Wait until the job is complete, up to a time limit |
Overridden from IQueuedWork
| Type | Name | Description | |
|---|---|---|---|
| const TCHAR * | GetDebugName () |
Returns text to identify the Work, for debug/log purposes only | |
| int64 | Returns an approximation of the peak memory (in bytes) this task could require during it's execution. |