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

API reference / Synchronization

SpinSemaphoreLock class

Scope guard that holds one permit of a semaphore, spinning before it suspends.

Use
import ThinkMeta.ConcurrentTasks.Synchronization.Semaphore;
Namespace
ThinkMeta::ConcurrentTasks::Synchronization

Syntax

template <SemaphoreType _SemaphoreType>
class [[nodiscard("Discarding a lock guard immediately releases the lock.")]]
    SpinSemaphoreLock

Template parameters

_SemaphoreTypeSemaphoreType
The semaphore type: Semaphore or Semaphore_s.

Remarks

Up to spinCount Semaphore::TryWait attempts (with YieldProcessor in between, the thread is not given up), then a suspending Semaphore::Wait. Releases one permit on destruction. Task or converted thread only.

See also

SemaphoreLock

Constructors

SpinSemaphoreLock

Takes one permit, spinning first.

Syntax

explicit SpinSemaphoreLock(
    _SemaphoreType& semaphore,
    unsigned long spinCount
) noexcept;

Parameters

semaphore_SemaphoreType&
The semaphore; it must outlive the guard.
spinCountunsigned long
The maximum number of spin attempts (0: Semaphore::Wait at once).

~SpinSemaphoreLock

Releases the permit.

Syntax

~SpinSemaphoreLock() noexcept;

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