UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
ConditionVariable.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "Async/ParkingLot.h"
6
7namespace UE
8{
9
14{
15public:
16 constexpr FConditionVariable() = default;
17
20
21 void NotifyOne()
22 {
23 if (bHasWaiters)
24 {
25 ParkingLot::WakeOne(
26 &bHasWaiters,
28 {
29 if (!WakeState.bHasWaitingThreads)
30 bHasWaiters = false;
31 return 0;
32 });
33 }
34 }
35
36 void NotifyAll()
37 {
38 if (bHasWaiters)
39 {
40 bHasWaiters = false;
41 ParkingLot::WakeAll(&bHasWaiters);
42 }
43 }
44
45 template<typename TLock>
47 {
49 &bHasWaiters,
50 [this] () -> bool
51 {
52 bHasWaiters = true;
53 return true;
54 },
55 [&Lock] ()
56 {
57 Lock.Unlock();
58 });
59 Lock.Lock();
60 }
61
62private:
63 std::atomic<bool> bHasWaiters = false;
64};
65
66} // namespace UE
67
68
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
Definition ConditionVariable.h:14
void Wait(TLock &Lock)
Definition ConditionVariable.h:46
void NotifyAll()
Definition ConditionVariable.h:36
constexpr FConditionVariable()=default
FConditionVariable & operator=(const FConditionVariable &)=delete
void NotifyOne()
Definition ConditionVariable.h:21
FConditionVariable(const FConditionVariable &)=delete
FWaitState Wait(const void *Address, TFunctionWithContext< bool()> CanWait, TFunctionWithContext< void()> BeforeWait)
Definition ParkingLot.h:52
Definition AdvancedWidgetsModule.cpp:13
Definition ParkingLot.h:30