InMemorySemaphoreState

Represents an in-memory state of a semaphore.

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
open override var permitsInUse: Int

The number of permits currently in use (i.e., permits that have been acquired but not yet released).

Link copied to clipboard

The queue to store the requests that are waiting for permits to be available.

Link copied to clipboard

The time mark indicating when the semaphore state was last replenished. It is used to determine when the rate limiting replenishment period has passed.

Functions

Link copied to clipboard
open override fun close()
Link copied to clipboard
open override fun setPermits(updateFunction: (Int) -> Int)

Updates the number of permits optionally considering the current value.

Link copied to clipboard

Sets a new replenishment time mark by essentially taking a snapshot of the current time.