|
| bool | Cancel () |
| | Cancel the task, if possible. 更多...
|
| |
| void | EnsureCompletion (bool bDoWorkOnThisThreadIfNotStarted=true) |
| | Wait until the job is complete 更多...
|
| |
|
template<typename Arg0Type , typename... ArgTypes> |
| | FAsyncTask (Arg0Type &&Arg0, ArgTypes &&... Args) |
| | Forwarding constructor.
|
| |
| bool | IsDone () |
| | Returns true if the work and TASK has completed, false while it's still in progress. 更多...
|
| |
| bool | IsIdle () const |
| | Returns true if the work has not been started or has been completed. 更多...
|
| |
| bool | IsWorkDone () const |
| | Returns true if the work has completed, false while it's still in progress. 更多...
|
| |
|
void | StartBackgroundTask (FQueuedThreadPool *InQueuedPool=GThreadPool) |
| | Queue this task for processing by the background thread pool
|
| |
| void | StartSynchronousTask () |
| | Run this task on this thread 更多...
|
| |
| bool | WaitCompletionWithTimeout (float TimeLimitSeconds) |
| | Wait until the job is complete, up to a time limit 更多...
|
| |
|
| ~FAsyncTask () |
| | Destructor, not legal when a task is in process
|
| |
template<typename TTask>
class FAsyncTask< TTask >
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();
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;
}