SuspendableSemaphore

internal interface SuspendableSemaphore(source)

Provides a mechanism for controlling access to shared resources using a set of permits. Behaves similarly to a Semaphore, but if no permits are available, the caller suspends until that request can be granted. Supports both counting and binary semaphores.

Inheritors

Functions

Link copied to clipboard
abstract suspend fun acquire(permits: Int, timeout: Duration)

Acquires n permits from the semaphore or suspends for the specified timeout if the permits are not available.

Link copied to clipboard
abstract suspend fun release(permits: Int)

Releases n permits back to the semaphore.