Mojo · Transactions

Transactions

from ustore import Stamp, Watch, Isolation, … 1.0.0-rc.1 · d6d40961

API

StructStampA position in the order commits apply in, ustore_stamp_t: where a commit landed, or the newest commit a transaction or a snapshot reads.1
struct Stamp

Fields

valueUInt64The position, growing with every commit.

Values

WrittenStamp

Conforms to

Answer, Copyable, Defaultable, Deinitable, Equatable, ImplicitlyCopyable, Movable
__init__Stamp zero, which a failed call leaves.
def __init__(out self)
def __init__(out self, arena: Int, generation: Int, written: Self, count: Int)

Adopts the stamp a call wrote.

StructWatchWhether a transaction records the keys a call touches for conflicts, ustore_watch_t.
struct Watch

Fields

codec_intThe raw ustore_watch_t value the ABI exchanges.

Values

KEYSWatch(Int32(0))Records the keys, so a concurrent change to any of them fails the commit.
NONEWatch(Int32(1))Records nothing.

Conforms to

Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable
StructIsolationHow the transactions of the in-memory engine see each other's writes, ustore_isolation_t.
struct Isolation

Fields

codec_intThe raw ustore_isolation_t value the ABI exchanges.

Values

STRICT_SERIALIZABLEIsolation(Int32(0))Every transaction appears to run alone at one moment.
SNAPSHOTIsolation(Int32(1))Every transaction reads the state its start saw and conflicts only over what it writes.

Conforms to

Copyable, Deinitable, Equatable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable
StructTransactionAn optimistic transaction grouping operations across collections and modalities, freed when it goes out of scope. It holds its database open, and serves one call at a time.5
struct Transaction

Verbs called on it run on the calling thread, read through it and write into it, recording the keys they touch; txn.unwatched() records nothing, and txn.on(executor) and txn.deferred(executor) route the same verbs to an executor.

Fields

libraryLibraryThe loaded engine.
databaseAddressThe ustore_database_t it belongs to.
addressAddressThe opaque ustore_transaction_t.

Conforms to

BlobsVerbs, DatabaseVerbs, Deinitable, DocsVerbs, GraphVerbs, Movable, PagesVerbs, StringsVerbs
__init__Adopts a transaction the engine just began.
def __init__(out self, *, library: Library, database: Int, address: Int)
__deinit__Resets and frees the transaction. Calls ustore_transaction_free.
def __deinit__(deinit self)
unwatchedThe same verbs on the calling thread, recording nothing for conflicts. Binding-only.
def unwatched(ref self) -> On[origin_of(self)]
onThe same verbs, blocking on executor. Binding-only.
def on(ref self, ref executor: Executor, watch: Watch = Watch.KEYS) -> On[origin_of(executor, self)]
deferredThe same verbs, each submitted to executor and answering a Deferred at once. Binding-only.
def deferred(
    ref self,
    ref executor: Executor,
    watch: Watch = Watch.KEYS
) -> DeferredOn[origin_of(executor, self)]