Choose your operating system:
Windows
macOS
Linux
Module |
|
Header |
/Engine/Source/Runtime/Core/Public/Async/AsyncWork.h |
Include |
#include "Async/AsyncWork.h" |
template<typename TTask>
class FAsyncTask : private IQueuedWork
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();
Name | Description | |
---|---|---|
|
FAsyncTask() |
|
|
FAsyncTask ( |
Forwarding constructor. |
Name | Description | |
---|---|---|
|
~FAsyncTask() |
Destructor, not legal when a task is in process |
Name | Description | ||
---|---|---|---|
|
Cancel() |
Cancel the task, if possible. |
|
|
EnsureCompletion |
Wait until the job is complete |
|
|
EQueuedWorkP... |
GetPriority() |
|
|
TTask & |
GetTask() |
Retrieve embedded user job, not legal to call while a job is in process |
|
const TTask ... |
GetTask() |
Retrieve embedded user job, not legal to call while a job is in process |
|
IsDone() |
Returns true if the work and TASK has completed, false while it's still in progress. |
|
|
IsIdle() |
Returns true if the work has not been started or has been completed. |
|
|
IsWorkDone() |
Returns true if the work has completed, false while it's still in progress. |
|
|
Reschedule ( |
If not already being processed, will be rescheduled on given thread pool and priority. |
|
|
StartBackgroundTask ( |
Queue this task for processing by the background thread pool |
|
|
StartSynchronousTask ( |
Run this task on this thread |
|
|
WaitCompletionWithTimeout ( |
Wait until the job is complete, up to a time limit |
Name | Description | ||
---|---|---|---|
|
GetRequiredMemory() |
Returns an approximation of the peak memory (in bytes) this task could require during it's execution. |