Skip to main content

Module stm

Module stm 

Source
Expand description

Stratum 12 — Transactional Memory

Optimistic concurrency with composable transactions, built from Strata 0–11.

Software transactional memory — optimistic transactions over TRef cells.

A Stm<A, E> describes a transactional program. commit (alias atomically) runs it to completion: on Outcome::Retry or a failed commit validation the attempt restarts after std::thread::yield_now.

Concurrency: all commits are serialized behind a global lock; transaction bodies record read versions and defer writes until commit succeeds.

Structs§

Stm
Transactional program composable with Stm::flat_map, Stm::map, etc.
TMap
Transactional map in a TRef (hash map snapshot per transaction).
TQueue
Transactional queue backed by a TRef.
TRef
Transactional mutable cell (shared with Arc identity).
TSemaphore
Transactional permit counter in a TRef.
Txn
One attempt of a transactional read/write set.

Enums§

Outcome
Result of one Stm execution pass over a Txn (no I/O yet).

Functions§

atomically
Alias for commit (Effect.ts naming).
commit
Run stm until it commits successfully (sync Effect::new body; safe for crate::runtime::run_blocking).