Ticker class. 更多...
#include <Ticker.h>
类 FTicker 继承关系图:类 | |
| struct | FElement |
| Element of the priority queue 更多... | |
Public 成员函数 | |
| CORE_API FDelegateHandle | AddTicker (const FTickerDelegate &InDelegate, float InDelay=0.0f) |
| Add a new ticker with a given delay / interval 更多... | |
| CORE_API FDelegateHandle | AddTicker (const TCHAR *InName, float InDelay, TFunction< bool(float)> Function) |
| Add a new ticker with a given delay / interval. 更多... | |
| CORE_API void | RemoveTicker (FDelegateHandle Handle) |
| Removes a previously added ticker delegate. 更多... | |
| CORE_API void | Tick (float DeltaTime) |
| Fire all tickers who have passed their delay and reschedule the ones that return true 更多... | |
静态 Public 成员函数 | |
| static CORE_API FTicker & | GetCoreTicker () |
| Singleton used for the ticker in Core / Launch. 更多... | |
Protected 属性 | |
| bool | bCurrentElementRemoved |
| State to track whether the CurrentElement removed itself during its own delegate execution. | |
| bool | bInTick |
| State to track whether CurrentElement is valid. | |
| FElement | CurrentElement |
| Current element being ticked (only valid during tick). | |
| double | CurrentTime |
| Current time of the ticker | |
| TArray< FElement, TInlineAllocator< 1 > > | Elements |
| Future delegates to fire | |
| TArray< FElement, TInlineAllocator< 1 > > | TickedElements |
| List of delegates that have been considered during Tick. 更多... | |
Ticker class.
Fires delegates after a delay.
Note: Do not try to add the same delegate instance twice, as there is no way to remove only a single instance (see member RemoveTicker).
| CORE_API FDelegateHandle FTicker::AddTicker | ( | const FTickerDelegate & | InDelegate, |
| float | InDelay = 0.0f |
||
| ) |
Add a new ticker with a given delay / interval
| InDelegate | Delegate to fire after the delay |
| InDelay | Delay until next fire; 0 means "next frame" |
| CORE_API FDelegateHandle FTicker::AddTicker | ( | const TCHAR * | InName, |
| float | InDelay, | ||
| TFunction< bool(float)> | Function | ||
| ) |
Add a new ticker with a given delay / interval.
| 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 |
Singleton used for the ticker in Core / Launch.
If you add a new ticker for a different subsystem, do not put that singleton here!
| CORE_API void FTicker::RemoveTicker | ( | FDelegateHandle | Handle | ) |
Removes a previously added ticker delegate.
Note: will remove ALL tickers that use this handle, as there's no way to uniquely identify which one you are trying to remove.
| Handle | The handle of the ticker to remove. |
| CORE_API void FTicker::Tick | ( | float | DeltaTime | ) |
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.
| DeltaTime | time that has passed since the last tick call |
|
protected |
List of delegates that have been considered during Tick.
Either they been fired or are not yet ready.