counting_semaphore |
A counting semaphore is a
generalization of a mutex semaphore that allows multiple resources to be locked
and unlocked. Threads can use the blocking method lock()
to acquire a single resource, or they can use the method try_lock()
to attempt acquisition of one or more resources without blocking.
Unlike the os_mutex_semaphore
, an os_counting_semaphore is not owned by a
particular thread; it is simply owned. One thread can wait()
and a different thread can post() to increase the
available resource count and unblock waiters. Contrast this with an os_mutex_semaphore
, where the same thread that waits (and acquires the resource) must also post to
release the resource.
Throws: os_thread_toolkit_error
Throws: os_thread_toolkit_error
Throws: os_thread_toolkit_error
1
). If no resources are present, blocks until one becomes
available. Throws: os_thread_toolkit_error
lock()
; alternative acquisition syntax. Throws: os_thread_toolkit_error
unlock()
; alternative event syntax. Throws: os_thread_toolkit_error
Throws: os_thread_toolkit_error
unlock()
; alternative acquisition syntax. Throws: os_thread_toolkit_error
unsigned
int size() const Throws: os_thread_toolkit_error
1
) and returns true ; otherwise, leaves the
resource count unchanged and immediately returns false
. Throws: os_thread_toolkit_error
1
). Throws: os_thread_toolkit_error
lock()
; alternative event syntax.Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.