RunAsyncTraceOnWorkerThread

RunAsyncTraceOnWorkerThread

#Overview

name: RunAsyncTraceOnWorkerThread

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of RunAsyncTraceOnWorkerThread is to control whether asynchronous trace functionality in Unreal Engine 5 runs on a worker thread or the game thread. This setting is primarily used for collision detection and physics calculations.

Regarding the associated variable CVarRunAsyncTraceOnWorkerThread:

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Collision/WorldCollisionAsync.cpp:33

Scope (from outer to inner):

file
namespace    AsyncTraceCVars

Source code excerpt:


namespace AsyncTraceCVars
{
	static int32 RunAsyncTraceOnWorkerThread = 1;
	static FAutoConsoleVariableRef CVarRunAsyncTraceOnWorkerThread(
		TEXT("RunAsyncTraceOnWorkerThread"),
		RunAsyncTraceOnWorkerThread,
		TEXT("Whether to use worker thread for async trace functionality. This works if FApp::ShouldUseThreadingForPerformance is true. Otherwise it will always use game thread. \n")
		TEXT("0: Use game thread, 1: User worker thread"),
		ECVF_Default);

	bool IsAsyncTraceOnWorkerThreads()
	{
		return RunAsyncTraceOnWorkerThread != 0 && (FApp::ShouldUseThreadingForPerformance() || FForkProcessHelper::IsForkedMultithreadInstance());
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Collision/WorldCollisionAsync.cpp:31

Scope (from outer to inner):

file
namespace    AsyncTraceCVars

Source code excerpt:

 * @param UserData		UserData
 */

namespace AsyncTraceCVars
{
	static int32 RunAsyncTraceOnWorkerThread = 1;
	static FAutoConsoleVariableRef CVarRunAsyncTraceOnWorkerThread(
		TEXT("RunAsyncTraceOnWorkerThread"),
		RunAsyncTraceOnWorkerThread,
		TEXT("Whether to use worker thread for async trace functionality. This works if FApp::ShouldUseThreadingForPerformance is true. Otherwise it will always use game thread. \n")
		TEXT("0: Use game thread, 1: User worker thread"),
		ECVF_Default);

	bool IsAsyncTraceOnWorkerThreads()
	{
		return RunAsyncTraceOnWorkerThread != 0 && (FApp::ShouldUseThreadingForPerformance() || FForkProcessHelper::IsForkedMultithreadInstance());
	}
}

namespace
{
	// Helper functions to return the right named member container based on a datum type
	template <typename DatumType> FORCEINLINE TArray<TUniquePtr<TTraceThreadData<DatumType    >>>& GetTraceContainer               (AsyncTraceData& DataBuffer);
	template <>                   FORCEINLINE TArray<TUniquePtr<TTraceThreadData<FTraceDatum  >>>& GetTraceContainer<FTraceDatum>  (AsyncTraceData& DataBuffer) { return DataBuffer.TraceData;   }
	template <>                   FORCEINLINE TArray<TUniquePtr<TTraceThreadData<FOverlapDatum>>>& GetTraceContainer<FOverlapDatum>(AsyncTraceData& DataBuffer) { return DataBuffer.OverlapData; }

	// Helper functions to return the right named member trace index based on a datum type

#Associated Variable and Callsites

This variable is associated with another variable named RunAsyncTraceOnWorkerThread. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Collision/WorldCollisionAsync.cpp:33

Scope (from outer to inner):

file
namespace    AsyncTraceCVars

Source code excerpt:


namespace AsyncTraceCVars
{
	static int32 RunAsyncTraceOnWorkerThread = 1;
	static FAutoConsoleVariableRef CVarRunAsyncTraceOnWorkerThread(
		TEXT("RunAsyncTraceOnWorkerThread"),
		RunAsyncTraceOnWorkerThread,
		TEXT("Whether to use worker thread for async trace functionality. This works if FApp::ShouldUseThreadingForPerformance is true. Otherwise it will always use game thread. \n")
		TEXT("0: Use game thread, 1: User worker thread"),
		ECVF_Default);

	bool IsAsyncTraceOnWorkerThreads()
	{
		return RunAsyncTraceOnWorkerThread != 0 && (FApp::ShouldUseThreadingForPerformance() || FForkProcessHelper::IsForkedMultithreadInstance());
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/Collision/WorldCollisionAsync.cpp:31

Scope (from outer to inner):

file
namespace    AsyncTraceCVars

Source code excerpt:

 * @param UserData		UserData
 */

namespace AsyncTraceCVars
{
	static int32 RunAsyncTraceOnWorkerThread = 1;
	static FAutoConsoleVariableRef CVarRunAsyncTraceOnWorkerThread(
		TEXT("RunAsyncTraceOnWorkerThread"),
		RunAsyncTraceOnWorkerThread,
		TEXT("Whether to use worker thread for async trace functionality. This works if FApp::ShouldUseThreadingForPerformance is true. Otherwise it will always use game thread. \n")
		TEXT("0: Use game thread, 1: User worker thread"),
		ECVF_Default);

	bool IsAsyncTraceOnWorkerThreads()
	{
		return RunAsyncTraceOnWorkerThread != 0 && (FApp::ShouldUseThreadingForPerformance() || FForkProcessHelper::IsForkedMultithreadInstance());
	}
}

namespace
{
	// Helper functions to return the right named member container based on a datum type
	template <typename DatumType> FORCEINLINE TArray<TUniquePtr<TTraceThreadData<DatumType    >>>& GetTraceContainer               (AsyncTraceData& DataBuffer);
	template <>                   FORCEINLINE TArray<TUniquePtr<TTraceThreadData<FTraceDatum  >>>& GetTraceContainer<FTraceDatum>  (AsyncTraceData& DataBuffer) { return DataBuffer.TraceData;   }
	template <>                   FORCEINLINE TArray<TUniquePtr<TTraceThreadData<FOverlapDatum>>>& GetTraceContainer<FOverlapDatum>(AsyncTraceData& DataBuffer) { return DataBuffer.OverlapData; }

	// Helper functions to return the right named member trace index based on a datum type