Preliminary. ThinkMeta ConcurrentTasks and this documentation are preliminary; everything is subject to change.

API reference / Synchronization

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

_SuspensionKindSuspensionKind
SuspensionKind::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

NameDescription
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 AutoResetEvent, allows timeouts; the waiter may destroy it after its wait.

Constructors

AutoResetEvent

Creates the event.

Syntax

explicit AutoResetEvent(bool isSet = false) noexcept;

Parameters

isSetbool
true to 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

Sets the event.

Syntax

void Set() noexcept;

Remarks

Resumes one suspended waiter, which receives the signal (the event stays reset), or leaves the event set if no waiter is suspended. Never suspends.

See also

Reset, Wait

Reset

Clears the signal.

Syntax

void Reset() noexcept;

Remarks

Suspended waiters stay suspended. Never suspends.

See also

Set

TryWait

Takes the signal if the event is set.

Syntax

[[nodiscard]] bool TryWait() noexcept;

Return value

Type: bool

true if the signal was taken; the caller then counts as having passed a Wait. false if the event was not set.

Remarks

The event is then reset. Never suspends.

See also

Wait

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

TryWait

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

TryWait

Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).