Package-level declarations

Types

Link copied to clipboard
interface STM

Software transactional memory, or STM, is an abstraction for concurrent state modification. With STM one can write code that concurrently accesses state and that can easily be composed without exposing details of how it ensures safety guarantees. Programs running within an STM transaction will neither deadlock nor have race-conditions.

Link copied to clipboard
data class TArray<A>

A TArray is an array of transactional variables.

Link copied to clipboard
data class TMap<K, V>

A TMap is a concurrent transactional implementation of a key value hashmap.

Link copied to clipboard
data class TMVar<A>

A TMVar is a mutable reference that can either be empty or hold a value.

Link copied to clipboard
data class TQueue<A>

A TQueue is a transactional unbounded queue which can be written to and read from concurrently.

Link copied to clipboard
data class TSemaphore

TSemaphore is the transactional Semaphore.

Link copied to clipboard
data class TSet<A>

A TSet is a concurrent transactional implementation of a hashset.

Link copied to clipboard
class TVar<A>

A TVar is a mutable reference that can only be (safely) accessed inside a STM transaction.

Functions

Link copied to clipboard
suspend fun <A> atomically(f: STM.() -> A): A

Run a transaction to completion.

Link copied to clipboard
fun STM.check(b: Boolean)

Retry if b is false otherwise does nothing.

Link copied to clipboard
Link copied to clipboard
fun <A> STM.newTArray(vararg arr: A): TArray<A>
fun <A> STM.newTArray(xs: Iterable<A>): TArray<A>
fun <A> STM.newTArray(size: Int, a: A): TArray<A>
fun <A> STM.newTArray(size: Int, f: (Int) -> A): TArray<A>
Link copied to clipboard
fun <K, V> STM.newTMap(): TMap<K, V>
fun <K, V> STM.newTMap(fn: (K) -> Int): TMap<K, V>
Link copied to clipboard
fun <A> STM.newTMVar(a: A): TMVar<A>
Link copied to clipboard
fun <A> STM.newTQueue(): TQueue<A>
Link copied to clipboard
fun STM.newTSem(initial: Int): TSemaphore
Link copied to clipboard
fun <A> STM.newTSet(): TSet<A>
fun <A> STM.newTSet(fn: (A) -> Int): TSet<A>
Link copied to clipboard
inline fun <A> stm(noinline f: STM.() -> A): STM.() -> A

Helper to create stm blocks that can be run with STM.orElse