Expand description
Task-local “current” ShapeTransitionTable handle.
Mirrors the pattern established in
shape-runtime::type_schema::current for TypeSchemaRegistry (B1.3),
but lives in shape-value because ShapeTransitionTable is a
shape-value type and pulling it up into shape-runtime would invert
the crate dependency.
Two layers, consulted in order:
- Task-local (
CURRENT_SHAPE_TABLE) — survives task migration across tokio worker threads so any descendant.awaitin a Shape execution future inherits the handle automatically. - Thread-local (
SYNC_CURRENT_SHAPE_TABLE) — fallback for synchronous entry points (CLI, tests, REPL one-shots) that are not running under a tokio task. ASyncShapeTableScopeRAII guard pushes/pops the value so nested scopes compose correctly.
Unlike the type-schema current module, this one exposes a
try_current_shape_table accessor that is the primary lookup used
by shape_graph’s free functions (shape_transition,
shape_for_hashmap_keys, shape_property_index,
drain_shape_transitions). When no scope is active those free
functions degrade to None / empty-drain — this preserves the
existing “fall back to hash lookup, no shape tracking” semantic that
was already returned for lock-poisoned or overflow cases by the
previous global-backed implementation, which keeps unit tests that
poke HashMapData::compute_shape without a VM alive.
Structs§
- Shape
Table Handle - Shareable handle to a shape transition table and its transition log.
- Sync
Shape Table Scope - RAII guard that installs a shape-table handle on the thread-local slot for the lifetime of the guard.
Functions§
- current_
shape_ table - Panicking variant of
try_current_shape_table. Callers that are guaranteed to execute within a VM scope may prefer this for fast- fail diagnostics. - try_
current_ shape_ table - Return the current ambient shape-table handle, or
Noneif no scope is active. - with_
async_ shape_ table_ scope - Run
futwithhandleinstalled as the task-local current shape table. Inherited by all descendant.awaitpoints and survives tokio task migration across worker threads.