release

open fun TSemaphore.release()

Release a permit back to the TSemaphore.

import arrow.fx.stm.TSemaphore
import arrow.fx.stm.atomically

suspend fun main() {
//sampleStart
val tsem = TSemaphore.new(5)
atomically {
tsem.release()
}
//sampleEnd
println("Permits remaining ${atomically { tsem.available() }}")
}

This function never retries.


open fun TSemaphore.release(n: Int)

Release n permits back to the TSemaphore.

import arrow.fx.stm.TSemaphore
import arrow.fx.stm.atomically

suspend fun main() {
//sampleStart
val tsem = TSemaphore.new(5)
atomically {
tsem.release(2)
}
//sampleEnd
println("Permits remaining ${atomically { tsem.available() }}")
}

n must be non-negative.

This function never retries.