Navigation
API > API/Runtime > API/Runtime/Core
A type of event that avoids missed notifications by maintaining a notification count.
This type of event is suited to waiting on another thread conditionally. Typical usage looks similar to this example: FEventCount Event;
std::atomic
On the waiting thread: FEventCountToken Token = Event.PrepareWait(); if (CurrentValue < TargetValue) { Event.Wait(Token); }
On the notifying thread: if (++CurrentValue == TargetValue) { Event.Notify(); }
Acquiring a token before checking the condition avoids a race because Wait returns immediately when the token no longer matches the notification count.
| Name | TEventCount |
| Type | class |
| Header File | /Engine/Source/Runtime/Core/Public/Async/EventCount.h |
| Include Path | #include "Async/EventCount.h" |
Syntax
template<typename CounterType>
class TEventCount
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
constexpr TEventCount () |
Async/EventCount.h | ||
TEventCount
(
const TEventCount& |
Async/EventCount.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Count | std::atomic< CounterType > | Async/EventCount.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
void Notify () |
Notifies all waiting threads. | Async/EventCount.h | |
void NotifyWeak () |
Notifies all waiting threads. | Async/EventCount.h | |
TEventCountToken< CounterType > PrepareWait () |
Prepare to wait. | Async/EventCount.h | |
void Wait
(
TEventCountToken< CounterType > Compare |
Wait until the event is notified. Returns immediately if notified since the token was acquired. | Async/EventCount.h | |
bool WaitFor
(
TEventCountToken< CounterType > Compare, |
Wait until the event is notified. Returns immediately if notified since the token was acquired. | Async/EventCount.h | |
bool WaitUntil
(
TEventCountToken< CounterType > Compare, |
Wait until the event is notified. Returns immediately if notified since the token was acquired. | Async/EventCount.h |
Operators
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
TEventCount & operator=
(
const TEventCount& |
Async/EventCount.h |