AtomicBoolean

final class AtomicBoolean extends Atomic[Boolean]

Atomic references wrapping Boolean values.

Note that the equality test in compareAndSet is value based, since Boolean is a primitive.

Companion:
object
trait Serializable
class Object
trait Matchable
class Any

Value members

Concrete methods

def compareAndSet(expect: Boolean, update: Boolean): Boolean
def flip(update: Boolean): Boolean

Convenience method that expects the current value to be not the provided value. Equivalent to compareAndSet(!update, update).

Convenience method that expects the current value to be not the provided value. Equivalent to compareAndSet(!update, update).

def get(): Boolean
def getAndSet(update: Boolean): Boolean
def lazySet(update: Boolean): Unit
def set(update: Boolean): Unit
override def toString: String
Definition Classes
Any

Inherited methods

final inline def :=(value: Boolean): Unit

Alias for set. Updates the current value.

Alias for set. Updates the current value.

Value parameters:
value

will be the new value returned by get()

Inherited from:
Atomic
final inline def apply(): Boolean

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

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

Inherited from:
Atomic
final inline def getAndTransform(inline cb: Boolean => Boolean): Boolean

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.

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.

Value parameters:
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

Inherited from:
Atomic
final inline def transform(inline cb: Boolean => Boolean): Unit

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.

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.

Value parameters:
cb

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

Inherited from:
Atomic
final inline def transformAndExtract[U](inline cb: Boolean => (U, Boolean)): U

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.

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.

Value parameters:
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

Inherited from:
Atomic
final inline def transformAndGet(inline cb: Boolean => Boolean): Boolean

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.

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.

Value parameters:
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

Inherited from:
Atomic
final inline def update(value: Boolean): Unit

Alias for set. Updates the current value.

Alias for set. Updates the current value.

Value parameters:
value

will be the new value returned by get()

Inherited from:
Atomic