FAsyncTask

Insights.

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

Core

Header

/Engine/Source/Runtime/Core/Public/Async/AsyncWork.h

Include

#include "Async/AsyncWork.h"

Syntax

template<typename TTask>
class FAsyncTask : private IQueuedWork

Remarks

FAsyncTask - template task for jobs queued to thread pools

Sample code:

class ExampleAsyncTask : public FNonAbandonableTask { friend class FAsyncTask<ExampleAsyncTask>;

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<ExampleAsyncTask>* MyTask = new FAsyncTask<ExampleAsyncTask>( 5 ); MyTask->StartBackgroundTask();

or MyTask->StartSynchronousTask();

Constructors

Name Description

Public function

FAsyncTask()

Public function

FAsyncTask

(
    Arg0Type&& Arg0,
    ArgTypes&&... Args
)

Forwarding constructor.

Destructors

Name Description

Public function

~FAsyncTask()

Destructor, not legal when a task is in process

Functions

Name Description

Public function

bool

 

Cancel()

Cancel the task, if possible.

Public function

void

 

EnsureCompletion

(
    bool bDoWorkOnThisThreadIfNotStarte...
)

Wait until the job is complete

Public function

TTask &

 

GetTask()

Retrieve embedded user job, not legal to call while a job is in process

Public function Const

const TTask ...

 

GetTask()

Retrieve embedded user job, not legal to call while a job is in process

Public function

bool

 

IsDone()

Returns true if the work and TASK has completed, false while it's still in progress.

Public function Const

bool

 

IsIdle()

Returns true if the work has not been started or has been completed.

Public function Const

bool

 

IsWorkDone()

Returns true if the work has completed, false while it's still in progress.

Public function

void

 

StartBackgroundTask

(
    FQueuedThreadPool* InQueuedPoo...
)

Queue this task for processing by the background thread pool

Public function

void

 

StartSynchronousTask()

Run this task on this thread

Public function

bool

 

WaitCompletionWithTimeout

(
    float TimeLimitSeconds
)

Wait until the job is complete, up to a time limit

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss