UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TimerHandle.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "TimerHandle.generated.h"
6
8
10USTRUCT(BlueprintType)
12{
14
17
19 : Handle(0)
20 {
21 }
22
24 bool IsValid() const
25 {
26 return Handle != 0;
27 }
28
31 {
32 Handle = 0;
33 }
34
35 bool operator==(const FTimerHandle& Other) const
36 {
37 return Handle == Other.Handle;
38 }
39
40 bool operator!=(const FTimerHandle& Other) const
41 {
42 return Handle != Other.Handle;
43 }
44
45 FString ToString() const
46 {
47 return FString::Printf(TEXT("%llu"), Handle);
48 }
49
50private:
51 static constexpr uint32 IndexBits = 24;
52 static constexpr uint32 SerialNumberBits = 40;
53
54 static_assert(IndexBits + SerialNumberBits == 64, "The space for the timer index and serial number should total 64 bits");
55
56 static constexpr int32 MaxIndex = (int32)1 << IndexBits;
57 static constexpr uint64 MaxSerialNumber = (uint64)1 << SerialNumberBits;
58
59 void SetIndexAndSerialNumber(int32 Index, uint64 SerialNumber)
60 {
61 check(Index >= 0 && Index < MaxIndex);
62 check(SerialNumber < MaxSerialNumber);
63 Handle = (SerialNumber << IndexBits) | (uint64)(uint32)Index;
64 }
65
66 inline int32 GetIndex() const
67 {
68 return (int32)(Handle & (uint64)(MaxIndex - 1));
69 }
70
71 inline uint64 GetSerialNumber() const
72 {
73 return Handle >> IndexBits;
74 }
75
78
80 {
81 return GetTypeHash(InHandle.Handle);
82 }
83};
#define check(expr)
Definition AssertionMacros.h:314
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_DYNAMIC_DELEGATE(DelegateName)
Definition DelegateCombinations.h:35
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define USTRUCT(...)
Definition ObjectMacros.h:746
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition TimerManager.h:133
U16 Index
Definition radfft.cpp:71
Definition TimerHandle.h:12
bool operator==(const FTimerHandle &Other) const
Definition TimerHandle.h:35
FString ToString() const
Definition TimerHandle.h:45
void Invalidate()
Definition TimerHandle.h:30
bool operator!=(const FTimerHandle &Other) const
Definition TimerHandle.h:40
friend uint32 GetTypeHash(const FTimerHandle &InHandle)
Definition TimerHandle.h:79
bool IsValid() const
Definition TimerHandle.h:24
Definition TimerManager.cpp:253