abstract suspend fun acquire()(source)

Acquires a permit from this semaphore, suspending until one is available. All suspending acquirers are processed in first-in-first-out (FIFO) order.

This suspending function is cancellable: if the Job of the current coroutine is cancelled while this suspending function is waiting, this function immediately resumes with CancellationException. There is a prompt cancellation guarantee: even if this function is ready to return the result, but was cancelled while suspended, CancellationException will be thrown. See suspendCancellableCoroutine for low-level details. This function releases the semaphore if it was already acquired by this function before the CancellationException was thrown.

Note that this function does not check for cancellation when it does not suspend. Use CoroutineScope.isActive or CoroutineScope.ensureActive to periodically check for cancellation in tight loops if needed.

Use tryAcquire to try to acquire a permit of this semaphore without suspension.