tick.SecondsBeforeEmbeddedAppSleeps
tick.SecondsBeforeEmbeddedAppSleeps
#Overview
name: tick.SecondsBeforeEmbeddedAppSleeps
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
When built as embedded, how many ticks to perform before sleeping
It is referenced in 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of tick.SecondsBeforeEmbeddedAppSleeps is to control the behavior of embedded applications in Unreal Engine, specifically determining how long the engine should run before allowing the embedded application to sleep.
This setting variable is primarily used in the Launch module of Unreal Engine, as evidenced by its presence in the LaunchEngineLoop.cpp file. It’s particularly relevant for embedded applications, which are typically resource-constrained environments where efficient power management is crucial.
The value of this variable is set using a TAutoConsoleVariable, which allows it to be modified at runtime through console commands. Its default value is set to 1 second.
The associated variable CVarSecondsBeforeEmbeddedAppSleeps interacts directly with tick.SecondsBeforeEmbeddedAppSleeps. They share the same value and purpose, with CVarSecondsBeforeEmbeddedAppSleeps being the C++ variable that holds and provides access to the value set by tick.SecondsBeforeEmbeddedAppSleeps.
Developers must be aware that this variable affects the performance and power consumption of embedded applications. Setting it too low might cause frequent sleep cycles, potentially impacting performance, while setting it too high might waste power by keeping the application active unnecessarily.
Best practices when using this variable include:
- Adjusting it based on the specific needs of the embedded application.
- Monitoring its impact on performance and power consumption.
- Using it in conjunction with other embedded-specific optimizations.
Regarding the associated variable CVarSecondsBeforeEmbeddedAppSleeps:
- Its purpose is to provide a programmatic interface to the tick.SecondsBeforeEmbeddedAppSleeps setting.
- It’s used in the Launch module of Unreal Engine.
- Its value is set by the tick.SecondsBeforeEmbeddedAppSleeps console variable.
- It’s used to determine when to allow sleep in embedded applications, as seen in the FEmbeddedCommunication::AllowSleep call.
- Developers should be aware that changes to this variable will directly affect the behavior of embedded applications.
- Best practices include using GetValueOnAnyThread() for thread-safe access to its value, and considering its impact on application responsiveness and power consumption when modifying it.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:333
Scope: file
Source code excerpt:
static TAutoConsoleVariable<float> CVarSecondsBeforeEmbeddedAppSleeps(
TEXT("tick.SecondsBeforeEmbeddedAppSleeps"),
1,
TEXT("When built as embedded, how many ticks to perform before sleeping")
);
/** Task that executes concurrently with Slate when tick.DoAsyncEndOfFrameTasks is true. */
class FExecuteConcurrentWithSlateTickTask
#Associated Variable and Callsites
This variable is associated with another variable named CVarSecondsBeforeEmbeddedAppSleeps
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:332
Scope: file
Source code excerpt:
);
static TAutoConsoleVariable<float> CVarSecondsBeforeEmbeddedAppSleeps(
TEXT("tick.SecondsBeforeEmbeddedAppSleeps"),
1,
TEXT("When built as embedded, how many ticks to perform before sleeping")
);
/** Task that executes concurrently with Slate when tick.DoAsyncEndOfFrameTasks is true. */
#Loc: <Workspace>/Engine/Source/Runtime/Launch/Private/LaunchEngineLoop.cpp:6229
Scope: file
Source code excerpt:
static double LastSleepTime = FPlatformTime::Seconds();
double TimeNow = FPlatformTime::Seconds();
if (LastSleepTime > 0 && TimeNow - LastSleepTime >= CVarSecondsBeforeEmbeddedAppSleeps.GetValueOnAnyThread())
{
LastSleepTime = 0;
FEmbeddedCommunication::AllowSleep(TEXT("FirstTicks"));
}
#endif
}