Class/Object

org.dmonix.consul

Semaphore

Related Docs: object Semaphore | package consul

Permalink

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)

    Permalink

Value Members

  1. final def !=(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  4. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  5. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @throws( ... )
  6. def destroy(): Try[Boolean]

    Permalink

    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

    Permalink
    Definition Classes
    AnyRef
  8. def equals(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  9. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  10. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate()
  11. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  12. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  13. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  14. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate()
  15. def release(): Try[Boolean]

    Permalink

    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]

    Permalink

    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

    Permalink
    Definition Classes
    AnyRef
  18. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  19. def tryAcquire(deadline: Deadline): Try[Boolean]

    Permalink

    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]

    Permalink

    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]

    Permalink

    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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @Deprecated @deprecated @throws( classOf[java.lang.Throwable] )
    Deprecated

    (Since version ) see corresponding Javadoc for more information.

Inherited from AnyRef

Inherited from Any

Ungrouped