Async

Execute a given function asynchronously.

Windows
MacOS
Linux

References

Module

Core

Header

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

Include

#include "Async/Async.h"

Syntax

template<typename CallableType>
auto Async
(
    EAsyncExecution Execution,
    CallableType && Callable,
    TUniqueFunction< void()> CompletionCallback
)

Remarks

Execute a given function asynchronously.

Usage examples:

using global function int TestFunc() { return 123; }

TUniqueFunction Task = TestFunc(); auto Result = Async(EAsyncExecution::Thread, Task);

using lambda TUniqueFunction Task = []() { return 123; }

auto Result = Async(EAsyncExecution::Thread, Task);

using inline lambda auto Result = Async(EAsyncExecution::Thread, []() { return 123; }

Returns

A TFuture object that will receive the return value from the function.

Parameters

Parameter

Description

CallableType

The type of callable object.

Execution

The execution method to use, i.e. on Task Graph or in a separate thread.

Function

The function to execute.

CompletionCallback

An optional callback function that is executed when the function completed execution.

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