UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
UE::Tasks::FTaskConcurrencyLimiter Class Reference

#include <TaskConcurrencyLimiter.h>

Public Member Functions

 FTaskConcurrencyLimiter (uint32 MaxConcurrency, ETaskPriority TaskPriority=ETaskPriority::Default)
 
template<typename TaskFunctionType >
void Push (const TCHAR *DebugName, TaskFunctionType &&TaskFunction)
 
bool Wait (FTimespan Timeout=FTimespan::MaxValue())
 

Detailed Description

A lightweight construct that limits the concurrency of tasks pushed into it.

Note
This class supports being destroyed before the tasks it contains are finished.

Constructor & Destructor Documentation

◆ FTaskConcurrencyLimiter()

UE::Tasks::FTaskConcurrencyLimiter::FTaskConcurrencyLimiter ( uint32  MaxConcurrency,
ETaskPriority  TaskPriority = ETaskPriority::Default 
)
inlineexplicit

Constructor.

Parameters
MaxConcurrencyHow wide the processing can go.
TaskPriorityPriority the tasks will be launched with.

Member Function Documentation

◆ Push()

template<typename TaskFunctionType >
void UE::Tasks::FTaskConcurrencyLimiter::Push ( const TCHAR DebugName,
TaskFunctionType &&  TaskFunction 
)
inline

Push a new task.

Parameters
DebugNameHelps to identify the task in debugger and profiler.
TaskFunctionA callable with a slot parameter, usually a lambda but can be also a functor object or a pointer to a function. The slot parameter is an index in [0..max_concurrency) range, unique at any moment of time, that can be used in user code to index a fixed-size buffer. See TaskConcurrencyLimiterStressTest() for an example.

◆ Wait()

bool UE::Tasks::FTaskConcurrencyLimiter::Wait ( FTimespan  Timeout = FTimespan::MaxValue())
inline

Waits for task's completion with timeout.

Parameters
TimeoutMaximum amount of time to wait for tasks to finish before returning.
Returns
true if all tasks are completed, false otherwise.
Note
A wait is satisfied once the internal task counter reaches 0 and is never reset afterward when more tasks are added. A new FTaskConcurrencyLimiter can be used for such a use case.

The documentation for this class was generated from the following file: