Language:
Discover
By Skill Level
By Category

FAsyncTask

Choose your OS:

Inheritance Hierarchy

IQueuedWork

FAsyncTask

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 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

bool

 

IsIdle()

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

Public function

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

true if the task is completed

References

Module

Core

Header

Runtime/Core/Public/Async/AsyncWork.h