folly::fibers::SemaphoreBase

Fiber-compatible semaphore base. Will safely block fibers that wait when no tokens are available and wake fibers when signalled.

Synopsis

Declared in <folly/fibers/SemaphoreBase.h>

class SemaphoreBase;

Types

NameDescription
Waiter A queued waiter blocked until the semaphore has capacity.

Member Functions

NameDescription
SemaphoreBase [constructor]Constructors
operator= Assignment operators
getAvailableTokens Returns the number of tokens currently available.
getCapacity Returns the total number of tokens the semaphore can hold.

Protected Type Aliases

NameDescription
WaiterList List of waiters queued for capacity.

Protected Member Functions

NameDescription
co_wait_common Wait for request capacity in the semaphore.
future_wait_common Wait for request capacity in the semaphore, returning a future.
signalSlow Slow path that wakes queued waiters when tokens become available.
try_wait_common try_wait_common overloads
waitSlow Slow path that enqueues the waiter when tokens are unavailable.
wait_common Wait for request capacity in the semaphore.

Protected Data Members

NameDescription
capacity_ Total number of tokens the semaphore can hold.
tokens_ Atomic counter of currently available tokens.
waitList_ Synchronized queue of pending waiters.

Derived Classes

NameDescription
BatchSemaphore Fiber-compatible batch semaphore with ability to perform batch token increment/decrement. Will safely block fibers that wait when no tokens are available and wake fibers when signalled.