Packages

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.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. Semaphore
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Semaphore(consul: Consul with SessionUpdater, semaphoreName: String)

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  5. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native() @HotSpotIntrinsicCandidate()
  6. 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,

  7. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  9. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  10. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  11. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  13. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  14. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @native() @HotSpotIntrinsicCandidate()
  15. 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.

  16. def sessionID: Option[String]

    The Consul session ID for this Semaphore instance

    The Consul session ID for this Semaphore instance

    Since

    1.0.0

  17. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  18. def toString(): String
    Definition Classes
    AnyRef → Any
  19. 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.

  20. 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.

  21. 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.

  22. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... ) @native()
  24. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] ) @Deprecated
    Deprecated

Inherited from AnyRef

Inherited from Any

Ungrouped