abstract class Semaphore[F[_]] extends AnyRef
An asynchronous semaphore, useful as a concurrency primitive.
- Source
- Semaphore.scala
- Alphabetic
- By Inheritance
- Semaphore
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Instance Constructors
- new Semaphore()
Abstract Value Members
-
abstract
def
available: F[Long]
Returns the number of permits currently available.
Returns the number of permits currently available. Always nonnegative.
-
abstract
def
clear: F[Long]
Resets the count of this semaphore back to zero, and returns the previous count.
Resets the count of this semaphore back to zero, and returns the previous count. Throws an
IllegalArgumentExceptionif count is below zero (due to pending decrements). -
abstract
def
count: F[Long]
Obtains a snapshot of the current count.
Obtains a snapshot of the current count. May be out of date the instant after it is retrieved. Use
tryDecrementortryDecrementByif you wish to attempt a decrement and return immediately if the current count is not high enough to satisfy the request. -
abstract
def
decrementBy(n: Long): F[Unit]
Decrements the number of available permits by
n, blocking untilnare available.Decrements the number of available permits by
n, blocking untilnare available. Error ifn < 0. The blocking is semantic; we do not literally block a thread waiting for permits to become available. Note that decrements are satisfied in strict FIFO order, so givens: Semaphore[F]with 2 permits available, adecrementBy(3)will always be satisfied before a later call todecrementBy(1). -
abstract
def
incrementBy(n: Long): F[Unit]
Increments the number of available permits by
n.Increments the number of available permits by
n. Error ifn < 0. This will have the effect of unblockingnacquisitions. -
abstract
def
timedDecrement(timeout: FiniteDuration, scheduler: Scheduler): F[Boolean]
Like decrement but limits the amount of time spent blocking for a permit.
Like decrement but limits the amount of time spent blocking for a permit. If the permit has not been acquired after the timeout has been reached, the action completes with false. If a permit is acquired, the action completes with true.
-
abstract
def
timedDecrementBy(n: Long, timeout: FiniteDuration, scheduler: Scheduler): F[Long]
Like decrementBy but limits the amount of time spent blocking for permits.
Like decrementBy but limits the amount of time spent blocking for permits. If all permits have not been acquired after the timeout has been reached, the action completes with the number of permits remaining to be acquired. If the requested number of permits is acquired, the action completes with 0.
-
abstract
def
tryDecrementBy(n: Long): F[Boolean]
Acquires
npermits now and returnstrue, or returnsfalseimmediately.Acquires
npermits now and returnstrue, or returnsfalseimmediately. Error ifn < 0.
Concrete Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (Semaphore[F], B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
decrement: F[Unit]
Decrements the number of permits by 1.
Decrements the number of permits by 1. Alias for
decrementBy(1). - def ensuring(cond: (Semaphore[F]) ⇒ Boolean, msg: ⇒ Any): Semaphore[F]
- def ensuring(cond: (Semaphore[F]) ⇒ Boolean): Semaphore[F]
- def ensuring(cond: Boolean, msg: ⇒ Any): Semaphore[F]
- def ensuring(cond: Boolean): Semaphore[F]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
- def formatted(fmtstr: String): String
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
final
def
increment: F[Unit]
Increments the number of permits by 1.
Increments the number of permits by 1. Alias for
incrementBy(1). -
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
def
tryDecrement: F[Boolean]
Alias for
tryDecrementBy(1). -
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
- def →[B](y: B): (Semaphore[F], B)