Semaphore class
A semaphore is a concurrency primitive that allows you to limit the number of concurrent operations.
You can specify the number of permits when creating the semaphore. When you call take, it will wait until there are enough permits available.
When you call release, it will add the number of permits back to the semaphore.
You can also use withPermits to run a ZIO with a certain number of permits. It will automatically release the permits when the ZIO completes.
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
release<
R, E> (int permits) → ZIO< R, E, Unit> - Releases the specified number of permits.
-
take<
R, E> (int permits) → ZIO< R, E, Unit> - Takes the specified number of permits. If there are not enough permits available, it will wait until there are.
-
toString(
) → String -
A string representation of this object.
inherited
-
use<
R, E, A> (ZIO< R, E, A> zio) → ZIO<R, E, A> - Runs the specified ZIO with a single permit. It will automatically release the permit when the ZIO completes.
-
withPermits<
R, E, A> (int permits, ZIO< R, E, A> zio) → ZIO<R, E, A> - Runs the specified ZIO with the specified number of permits. It will automatically release the permits when the ZIO completes.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited