monifu.concurrent.locks.Lock

Extensions

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

Linear Supertypes
AnyVal, NotNull, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Extensions
  2. AnyVal
  3. NotNull
  4. Any
  1. Hide All
  2. Show all
Learn more about member selection
Visibility
  1. Public
  2. All

Instance Constructors

  1. new Extensions(self: L)

Value Members

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

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

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

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

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

    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

    Annotations
    @macroImpl( ... )
    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. def enterInterruptibly[T](callback: T): T

    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
    @macroImpl( ... ) @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]

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

    Definition Classes
    Any
  9. val self: L

  10. def toString(): String

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

    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.

    Annotations
    @macroImpl( ... )
  12. def tryEnter[T](callback: T): Boolean

    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.

    Annotations
    @macroImpl( ... )

Inherited from AnyVal

Inherited from NotNull

Inherited from Any

Ungrouped