An asynchronous semaphore, which is a generalization of a mutex. Semaphores have a certain number of permits, which can be held and released concurrently by different parties. Attempts to acquire more permits than available result in the acquiring fiber being suspended until the specified number of permits become available.
If you need functionality that Semaphore doesnt' provide, use a TSemaphore and define it in a zio.stm.ZSTM transaction.
Attributes
- Companion
- object
- Source
- Semaphore.scala
- Graph
-
- Supertypes
-
trait Serializableclass Objecttrait Matchableclass Any
Members list
Value members
Abstract methods
Returns the number of available permits.
Executes the specified workflow, acquiring a permit immediately before the workflow begins execution and releasing it immediately after the workflow completes execution, whether by success, failure, or interruption.
Executes the specified workflow, acquiring a permit immediately before the workflow begins execution and releasing it immediately after the workflow completes execution, whether by success, failure, or interruption.
Attributes
- Source
- Semaphore.scala
Returns a scoped workflow that describes acquiring a permit as the acquire action and releasing it as the release action.
Returns a scoped workflow that describes acquiring a permit as the acquire action and releasing it as the release action.
Attributes
- Source
- Semaphore.scala
Executes the specified workflow, acquiring the specified number of permits immediately before the workflow begins execution and releasing them immediately after the workflow completes execution, whether by success, failure, or interruption.
Executes the specified workflow, acquiring the specified number of permits immediately before the workflow begins execution and releasing them immediately after the workflow completes execution, whether by success, failure, or interruption.
Attributes
- Source
- Semaphore.scala
Returns a scoped workflow that describes acquiring the specified number of permits and releasing them when the scope is closed.
Returns a scoped workflow that describes acquiring the specified number of permits and releasing them when the scope is closed.
Attributes
- Source
- Semaphore.scala
Concrete methods
Returns the number of tasks currently waiting for permits. The default implementation returns 0.
Returns the number of tasks currently waiting for permits. The default implementation returns 0.
Attributes
- Source
- Semaphore.scala
Executes the effect, acquiring a permit if available and releasing it after execution. Returns None if no permits were available.
Executes the effect, acquiring a permit if available and releasing it after execution. Returns None if no permits were available.
Attributes
- Source
- Semaphore.scala
Executes the effect, acquiring n permits if available and releasing them after execution. Returns None if no permits were available.
Executes the effect, acquiring n permits if available and releasing them after execution. Returns None if no permits were available.
Attributes
- Source
- Semaphore.scala