AutoResetEvent class
An auto-reset event for tasks.
- Use
import ThinkMeta.ConcurrentTasks.Synchronization.AutoResetEvent;- Namespace
ThinkMeta::ConcurrentTasks::Synchronization- Inherits
Waitable,ISuspendCallback
Syntax
using AutoResetEvent = _AutoResetEvent<SuspensionKind::Multiple>;
using AutoResetEvent_s = _AutoResetEvent<SuspensionKind::Single>;Template parameters
_SuspensionKindSuspensionKindSuspensionKind::Multiple: any number of waiting tasks;SuspensionKind::Single: at most one waiting task at a time, cheaper, with timeouts.
Remarks
Set lets one waiter pass (or, with no waiter, stays set until one TryWait / Wait takes the signal). Several Sets without a waiter in between count as one. Comes as AutoResetEvent (any number of waiters) and AutoResetEvent_s (one waiter). Wait suspends the calling task and needs a task or an OS thread converted with ConvertThreadToTask. Set, Reset and TryWait never suspend and may be called from any thread. No member reports errors. AutoResetEvent: any number of waiters, woken in LIFO order without fairness; no timeouts. Destroy the event only when no task can wait on it or set it any more; the return of a Wait alone does not mean that (AutoResetEvent_s allows destroying it right after the wait).
See also
ManualResetEvent, SuspensionKind
Names
| Name | Description |
|---|---|
AutoResetEvent |
Auto-reset event for any number of waiting tasks (no timeouts). |
AutoResetEvent_s |
Auto-reset event for at most one waiting task.
Cheaper than |
Constructors
AutoResetEvent
Creates the event.
Syntax
explicit AutoResetEvent(bool isSet = false) noexcept;Parameters
isSetbooltrueto create it set.Default:false
~AutoResetEvent
Destroys the event.
Syntax
~AutoResetEvent() noexcept;Remarks
No task may be waiting on it (asserted in Debug).
Methods
Set
Reset
Clears the signal.
Syntax
void Reset() noexcept;Remarks
Suspended waiters stay suspended. Never suspends.
See also
TryWait
Resume
Resumes one waiting task without touching the signal.
Syntax
void Resume() noexcept;Remarks
Part of the wait protocol; application code uses Set instead.
Wait
Waits for the signal and takes it.
Syntax
void Wait() noexcept;Remarks
Suspends the calling task until a Set if the event is reset. Task or converted thread only; at most one waiter at a time.
See also
Waits for the signal with a time limit.
Syntax
[[nodiscard]] bool Wait(Duration timeout) noexcept;Parameters
timeoutDuration- The longest time to wait. Needs
EnableTimers; without it the wait has no limit.
Return value
Type: bool
true if the signal was taken; false if it timed out: the signal was not taken and the task no longer waits on the event.
Remarks
Task or converted thread only.
See also
Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).