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.

On this page
Use
import ThinkMeta.ConcurrentTasks.Synchronization.Semaphore;
Namespace
ThinkMeta::ConcurrentTasks::Synchronization
Platforms
Windows, Linux

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 the processor's pause 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,
    std::uint32_t spinCount
) noexcept;

Parameters

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

~SpinSemaphoreLock

Releases the permit.

Syntax

~SpinSemaphoreLock() noexcept;

Generated from ThinkMeta.ConcurrentTasks.API @ c7663c4 (2026-11-19).