Navigation
API > API/Runtime > API/Runtime/EventLoop
Timer manager for posting timers to an event loop.
The event loop timer manager provides the guarantee that its timers will never fire early while only progressing its view of time based on the delta passed to its Tick method. To provide this guarantee, timers may fire later than requested which is by design.
Adding and removing timers are thread-safe, however the timer callback and clear callbacks will both be called from within the Tick method, which may be a different thread. It is up to the user to handle thread safety within their callbacks.
| Name | TTimerManager |
| Type | class |
| Header File | /Engine/Source/Runtime/Online/Experimental/EventLoop/Public/EventLoop/EventLoopTimer.h |
| Include Path | #include "EventLoop/EventLoopTimer.h" |
Syntax
template<typename Traits>
class TTimerManager : public FNoncopyable
Inheritance Hierarchy
- FNoncopyable → TTimerManager
Structs
| Name | Remarks |
|---|---|
| FTimerHeapOrder |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FInternalHandle | typename FStorageType::FInternalHandle | EventLoop/EventLoopTimer.h | |
| FInternalHandleArryType | typename FStorageType::FInternalHandleArryType | EventLoop/EventLoopTimer.h | |
| FStorageType | TManagedStorage< FTimerData, typename Traits::FStorageTraits > | EventLoop/EventLoopTimer.h | |
| FTimerHandle | typename FStorageType::FExternalHandle | EventLoop/EventLoopTimer.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| ActiveTimerHeap | TArray< FInternalHandle, typename Traits::FTimerHeapAllocatorType > | Heap of actively running timers. | EventLoop/EventLoopTimer.h | |
| bIsTicking | bool | Track whether the timer manager is in the process of ticking. | EventLoop/EventLoopTimer.h | |
| InternalTime | FTimespan | An internally consistent clock. Advances during ticking. | EventLoop/EventLoopTimer.h | |
| PendingRepeatTimers | TArray< FInternalHandle, typename Traits::FTimerRepeatAllocatorType > | Timers which will be rescheduled on the next call to Tick. | EventLoop/EventLoopTimer.h | |
| Storage | FStorageType | Storage for timer entries. | EventLoop/EventLoopTimer.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void ClearTimer
(
FTimerHandle& InHandle, |
Clears a previously set timer.Thread safe. | EventLoop/EventLoopTimer.h | |
bool GetNextTimeout
(
FTimespan& OutTimeout |
Retrieve the remaining time since the last call to Tick before the next timer will fire. | EventLoop/EventLoopTimer.h | |
uint32 GetNumTimers () |
Returns the total number of timers. | EventLoop/EventLoopTimer.h | |
bool HasPendingRepeatTimer() |
Returns whether any timers are waiting to be rescheduled.NOT thread safe. | EventLoop/EventLoopTimer.h | |
void Init() |
Initialize the timer manager and its storage.NOT thread safe. | EventLoop/EventLoopTimer.h | |
FTimerHandle SetTimer
(
FTimerCallback&& Callback, |
Set a new timer. | EventLoop/EventLoopTimer.h | |
void Tick
(
FTimespan DeltaTime |
Accumulate the timer managers elapsed time and fire timers which have elapsed.NOT thread safe. | EventLoop/EventLoopTimer.h |