http.CurlEventLoopEnableChance
http.CurlEventLoopEnableChance
#Overview
name: http.CurlEventLoopEnableChance
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Enable chance of event loop, from 0 to 100
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of http.CurlEventLoopEnableChance is to control the probability of enabling the event loop for HTTP operations in Unreal Engine’s HTTP module, specifically for the cURL implementation.
This setting variable is primarily used by the HTTP module, which is part of Unreal Engine’s Online subsystem. It directly affects the behavior of the cURL HTTP manager, which handles HTTP requests and responses.
The value of this variable is set through a console variable (CVarHttpEventLoopEnableChance) with a default value defined by UE_HTTP_EVENT_LOOP_ENABLE_CHANCE_BY_DEFAULT. It can be changed at runtime through console commands or potentially through configuration files.
The associated variable CVarHttpEventLoopEnableChance interacts directly with http.CurlEventLoopEnableChance. They share the same value and purpose.
Developers must be aware that this variable determines the likelihood of using an event loop for HTTP operations. The value ranges from 0 to 100, representing a percentage chance. A higher value increases the probability of using the event loop.
Best practices when using this variable include:
- Understanding the performance implications of enabling or disabling the event loop for your specific use case.
- Testing your application with different values to find the optimal setting for your networking requirements.
- Being cautious when changing this value, as it affects the core behavior of HTTP operations in the engine.
Regarding the associated variable CVarHttpEventLoopEnableChance:
Its purpose is to provide programmatic access to the http.CurlEventLoopEnableChance setting within the C++ code.
It is used in the HTTP module, specifically in the CurlHttpManager class, to determine whether to use an event loop for HTTP operations.
The value is set when the console variable is initialized and can be accessed at runtime using the GetValueOnGameThread() method.
This variable directly interacts with the logic that decides whether to use an event loop for each HTTP thread created.
Developers should be aware that this variable is used in a random check to determine the use of an event loop, so the behavior may vary between runs of the application.
Best practices include:
- Using GetValueOnGameThread() when accessing the value to ensure thread-safety.
- Considering the impact on performance and behavior when modifying this value during runtime.
- Being aware that command-line arguments can override this setting, which may be useful for testing or debugging purposes.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Online/HTTP/Private/HttpModule.cpp:23
Scope: file
Source code excerpt:
TAutoConsoleVariable<int32> CVarHttpEventLoopEnableChance(
TEXT("http.CurlEventLoopEnableChance"),
UE_HTTP_EVENT_LOOP_ENABLE_CHANCE_BY_DEFAULT,
TEXT("Enable chance of event loop, from 0 to 100"),
ECVF_SaveForNextBoot
);
DEFINE_LOG_CATEGORY(LogHttp);
#Associated Variable and Callsites
This variable is associated with another variable named CVarHttpEventLoopEnableChance
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Online/HTTP/Private/Curl/CurlHttpManager.cpp:37
Scope: file
Source code excerpt:
#endif
extern TAutoConsoleVariable<int32> CVarHttpEventLoopEnableChance;
CURLM* FCurlHttpManager::GMultiHandle = nullptr;
#if !WITH_CURL_XCURL
CURLSH* FCurlHttpManager::GShareHandle = nullptr;
#endif
#Loc: <Workspace>/Engine/Source/Runtime/Online/HTTP/Private/Curl/CurlHttpManager.cpp:447
Scope (from outer to inner):
file
function FHttpThreadBase* FCurlHttpManager::CreateHttpThread
Source code excerpt:
FHttpThreadBase* FCurlHttpManager::CreateHttpThread()
{
bool bUseEventLoop = (FMath::RandRange(0, 99) < CVarHttpEventLoopEnableChance.GetValueOnGameThread());
// Also support to change it through runtime args.
// Can't set cvar CVarHttpEventLoopEnableChance through runtime args or .ini files because http module initialized too early
FParse::Bool(FCommandLine::Get(), TEXT("useeventloop="), bUseEventLoop);
if (bUseEventLoop)
{
#if WITH_CURL_MULTIPOLL
UE_LOG(LogInit, Log, TEXT("CreateHttpThread using FCurlMultiPollEventLoopHttpThread"));
#Loc: <Workspace>/Engine/Source/Runtime/Online/HTTP/Private/HttpModule.cpp:22
Scope: file
Source code excerpt:
#endif
TAutoConsoleVariable<int32> CVarHttpEventLoopEnableChance(
TEXT("http.CurlEventLoopEnableChance"),
UE_HTTP_EVENT_LOOP_ENABLE_CHANCE_BY_DEFAULT,
TEXT("Enable chance of event loop, from 0 to 100"),
ECVF_SaveForNextBoot
);