Navigation
API > API/Runtime > API/Runtime/Core
Support for canceling tasks mid-execution usage: FCancellationToken Token; Launch(UE_SOURCE_LOCATION, [&Token] { ... if (Token.IsCanceled()) return; ... }); Token.Cancel();
- it's user's decision and responsibility to manage cancellation token lifetime, to check cancellation token, return early, to do any required cleanup, or to do nothing at all
- no way to cancel a task to skip its execution completely
- waiting for a canceled task is blocking until its prerequisites are completed and the task is executed and completed, basically same as for not canceled tasks except a canceled one can quit execution early
- canceling a task doesn't affect its subsequents (unless they use the same cancellation token instance)
| Name | FCancellationToken |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Tasks/Task.h |
| Include Path | #include "Tasks/Task.h" |
Syntax
class FCancellationToken
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Tasks/Task.h | |||
| Tasks/Task.h | |||
FCancellationToken
(
const FCancellationToken& |
Tasks/Task.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| bCanceled | std::atomic< bool > | Tasks/Task.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Cancel() |
Tasks/Task.h | ||
bool IsCanceled() |
Tasks/Task.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
FCancellationToken & operator=
(
const FCancellationToken& |
Tasks/Task.h | ||
| Tasks/Task.h |