Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/Async
References
| Module | Core |
| Header | /Engine/Source/Runtime/Core/Public/Async/EventCount.h |
| Include | #include "Async/EventCount.h" |
Syntax
template<typename CounterType>
class TEventCount
Remarks
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: ++CurrentValue; 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.
Constructors
| Type | Name | Description | |
|---|---|---|---|
| constexpr | TEventCount () |
||
TEventCount
(
const TEventCount& |
Functions
| Type | Name | Description | |
|---|---|---|---|
| void | Notify () |
Notifies all waiting threads. | |
| TEventCountToken< CounterType > | PrepareWait () |
Prepare to wait. | |
| void | Wait
(
TEventCountToken< CounterType > Compare |
Wait until the event is notified. Returns immediately if notified since the token was acquired. | |
| bool | WaitFor
(
TEventCountToken< CounterType > Compare, |
Wait until the event is notified. Returns immediately if notified since the token was acquired. | |
| bool | WaitUntil
(
TEventCountToken< CounterType > Compare, |
Wait until the event is notified. Returns immediately if notified since the token was acquired. |
Operators
| Type | Name | Description | |
|---|---|---|---|
| TEventCount & | operator=
(
const TEventCount& |