TArray

trait TArray[A] extends TxnDebuggable

Bulk transactional storage, roughly equivalent to Array[Ref[T]] but potentially much more space efficient. Elements can be read and written directly, or the refs method can be used to obtain transient Ref instances backed by the elements of the TArray.

Bulk transactional storage, roughly equivalent to Array[Ref[T]] but potentially much more space efficient. Elements can be read and written directly, or the refs method can be used to obtain transient Ref instances backed by the elements of the TArray.

Authors

Nathan Bronson

Companion
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def apply(index: Int)(txn: InTxn): A

Performs a transactional read of the indexth element of this transactional array. Equivalent to refs(index).get.

Performs a transactional read of the indexth element of this transactional array. Equivalent to refs(index).get.

def length: Int

Returns the length of this TArray, which does not change.

Returns the length of this TArray, which does not change.

def refs: IndexedSeq[Ref[A]]

Returns a sequence of Ref instances that are backed by elements of this TArray. All operations on the contained Refs are supported.

Returns a sequence of Ref instances that are backed by elements of this TArray. All operations on the contained Refs are supported.

As an example, the following code tests whether a(i) is greater than 10 without requiring the transaction to roll back for all writes to a(i):

  atomic { implicit t =>
    if (a.refs(i).getWith( _ > 10 )) {
      ... lots of stuff
    }
  }
def single: View[A]

Returns a TArray.View that allows access to the contents of this TArray without requiring that an InTxn be available. See Ref.View.

Returns a TArray.View that allows access to the contents of this TArray without requiring that an InTxn be available. See Ref.View.

def update(index: Int, v: A)(txn: InTxn): Unit

Performs a transactional write to the indexth element of this transactional array. Equivalent to refs(index).set(v).

Performs a transactional write to the indexth element of this transactional array. Equivalent to refs(index).set(v).

Inherited methods

def dbgStr: String

Returns a string representation of the transactional value in this instance for debugging convenience. The Ref reads (and writes) performed while constructing the result will be discarded before returning. This method works fine outside a transaction.

Returns a string representation of the transactional value in this instance for debugging convenience. The Ref reads (and writes) performed while constructing the result will be discarded before returning. This method works fine outside a transaction.

If this method is called from within a transaction that is already doomed (status Txn.Rolledback), a string describing the reason for the outer transaction's rollback will be returned.

Inherited from
TxnDebuggable
def dbgValue: Any

Returns some value that is suitable for examination in a debugger, or returns a Txn.RollbackCause if called from inside a doomed atomic block.

Returns some value that is suitable for examination in a debugger, or returns a Txn.RollbackCause if called from inside a doomed atomic block.

Inherited from
TxnDebuggable