consume

suspend fun consume(tokensToConsume: Long)(source)

Consumes the specified number of tokensToConsume, suspending as long as necessary to accumulate the requisite number of tokens. This algorithm is a direct copy of Bucket4j BlockingBucket's consume, except it suspends the calling coroutine's execution while waiting for available tokens, rather than blocking the thread. See the Bucket4j consume documentation for more details.

Parameters

tokensToConsume

The number of tokens to try and consume from the bucket. Must be a positive value.