acquire

open suspend override fun acquire(permits: Int, timeout: Duration)(source)

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

Parameters

permits

the number of permits to acquire.

timeout

the maximum time to wait for the permits.

Throws

if the specified timeout is exceeded while waiting for the permits.

if the specified permits is non-positive or the timeout is negative.