AutoResetEvent class
An auto-reset event for tasks.
- Use
import ThinkMeta.ConcurrentTasks.Synchronization.AutoResetEvent;- Namespace
ThinkMeta::ConcurrentTasks::Synchronization- Inherits
Waitable,ISuspendCallback- Platforms
- Windows, Linux
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; with AutoResetEvent, Sets from several threads at the same moment may also count as one while tasks wait, so to count every signal use a Semaphore. 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. A CancelTask does not end it; Wait with Duration::Infinite waits until either.
See also
Waits for the signal with a time limit.
Syntax
[[nodiscard]] WaitStatus Wait(Duration timeout) noexcept;Parameters
timeoutDuration- The longest time to wait. Needs
EnableTimers; without it, or withDuration::Infinite, the wait has no limit.
Return value
Type: WaitStatus
WaitStatus::Signaled if the signal was taken; WaitStatus::TimedOut if it timed out; WaitStatus::Cancelled if the task was cancelled (CancelTask). Unless signaled, 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 @ c7663c4 (2026-11-19).