SinkLike

trait SinkLike[-A, Context]

Provides all of the operations of a Sink[A], without the ability to get a Sink.View.

Provides all of the operations of a Sink[A], without the ability to get a Sink.View.

Authors

Nathan Bronson

class Object
trait Matchable
class Any
trait RefLike[A, Context]
trait Ref[A]
trait TxnLocal[A]
trait Sink[A]

Value members

Abstract methods

def set(v: A)(txn: Context): 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.

def trySet(v: A)(txn: Context): 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.

Concrete methods

def update(v: A)(txn: Context): 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.