Stdlib index
- Captured-borrow migration worklist (3.3.3)
- Owned-bind migration worklist (8.2.7)
- Return-side title audit — the ride-through enumeration
- stdlib ownership audit
- stdlib ownership dispositions (plan 1.3.1 / 4.3.1)
aot
codec
codec / csv
codec / json
collection
- ArrayList
- BPlusTree
- Cache
- Collectors
- HashMap
- HashSet
- Heap
- ImmutableList
- ImmutableMap
- ImmutableSet
- LinkedList
- RedBlackTree
- Sort
collection / ltm
concurrent
error
- Exception
- NoOptionalValueException
- NotProvidedException
- RecoverableException
- ScopedBuildFailedException
- ScopeNotActiveException
- Throwable
- UnrecoverableException
gfx
hash
ifx
io
io / file
io / net
io / net / dns
io / net / uri
lang
lang / stream
math
math / fft
math / linalg
math / npio
math / poly
math / random
math / stats
nucleo
- Columns — the Arrow-laid-out substrate
- Fused tensor expressions — Fuse
- Table — the lazy, typed dataframe
- Tape — define-by-run autograd
- Transform intrinsics — Grad, Vmap, Jit
process
reflect
search / distance
search / fuzzy
search / ngram
session
time
- Clock
- DateTimeFormatter
- Duration
- Instant
- LocalDate
- LocalDateTime
- LocalTime
- Period
- ZonedDateTime
- ZoneId
- ZoneOffset
wire
xpu
xpu / mesh
RwLock<T>
cajeta.concurrent.RwLock — read-heavy shared state. Like Mutex
it owns the protected value, but distinguishes shared reads from exclusive
writes: many readers may hold the read lock at once, a writer holds it
exclusively, and writer-preference in the runtime keeps a steady stream of
readers from starving a writer. Same closure/scoped shape as Mutex — the
protected value doesn’t escape a write region. Reach for it over Mutex only
when reads vastly dominate writes.
RwLock<int32> hits = heap RwLock<int32>(5);
hits.withWrite((int32 v) -> v + 9); // exclusive write lock, store v + 9
int32 snapshot = hits.read(); // shared read lock, returns a copy -> 14
Methods
| Signature | |
|---|---|
RwLock(#T initial) ⚑ | Wrap initial in a fresh lock, taking ownership of it (#T) |
T read() | Snapshot the protected value under a shared read lock; intended for value/primitive T |
void withWrite((T) -> #T fn) | Exclusive write critical section: acquire the write lock, pass the current value to fn, store its result, release |
⚑ = @EntryPoint
See also
- Tour: ConcurrentDemo
- Source:
runtime/src/cajeta/concurrent/RwLock.cajeta - Mutex, Lock