UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
Lock.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Trace/Config.h"
7#include "Platform.h"
8
9#if TRACE_PRIVATE_MINIMAL_ENABLED
10
11namespace UE {
12namespace Trace {
13namespace Private {
14
15struct FLock
16{
17 FLock(volatile uint8* InLock)
18 : Lock(InLock)
19 {
21 StartSeconds = GetTime();
22
24 {
25 ThreadSleep(0);
26
27 if (TimedOut())
28 {
29 break;
30 }
31 }
32 }
33
34 ~FLock()
35 {
37 }
38
39 double GetTime()
40 {
41 return static_cast<double>(TimeGetTimestamp()) / static_cast<double>(CyclesPerSecond);
42 }
43
44 bool TimedOut()
45 {
46 const double WaitTime = GetTime() - StartSeconds;
47 return WaitTime > MaxWaitSeconds;
48 }
49
50 volatile uint8* Lock;
52 double StartSeconds;
53 inline const static double MaxWaitSeconds = 1.0;
54};
55
56}}}
57
58#endif
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
FRWLock Lock
Definition UnversionedPropertySerialization.cpp:921
uint8_t uint8
Definition binka_ue_file_header.h:8
@ Trace
Definition NetTraceConfig.h:23
Definition OverriddenPropertySet.cpp:45
bool AtomicCompareExchangeAcquire(Type volatile *Target, Type New, Type Expected)
Definition Atomic.h:115
Type AtomicExchangeRelease(Type volatile *Target, Type Value)
Definition Atomic.h:99
Definition AdvancedWidgetsModule.cpp:13