Sink

trait Sink[-A] extends SinkLike[A, InTxn]

Sink[+A] consists of the contra-variant write-only operations of Ref[A].

Sink[+A] consists of the contra-variant write-only operations of Ref[A].

Authors

Nathan Bronson

Companion
object
trait SinkLike[A, InTxn]
class Object
trait Matchable
class Any
trait Ref[A]

Value members

Abstract methods

def single: View[A]

See Ref.single.

See Ref.single.

Inherited methods

def set(v: A)(txn: InTxn): Unit

Performs a transactional write. The new value will not be visible by any other threads until (and unless) txn successfully commits. Equivalent to update(v).

Performs a transactional write. The new value will not be visible by any other threads until (and unless) txn successfully commits. Equivalent to update(v).

Value Params
v

a value to store in the Ref.

Throws
IllegalStateException

if txn is not active.

Inherited from
SinkLike
def trySet(v: A)(txn: InTxn): Boolean

Performs a transactional write and returns true, or returns false. The STM implementation may choose to return false to reduce (not necessarily avoid) blocking. If no other threads are performing any transactional or atomic accesses then this method will succeed.

Performs a transactional write and returns true, or returns false. The STM implementation may choose to return false to reduce (not necessarily avoid) blocking. If no other threads are performing any transactional or atomic accesses then this method will succeed.

Inherited from
SinkLike
def update(v: A)(txn: InTxn): Unit

Performs a transactional write. The new value will not be visible by any other threads until (and unless) txn successfully commits. Equivalent to set(v).

Performs a transactional write. The new value will not be visible by any other threads until (and unless) txn successfully commits. Equivalent to set(v).

Example:

  val x = Ref(0)
  atomic { implicit t =>
    ...
    x() = 10 // perform a write inside a transaction
    ...
  }
Value Params
v

a value to store in the Ref.

Throws
IllegalStateException

if txn is not active.

Inherited from
SinkLike