Expand description
Cross-isolate shared mutable state: SharedValue, SharedAtom (Phase B3).
The isolate model is share-nothing for GC-heap data. But some state
genuinely needs to be visible across isolates — global configuration, shared
counters, published results. Phase B3 adds an explicit, honest escape
hatch: shared-atom.
§Two-tier mutable references (per the ADR)
| Primitive | Backing | Send? | Use case |
|---|---|---|---|
atom | GcPtr<Atom> (Mutex<Value>) | !Send | isolate-local, fast |
shared-atom | Arc<SharedAtom> (ArcSwap<SharedValue>) | ✓ | cross-isolate, lock-free CAS |
A value stored in a shared-atom must be promotable — it must be
representable as a SharedValue. The promotion cost is paid once on
publish; reads (deref) are an atomic load.
§SharedValue
Covers only the “plain data” subset of Value:
- Scalars (stored inline, no allocation)
- Strings (
Arc<str>, immutable, refcounted) - Keywords / symbols (
StaticGcPtr<T>, interned, program-lifetime) - Large byte buffers (
Arc<[u8]>, the BEAM off-heap-binary trick)
Closures, native resources, and isolate-bound GC objects are not
promotable. This restriction is enforced at publish time via promote.
Structs§
- Promote
Error - Returned when a
Valuecannot be promoted toSharedValue. - Shared
Atom - A cross-isolate mutable reference backed by a lock-free
ArcSwap.
Enums§
- Shared
Value - A
Send + Syncvalue representation for cross-isolate sharing.
Functions§
- demote
- Demote a
SharedValueback into an isolate-localValue. - promote
- Promote a
Valueto aSharedValuefor cross-isolate publishing.