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.")]]
SpinSemaphoreLockTemplate parameters
_SemaphoreTypeSemaphoreType- The semaphore type:
SemaphoreorSemaphore_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
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::Waitat once).
~SpinSemaphoreLock
Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).