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
Lock
cajeta.concurrent.Lock — the no-data RAII gate over the async-aware lock
intrinsics. acquire() returns a #LockGuard whose drop releases the lock;
tryAcquire() is non-blocking (1 = acquired, 0 = already held) and pairs with
a manual releaseLock(). A fiber that hits a held lock parks and yields to its
carrier rather than blocking the OS thread. Use a plain Lock to guard state
not bundled into a single value; reach for Mutex when there is one
piece of data to fuse the lock with.
Lock gate = heap Lock();
LockGuard g #= gate.acquire(); // held while g is alive; auto-release on drop
Lock gate2 = heap Lock();
if (gate2.tryAcquire() == 1) { // non-blocking attempt
gate2.releaseLock(); // manual pairing with tryAcquire
}
Methods
| Signature | |
|---|---|
Lock() ⚑ | Create a fresh, unheld lock |
#LockGuard acquire() | Block until the lock is held, then return a #LockGuard that releases it on drop; bind the guard to a scope |
int32 tryAcquire() | Non-blocking acquire: 1 if taken (caller must releaseLock()), 0 if already held |
void releaseLock() | Manually release a lock taken via tryAcquire(); locks taken via acquire() are released by their LockGuard |
⚑ = @EntryPoint
See also
- Tour: ConcurrentDemo
- Source:
runtime/src/cajeta/concurrent/Lock.cajeta - Mutex, RwLock, Semaphore