class Semaphore extends AnyRef
A semaphore is a construction to control access to a common resource in a concurrent system. The semaphore in this library allows for creation of a distributed lock. In principle a semaphore is initiated with 1..n permits, instances of a semaphore then try to acquire one permit either succeeding or failing in case there are no more permits left to take. The simplest form is a binary semaphore which has only one permit thus only allowing a single instance to acquire a permit. Semaphores are traditionally used to control access to a protected source like a database or some task that only should be executed by a single process.
Each instance of the Semaphore class can hold exactly 0 or 1 permit thus invoking any of the tryAcquire functions mulitple times will not acquire additional permits.
- Alphabetic
- By Inheritance
- Semaphore
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native() @HotSpotIntrinsicCandidate()
- def destroy(): Try[Boolean]
Destroys all data for the semaphore.
Destroys all data for the semaphore. Any instances blocking for a permit will be released and return as Failure,
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- 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() @HotSpotIntrinsicCandidate()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
- def release(): Try[Boolean]
Attempts to release a permit.
Attempts to release a permit. If this instance is not holding a permit this function call does nothing
- returns
@return Success if managed to access Consul, then true if a permit was released.
- def sessionID: Option[String]
The Consul session ID for this Semaphore instance
The Consul session ID for this Semaphore instance
- Since
1.0.0
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- def tryAcquire(deadline: Deadline): Try[Boolean]
Attempts to acquire a permit blocking if necessary.
Attempts to acquire a permit blocking if necessary. If this instance is already holding a permit no further permits are taken
- deadline
The deadline for when to give up blocking for a permit
- returns
Success if managed to access Consul, then true if a permit was acquired.
- def tryAcquire(maxWait: FiniteDuration): Try[Boolean]
Attempts to acquire a permit blocking if necessary.
Attempts to acquire a permit blocking if necessary. If this instance is already holding a permit no further permits are taken In practice this invokes
tryAcquire(Deadline.now + maxWait)
- maxWait
The maximum time to block for a permit
- returns
Success if managed to access Consul, then true if a permit was acquired.
- def tryAcquire(): Try[Boolean]
Attempts to acquire a permit without blocking.
Attempts to acquire a permit without blocking. If this instance is already holding a permit no further permits are taken
- returns
Success if managed to access Consul, then true if a permit was acquired.
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated