![]() |
UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
|
#include <EventCount.h>
Public Member Functions | |
| constexpr | TEventCount ()=default |
| TEventCount (const TEventCount &)=delete | |
| TEventCount & | operator= (const TEventCount &)=delete |
| TEventCountToken< CounterType > | PrepareWait () |
| void | Wait (TEventCountToken< CounterType > Compare) |
| bool | WaitFor (TEventCountToken< CounterType > Compare, FMonotonicTimeSpan WaitTime) |
| bool | WaitUntil (TEventCountToken< CounterType > Compare, FMonotonicTimePoint WaitTime) |
| void | Notify () |
| void | NotifyWeak () |
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<uint32> CurrentValue = 0;
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.
|
constexprdefault |
|
delete |
|
inline |
Notifies all waiting threads.
Any threads that have called PrepareWait() and not yet waited will be notified immediately if they do wait on a token from a call to PrepareWait() that preceded this call.
|
inline |
Notifies all waiting threads.
Any threads that have called PrepareWait() and not yet waited will be notified immediately if they do wait on a token from a call to PrepareWait() that preceded this call. Note: This version doesn't provide a memory barrier, you are responsible for the memory ordering for the value you're synchronizing this eventcount with.
|
delete |
|
inline |
Prepare to wait.
Call this before any logic that must re-execute if the event is notified in the meantime.
|
inline |
Wait until the event is notified. Returns immediately if notified since the token was acquired.
| Compare | A token acquired from PrepareWait() before checking the conditions for this wait. |
|
inline |
Wait until the event is notified. Returns immediately if notified since the token was acquired.
| Compare | A token acquired from PrepareWait() before checking the conditions for this wait. |
| WaitTime | Relative time after which waiting is automatically canceled and the thread wakes. |
|
inline |
Wait until the event is notified. Returns immediately if notified since the token was acquired.
| Compare | A token acquired from PrepareWait() before checking the conditions for this wait. |
| WaitTime | Absolute time after which waiting is automatically canceled and the thread wakes. |