![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <Ticker.h>
Inheritance diagram for FTSTicker:Public Types | |
| using | FDelegateHandle = TWeakPtr< FElement > |
Public Member Functions | |
| CORE_API FDelegateHandle | AddTicker (const FTickerDelegate &InDelegate, float InDelay=0.0f) |
| CORE_API FDelegateHandle | AddTicker (const TCHAR *InName, float InDelay, TUniqueFunction< bool(float)> &&InFunction) |
| CORE_API void | Tick (float DeltaTime) |
| CORE_API void | Reset () |
Static Public Member Functions | |
| static CORE_API FTSTicker & | GetCoreTicker () |
| static CORE_API void | RemoveTicker (FDelegateHandle Handle) |
Thread-safe ticker class. Fires delegates after a delay.
| using FTSTicker::FDelegateHandle = TWeakPtr<FElement> |
| FTSTicker::FDelegateHandle FTSTicker::AddTicker | ( | const FTickerDelegate & | InDelegate, |
| float | InDelay = 0.0f |
||
| ) |
Add a new ticker with a given delay / interval
Can be called concurrently. Resources used by the delegate must be released on the ticking thread.
| InDelegate | Delegate to fire after the delay |
| InDelay | Delay until next fire; 0 means "next frame" |
| FTSTicker::FDelegateHandle FTSTicker::AddTicker | ( | const TCHAR * | InName, |
| float | InDelay, | ||
| TUniqueFunction< bool(float)> && | InFunction | ||
| ) |
Add a new ticker with a given delay / interval.
Can be called concurrently.
| InName | Name of this ticker for profiling |
| InDelay | Delay until next fire; 0 means "next frame" |
| Function | Function to execute. Should return true to fire after another InDelay time |
|
static |
|
static |
Removes a previously added ticker delegate.
Can be called concurrently. If is called in the middle of the delegate execution, it blocks until the execution finishes, and thus guarantees that the delegate won't be executed after the call.
| Handle | The handle of the ticker to remove. |
| void FTSTicker::Reset | ( | ) |
Resets the instance to its default state. Must be called from the ticking thread.
Fire all tickers who have passed their delay and reschedule the ones that return true
Note: This reschedule has timer skew, meaning we always wait a full Delay period after each invocation even if we missed the last interval by a bit. For instance, setting a delay of 0.1 seconds will not necessarily fire the delegate 10 times per second, depending on the Tick() rate. What this DOES guarantee is that a delegate will never be called MORE FREQUENTLY than the Delay interval, regardless of how far we miss the scheduled interval.
Must not be called concurrently.
| DeltaTime | time that has passed since the last tick call |