Files
UnrealEngine/Engine/Plugins/Mutable/Source/MutableRuntime/Private/MuR/ParallelExecutionUtils.cpp
2025-05-18 13:04:45 +08:00

28 lines
503 B
C++

// Copyright Epic Games, Inc. All Rights Reserved.
#include <MuR/ParallelExecutionUtils.h>
#include <Async/ParallelFor.h>
namespace mu::ParallelExecutionUtils
{
void InvokeBatchParallelFor(int32 Num, TFunctionRef<void(int32)> Body)
{
if (Num == 1)
{
Body(0);
}
else if (Num > 1)
{
ParallelFor(Num, Body);
}
}
void InvokeBatchParallelForSingleThread(int32 Num, TFunctionRef<void(int32)> Body)
{
for (int32 BatchId = 0; BatchId < Num; ++BatchId)
{
Body(BatchId);
}
}
}