FAsyncTask

[FAsyncTask](API\Runtime\Core\Async\FAsyncTask) - template task for jobs queued to thread pools

Windows
MacOS
Linux

Inheritance Hierarchy

IQueuedWork

FAsyncTask

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

Select Skin
Light
Dark

Welcome to the new Unreal Engine 4 Documentation site!

We're working on lots of new features including a feedback system so you can tell us how we are doing. It's not quite ready for use in the wild yet, so head over to the Documentation Feedback forum to tell us about this page or call out any issues you are encountering in the meantime.

We'll be sure to let you know when the new system is up and running.

Post Feedback