arrow-fx / arrow.fx / Semaphore
interface ~~Semaphore~~<F>
Deprecated: The IO datatype and it’s related type classes will disappear in Arrow 0.13.0. All useful operations are offered directly over suspend functions by Arrow Fx Coroutines. https://arrow-kt.io/docs/fx/async/
A counting Semaphore is used to control access to a resource in a concurrent system. It keeps track of the count of available resources.
acquire | Acquire a resource Suspending the Fiber running the action until the resource is available.open fun acquire(): Kind<F, Unit > |
acquireN | Acquires n resources Suspending the Fiber running the action until the resources are available.abstract fun acquireN(n: Long ): Kind<F, Unit > |
available | Get a snapshot of the currently available permits, always non negative.abstract fun available(): Kind<F, Long > |
count | Get a snapshot of the current count, may be negative. The count is current available permits minus the outstanding acquires.abstract fun count(): Kind<F, Long > |
release | Release a resourcesopen fun release(): Kind<F, Unit > |
releaseN | Release n resourcesabstract fun releaseN(n: Long ): Kind<F, Unit > |
tryAcquire | Try to acquire a resource and get an immediate response as Boolean.open fun tryAcquire(): Kind<F, Boolean > |
tryAcquireN | Try to acquires n resources and get an immediate response as Boolean.abstract fun tryAcquireN(n: Long ): Kind<F, Boolean > |
withPermit | Runs the supplied effect that acquires a permit, and then releases the permit.abstract fun <A> withPermit(t: Kind<F, A>): Kind<F, A> |
invoke | Construct a Semaphore initialized with n available permits.operator fun <F> invoke(n: Long , CF: Concurrent <F>): Kind<F, Semaphore <F>> |
uncancelable | fun <F> ~~uncancelable~~(n: Long , AS: Async <F>): Kind<F, Semaphore <F>> |
uncancellable | Construct a Semaphore initialized with n available permits. Since it’s based on Async it’s constrained with an uncancellable acquire operation.fun <F> uncancellable(n: Long , AS: Async <F>): Kind<F, Semaphore <F>> |
Do you like Arrow?
✖