Trait

monifu.concurrent.atomic

BlockableAtomic

Related Doc: package atomic

Permalink

trait BlockableAtomic[T] extends Atomic[T]

Represents Atomic references that can block the thread (with spin-locking) in wait of a successful condition (is not supported on top of Scala.js).

Useful when using an Atomic reference as a locking mechanism.

Source
BlockableAtomic.scala
Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BlockableAtomic
  2. Atomic
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Abstract Value Members

  1. abstract def :=(value: T): Unit

    Permalink

    Alias for set().

    Alias for set(). Updates the current value.

    value

    will be the new value returned by get()

    Definition Classes
    Atomic
  2. abstract def compareAndSet(expect: T, update: T): Boolean

    Permalink

    Does a compare-and-set operation on the current value.

    Does a compare-and-set operation on the current value. For more info, checkout the related Compare-and-swap Wikipedia page.

    It's an atomic, worry free operation.

    expect

    is the value you expect to be persisted when the operation happens

    update

    will be the new value, should the check for expect succeeds

    returns

    either true in case the operation succeeded or false otherwise

    Definition Classes
    Atomic
  3. abstract def get: T

    Permalink

    returns

    the current value persisted by this Atomic

    Definition Classes
    Atomic
  4. abstract def getAndSet(update: T): T

    Permalink

    Sets the persisted value to update and returns the old value that was in place.

    Sets the persisted value to update and returns the old value that was in place. It's an atomic, worry free operation.

    Definition Classes
    Atomic
  5. abstract def getAndTransform(cb: (T) ⇒ T): T

    Permalink

    Abstracts over compareAndSet.

    Abstracts over compareAndSet. You specify a transformation by specifying a callback to be executed, a callback that transforms the current value. This method will loop until it will succeed in replacing the current value with the one produced by the given callback.

    Note that the callback will be executed on each iteration of the loop, so it can be called multiple times - don't do destructive I/O or operations that mutate global state in it.

    cb

    is a callback that receives the current value as input and returns the update which is the new value that should be persisted

    returns

    the old value, just prior to when the successful update happened

    Definition Classes
    Atomic
  6. abstract def lazySet(update: T): Unit

    Permalink

    Eventually sets to the given value.

    Eventually sets to the given value. Has weaker visibility guarantees than the normal set().

    Definition Classes
    Atomic
  7. abstract def set(update: T): Unit

    Permalink

    Updates the current value.

    Updates the current value.

    update

    will be the new value returned by get()

    Definition Classes
    Atomic
  8. abstract def transform(cb: (T) ⇒ T): Unit

    Permalink

    Abstracts over compareAndSet.

    Abstracts over compareAndSet. You specify a transformation by specifying a callback to be executed, a callback that transforms the current value. This method will loop until it will succeed in replacing the current value with the one produced by the given callback.

    Note that the callback will be executed on each iteration of the loop, so it can be called multiple times - don't do destructive I/O or operations that mutate global state in it.

    cb

    is a callback that receives the current value as input and returns the update which is the new value that should be persisted

    Definition Classes
    Atomic
  9. abstract def transformAndExtract[U](cb: (T) ⇒ (U, T)): U

    Permalink

    Abstracts over compareAndSet.

    Abstracts over compareAndSet. You specify a transformation by specifying a callback to be executed, a callback that transforms the current value. This method will loop until it will succeed in replacing the current value with the one produced by your callback.

    Note that the callback will be executed on each iteration of the loop, so it can be called multiple times - don't do destructive I/O or operations that mutate global state in it.

    cb

    is a callback that receives the current value as input and returns a tuple that specifies the update + what should this method return when the operation succeeds.

    returns

    whatever was specified by your callback, once the operation succeeds

    Definition Classes
    Atomic
  10. abstract def transformAndGet(cb: (T) ⇒ T): T

    Permalink

    Abstracts over compareAndSet.

    Abstracts over compareAndSet. You specify a transformation by specifying a callback to be executed, a callback that transforms the current value. This method will loop until it will succeed in replacing the current value with the one produced by the given callback.

    Note that the callback will be executed on each iteration of the loop, so it can be called multiple times - don't do destructive I/O or operations that mutate global state in it.

    cb

    is a callback that receives the current value as input and returns the update which is the new value that should be persisted

    returns

    whatever the update is, after the operation succeeds

    Definition Classes
    Atomic
  11. abstract def update(value: T): Unit

    Permalink

    Alias for set().

    Alias for set(). Updates the current value.

    value

    will be the new value returned by get()

    Definition Classes
    Atomic
  12. abstract def waitForCompareAndSet(expect: T, update: T, waitAtMost: FiniteDuration): Unit

    Permalink

    Waits until the compareAndSet operation succeeds, e.g...

    Waits until the compareAndSet operation succeeds, e.g... 1. until the old value == expected and the operation succeeds, or 2. until the current thread is interrupted, or 3. the specified timeout is due

    So this can throw an exception on timeout, useful for when you want to insure that you don't block the current thread ad infinitum

    waitAtMost

    specifies the timeout, after which this method throws a TimeoutException

    Annotations
    @throws( classOf[InterruptedException] ) @throws( classOf[TimeoutException] )
  13. abstract def waitForCompareAndSet(expect: T, update: T, maxRetries: Int): Boolean

    Permalink

    Waits until the compareAndSet operation succeeds, e.g...

    Waits until the compareAndSet operation succeeds, e.g...

    1. until the old value == expected and the operation succeeds, or 2. until the current thread is interrupted 3. until the the spin lock retried for a maximum of maxRetries

    expect

    the expected current value

    update

    the value to replace the current value

    maxRetries

    the maximum number of times to retry in case of failure

    returns

    true if the operation succeeded or false in case it failed after it retried for maxRetries times

    Annotations
    @throws( classOf[InterruptedException] )
  14. abstract def waitForCompareAndSet(expect: T, update: T): Unit

    Permalink

    Waits until the compareAndSet operation succeeds, e.g...

    Waits until the compareAndSet operation succeeds, e.g... 1. until the old value == expected and the operation succeeds, or 2. until the current thread is interrupted

    Annotations
    @throws( classOf[InterruptedException] )
  15. abstract def waitForCondition(waitAtMost: FiniteDuration, p: (T) ⇒ Boolean): Unit

    Permalink

    Waits until the specified callback, that receives the current value, returns true.

    Waits until the specified callback, that receives the current value, returns true. Throws a TimeoutException in case the specified waitAtMost timeout is due.

    Annotations
    @throws( classOf[InterruptedException] ) @throws( classOf[TimeoutException] )
  16. abstract def waitForCondition(p: (T) ⇒ Boolean): Unit

    Permalink

    Waits until the specified callback, that receives the current value, returns true.

    Waits until the specified callback, that receives the current value, returns true.

    Annotations
    @throws( classOf[InterruptedException] )
  17. abstract def waitForValue(expect: T, waitAtMost: FiniteDuration): Unit

    Permalink

    Waits until the specified expect value == the value stored by this Atomic reference or until the current thread gets interrupted.

    Waits until the specified expect value == the value stored by this Atomic reference or until the current thread gets interrupted.

    This can throw an exception on timeout, useful for when you want to insure that you don't block the current thread ad infinitum

    waitAtMost

    specifies the timeout, after which this method throws a TimeoutException

    Annotations
    @throws( classOf[InterruptedException] ) @throws( classOf[TimeoutException] )
  18. abstract def waitForValue(expect: T): Unit

    Permalink

    Waits until the specified expect value == the value stored by this Atomic reference or until the current thread gets interrupted.

    Waits until the specified expect value == the value stored by this Atomic reference or until the current thread gets interrupted.

    Annotations
    @throws( classOf[InterruptedException] )

Concrete 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. def apply(): T

    Permalink

    returns

    the current value persisted by this Atomic, an alias for get()

    Definition Classes
    Atomic
  5. final def asInstanceOf[T0]: T0

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

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  7. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  9. def finalize(): Unit

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  10. final def getClass(): Class[_]

    Permalink
    Definition Classes
    AnyRef → Any
  11. def hashCode(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  12. final def isInstanceOf[T0]: Boolean

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

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

    Permalink
    Definition Classes
    AnyRef
  15. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  16. final def synchronized[T0](arg0: ⇒ T0): T0

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

    Permalink
    Definition Classes
    AnyRef → Any
  18. final def wait(): Unit

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  19. final def wait(arg0: Long, arg1: Int): Unit

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

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

Inherited from Atomic[T]

Inherited from AnyRef

Inherited from Any

Ungrouped