Class/Object

monifu.concurrent.locks.Lock

Extensions

Related Docs: object Extensions | package Lock

Permalink

implicit final class Extensions[L <: java.util.concurrent.locks.Lock] extends AnyVal

Linear Supertypes
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Extensions
  2. AnyVal
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Extensions(self: L)

    Permalink

Value Members

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

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

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

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

    Permalink
    Definition Classes
    Any
  5. macro def enter[T](callback: T): T

    Permalink

    Executes the given callback with the lock acquired.

    Executes the given callback with the lock acquired.

    Is implemented as macro to eliminate any method calls overhead.

    callback

    the callback to be executed once the lock is acquired

    returns

    the returned value of our callback

    Example:
    1. private[this] val gate = Extensions()
      private[this] var queue = mutable.Queue.empty[Int]
      def push(elem: Int): Unit =
        gate.enter {
          queue.enqueue(elem)
        }
      def pop(): Option[Int] =
        gate.enter {
          if (queue.nonEmpty) Some(queue.dequeue()) else None
        }
  6. macro def enterInterruptibly[T](callback: T): T

    Permalink

    Executes the given callback with the lock acquired, unless the thread was interrupted.

    Executes the given callback with the lock acquired, unless the thread was interrupted.

    Is implemented as macro to eliminate any method calls overhead.

    callback

    the callback to be executed once the lock is acquired

    returns

    the returned value of our callback

    Annotations
    @throws( classOf[InterruptedException] )
    Example:
    1. private[this] val gate = Extensions()
      private[this] var queue = mutable.Queue.empty[Int]
      def push(elem: Int): Unit =
        gate.enterInterruptibly {
          queue.enqueue(elem)
        }
      def pop(): Option[Int] =
        gate.enterInterruptibly {
          if (queue.nonEmpty) Some(queue.dequeue()) else None
        }
    Exceptions thrown

    java.lang.InterruptedException exception is thrown if the thread was interrupted

  7. def getClass(): Class[_ <: AnyVal]

    Permalink
    Definition Classes
    AnyVal → Any
  8. final def isInstanceOf[T0]: Boolean

    Permalink
    Definition Classes
    Any
  9. val self: L

    Permalink
  10. def toString(): String

    Permalink
    Definition Classes
    Any
  11. macro def tryEnter[T](time: Long, unit: TimeUnit, callback: T): Boolean

    Permalink

    Acquires the lock only if it is free within the given waiting time and in case the lock was acquired then executes the given callback.

    Acquires the lock only if it is free within the given waiting time and in case the lock was acquired then executes the given callback.

    time

    the maximum time to wait for the lock

    unit

    the time unit of the time argument

    callback

    the callback to execute

    returns

    either true in case the lock was acquired and the callback was executed, or false otherwise.

  12. macro def tryEnter[T](callback: T): Boolean

    Permalink

    Acquires the lock only if it is free at the time of invocation and in case the lock was acquired then executes the given callback.

    Acquires the lock only if it is free at the time of invocation and in case the lock was acquired then executes the given callback.

    callback

    the callback to execute

    returns

    either true in case the lock was acquired and the callback was executed, or false otherwise.

Inherited from AnyVal

Inherited from Any

Ungrouped