UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PlatformEvents.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2#pragma once
3
4#include "CoreTypes.h"
6#include "Trace/Trace.h"
7#include "Trace/Trace.inl"
8
9class FString;
10
11#if !defined(PLATFORM_SUPPORTS_PLATFORM_EVENTS)
12# define PLATFORM_SUPPORTS_PLATFORM_EVENTS 0
13#endif
14
16
19
20
21
23{
24public:
25 enum class EEventType
26 {
27 None = 0x00,
28 ContextSwitch = 0x01,
29 StackSampling = 0x02,
30 };
31
32 CORE_API static EEventType GetEvent(const FString& Name);
33
34#if PLATFORM_SUPPORTS_PLATFORM_EVENTS
35
37 CORE_API static void PostInit();
38 CORE_API static bool CanEnable(EEventType Event, const TCHAR** OutReason);
39 CORE_API static void Enable(EEventType Event);
40 CORE_API static void Disable(EEventType Event);
41 CORE_API static void Stop();
42 UE_DEPRECATED(5.7, "Use channel callback instead.")
43 CORE_API static void OnTraceChannelUpdated(const FString& ChannelName, bool bIsEnabled);
44
46 CORE_API static void OutputContextSwitch(uint64 StartTime, uint64 EndTime, uint32 ThreadId, uint8 CoreNumber);
47 CORE_API static void OutputStackSample(uint64 Time, uint32 ThreadId, const uint64* Addresses, uint32 AddressCount);
48 CORE_API static void OutputThreadName(uint32 ThreadId, uint32 ProcessId, const TCHAR* Name, uint32 NameLen);
49
50#else // PLATFORM_SUPPORTS_PLATFORM_EVENTS
51
53 static void PostInit() {}
54 static void Enable(EEventType Event) {}
55 static void Disable(EEventType Event) {}
56 static void Stop() {}
57 static void OnTraceChannelUpdated(const FString& ChannelName, bool bIsEnabled) {}
58
59 static void OutputContextSwitch(uint64 StartTime, uint64 EndTime, uint32 ThreadId, uint8 CoreNumber) {}
60 static void OutputStackSample(uint64 Time, uint32 ThreadId, const uint64* Addresses, uint32 AddressCount) {}
61 static void OutputThreadName(uint32 ThreadId, uint32 ProcessId, const TCHAR* Name, uint32 NameLen) {}
62
63#endif // PLATFORM_SUPPORTS_PLATFORM_EVENTS
64};
65
67
68
69
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
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 ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
void Init()
Definition LockFreeList.h:4
@ Stop
Definition PrecomputedVolumetricLightmapStreaming.cpp:26
#define UE_TRACE_CHANNEL_CUSTOM_EXTERN(ChannelName, ChannelClass,...)
Definition Trace.h:449
uint8_t uint8
Definition binka_ue_file_header.h:8
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition PlatformEvents.h:23
static void Init(uint32 SamplingIntervalUsec)
Definition PlatformEvents.h:52
static void Stop()
Definition PlatformEvents.h:56
static void Enable(EEventType Event)
Definition PlatformEvents.h:54
static void OutputContextSwitch(uint64 StartTime, uint64 EndTime, uint32 ThreadId, uint8 CoreNumber)
Definition PlatformEvents.h:59
static CORE_API EEventType GetEvent(const FString &Name)
static void PostInit()
Definition PlatformEvents.h:53
static void OutputThreadName(uint32 ThreadId, uint32 ProcessId, const TCHAR *Name, uint32 NameLen)
Definition PlatformEvents.h:61
EEventType
Definition PlatformEvents.h:26
static void OnTraceChannelUpdated(const FString &ChannelName, bool bIsEnabled)
Definition PlatformEvents.h:57
static void Disable(EEventType Event)
Definition PlatformEvents.h:55
static void OutputStackSample(uint64 Time, uint32 ThreadId, const uint64 *Addresses, uint32 AddressCount)
Definition PlatformEvents.h:60