acquire

suspend fun acquire()

Takes a permit: at once when one is free, else after waiting in the queue at most maxWait, or fails with QueryBusyException. The semaphore hands a released permit to the longest waiter (FIFO) and gives it back when that waiter was cancelled meanwhile. Each permit taken is given back with one release: a caller that reads in chunks may give it back between two and take it again, so a lowered limit applies to it from its next chunk.