Dense, fork-local runtime state for SCI contexts.
Stable handles are assigned integer slots once per context lineage. A world stores slot values densely; a fork copies that array. Mutable primitives CAS only their own slot, so unrelated atoms never contend on a shared world root.
Locking (JVM). Evaluation takes no world lock and reads slots lock-free.
slot-gate (read): every slot write, together with the host-object
mirror of a primary world (Var root/meta, Namespace meta, Type data,
volatile) and a lazy realization step. No user code runs inside.publish-gate (read): a publication of several slot writes that must
appear together, e.g. a def's value and metadata. No user code runs
inside: Var watch notifications are deferred until it ends, and the
namespace-environment atom (whose watches and validator are user code)
is never updated inside.slot-gate exclusively for the array copy.
A fork is therefore a cut between individual publications. Every
publication makes its result reachable last: slots are written before an
environment mapping or slot value refers to the handle.Copy-section audit (JVM). Everything that runs while a fork holds the
source's publish-gate and slot-gate write locks follows one rule: no
user (interpreted) code, and it waits only on leaf locks, which are never
held while waiting for another lock or for user code. The participants:
realize-primary!): reads Var roots and metadata,
namespace metadata, Type data and SCI volatile/ref roots through fork's
snapshot fns; plain field reads.IForkableWorldCache of SCI's lazy caches): copy an
existing realization in short map sections; they never realize a lazy
value or take its realization monitor. The owner index is a WeakHashMap
under its own monitor (leaf); owners hash by identity.sci.fork/trusted-future?): isDone only on exact
FutureTask / CompletableFuture or a clojure.core/future wrapper around
one (a volatile read); the wrapper's delegate is read reflectively, its
Field cached in a ConcurrentHashMap (leaf bin locks, class reflection).copy-cells!), installed only by SCI and the host
(install-var-fork-fns!), never from Var metadata or any evaluation:
fork-loaded-libs (operand: the built-in *loaded-libs* root, a ref /
atom only SCI's add-loaded-lib updates with conj; the JVM deref may
wait for that commit's ref lock), the CLJS fork-type-data (operand: the
type's JS prototype, which only SCI sets: interpreted alter-meta! and
-create-type cannot replace it) and the ClojureDart method table
(identity). Var copiers installed through :fork-fns are host code
with the same rule.retire-world!) is not inside a copy: it takes the slot
read lock, so it waits for a copy in progress (and a copy for it); its
cache hooks (IWorldCache) only drop private entries.IForkableWorldCache / IWorldCache implementations are trusted
host code under the same rule.
The locks are blocking and non-fair: waiting under them is acyclic, but
has no time bound. A fork's copy waits for in-flight slot writes and
publications (which run no user code), and they wait for the copy.Dense, fork-local runtime state for SCI contexts. Stable handles are assigned integer slots once per context lineage. A world stores slot values densely; a fork copies that array. Mutable primitives CAS only their own slot, so unrelated atoms never contend on a shared world root. Locking (JVM). Evaluation takes no world lock and reads slots lock-free. - `slot-gate` (read): every slot write, together with the host-object mirror of a primary world (Var root/meta, Namespace meta, Type data, volatile) and a lazy realization step. No user code runs inside. - `publish-gate` (read): a publication of several slot writes that must appear together, e.g. a def's value and metadata. No user code runs inside: Var watch notifications are deferred until it ends, and the namespace-environment atom (whose watches and validator are user code) is never updated inside. - A fork takes both write locks only for the copy: primary realization, the cells, the lazy realization caches and the namespace environment. It excludes writers for that copy and never waits for an evaluation. - A resize takes `slot-gate` exclusively for the array copy. A fork is therefore a cut between individual publications. Every publication makes its result reachable last: slots are written before an environment mapping or slot value refers to the handle. Copy-section audit (JVM). Everything that runs while a fork holds the source's `publish-gate` and `slot-gate` write locks follows one rule: no user (interpreted) code, and it waits only on leaf locks, which are never held while waiting for another lock or for user code. The participants: - Primary snapshot (`realize-primary!`): reads Var roots and metadata, namespace metadata, Type data and SCI volatile/ref roots through `fork`'s snapshot fns; plain field reads. - Stock cache hooks (`IForkableWorldCache` of SCI's lazy caches): copy an existing realization in short map sections; they never realize a lazy value or take its realization monitor. The owner index is a WeakHashMap under its own monitor (leaf); owners hash by identity. - Trusted-Future check (`sci.fork/trusted-future?`): `isDone` only on exact FutureTask / CompletableFuture or a `clojure.core/future` wrapper around one (a volatile read); the wrapper's delegate is read reflectively, its Field cached in a ConcurrentHashMap (leaf bin locks, class reflection). - SCI's own copiers (`copy-cells!`), installed only by SCI and the host (`install-var-fork-fns!`), never from Var metadata or any evaluation: `fork-loaded-libs` (operand: the built-in `*loaded-libs*` root, a ref / atom only SCI's `add-loaded-lib` updates with `conj`; the JVM deref may wait for that commit's ref lock), the CLJS `fork-type-data` (operand: the type's JS prototype, which only SCI sets: interpreted `alter-meta!` and `-create-type` cannot replace it) and the ClojureDart method table (`identity`). Var copiers installed through `:fork-fns` are host code with the same rule. - The namespace environment snapshot: a deref of the env atom. - Retirement (`retire-world!`) is not inside a copy: it takes the slot read lock, so it waits for a copy in progress (and a copy for it); its cache hooks (`IWorldCache`) only drop private entries. - Failed-copy cleanup retires the unpublished target after the source's locks are released. - Host `IForkableWorldCache` / `IWorldCache` implementations are trusted host code under the same rule. The locks are blocking and non-fair: waiting under them is acyclic, but has no time bound. A fork's copy waits for in-flight slot writes and publications (which run no user code), and they wait for the copy.
(active-ctx captured)Use the currently evaluating descendant context for an interpreted closure. Unrelated SCI contexts cannot capture one another accidentally.
Use the currently evaluating descendant context for an interpreted closure. Unrelated SCI contexts cannot capture one another accidentally.
(alter-namespace-meta! handle fallback f args)(alter-namespace-meta! handle fallback f args mirror)(alter-type-data! handle fallback f args)(alter-type-data! handle fallback f args mirror)(alter-var-meta! handle fallback f args)(alter-var-meta! handle fallback f args mirror)(assert-type-usable! t)Refuse with the retired error unless (type-usable? t).
Refuse with the retired error unless `(type-usable? t)`.
(attach-managed-owner! registry managed-index owner)Attach weak ownership after constructing a self-described handle. The owner is never retained strongly by the lineage registry.
Attach weak ownership after constructing a self-described handle. The owner is never retained strongly by the lineage registry.
(binding-scope)Return the currently executing world for dynamic-binding isolation. Nil denotes a host binding established outside managed SCI evaluation.
Return the currently executing world for dynamic-binding isolation. Nil denotes a host binding established outside managed SCI evaluation.
(call-admitted ctx f)Run f, an evaluation of ctx that may enter its world several times
(one eval-string*), as one evaluation: admitted while the world is open,
it finishes even if the world is retired meanwhile.
Run `f`, an evaluation of `ctx` that may enter its world several times (one eval-string*), as one evaluation: admitted while the world is open, it finishes even if the world is retired meanwhile.
(call-with-context ctx f)Run f with ctx installed as both SCI's dynamic context and active world.
This is the host invocation boundary for interpreted values that outlive the
top-level evaluation which produced them.
Run `f` with `ctx` installed as both SCI's dynamic context and active world. This is the host invocation boundary for interpreted values that outlive the top-level evaluation which produced them.
(call-with-type-admitted t render fallback)Printing an instance of SCI type t. (render) runs with t's home
admitted on this thread, held through rendering, so the home's retirement
meanwhile cannot interrupt it. When the home is already retired (and the
active world has no definition of its own), or rendering meets the
engine's refusal of a retired world anywhere (a mutable field managed in
a retired world, a method made in one), (fallback e) is called with
that refusal (it may rethrow it, e.g. once staged output has streamed).
Any other exception propagates.
Printing an instance of SCI type `t`. `(render)` runs with `t`'s home admitted on this thread, held through rendering, so the home's retirement meanwhile cannot interrupt it. When the home is already retired (and the active world has no definition of its own), or rendering meets the engine's refusal of a retired world anywhere (a mutable field managed in a retired world, a method made in one), `(fallback e)` is called with that refusal (it may rethrow it, e.g. once staged output has streamed). Any other exception propagates.
(call-with-type-admitted-streaming t render fallback)call-with-type-admitted for a printer that writes straight to its
destination (the pretty printer): falls back only when the home is
refused before rendering starts; a refusal while rendering propagates.
`call-with-type-admitted` for a printer that writes straight to its destination (the pretty printer): falls back only when the home is refused before rendering starts; a refusal while rendering propagates.
(call-with-var-context handle f)Run f in the active related world for handle, or in the Var's stable
home world when invoked directly by the host. Shared built-in Vars have no
home and retain their direct compatibility behavior.
Run `f` in the active related world for `handle`, or in the Var's stable home world when invoked directly by the host. Shared built-in Vars have no home and retain their direct compatibility behavior.
(declare-type! handle data value-fork-fn)Analysis of a deftype: the type's slot holds its declaration data (its
name, marked :sci.impl/declared) before the namespace mapping publishes the
type, so a fork in between keeps it undefined. Marks no home: the world
that evaluates the deftype defines the type (-create-type).
Analysis of a deftype: the type's slot holds its declaration `data` (its name, marked `:sci.impl/declared`) before the namespace mapping publishes the type, so a fork in between keeps it undefined. Marks no home: the world that evaluates the deftype defines the type (`-create-type`).
(define-type-slot! handle value-fork-fn)-create-type, before it writes the definition (setVal, mirrored in a
primary's host field) and elects the home (elect-type-home!): the type's
descriptor in the current world, with the clone fn forks use.
`-create-type`, before it writes the definition (`setVal`, mirrored in a primary's host field) and elects the home (`elect-type-home!`): the type's descriptor in the current world, with the clone fn forks use.
(elect-type-home! handle)After a successful definition of type handle in the current world: make
that world its home unless one was elected before (a CAS on the Type).
After a successful definition of type `handle` in the current world: make that world its home unless one was elected before (a CAS on the Type).
(fork-recovery? error)Whether a failure retains an unpublished fork target for cleanup retry.
Whether a failure retains an unpublished fork target for cleanup retry.
(fork-world world fork-value snapshot-value snapshot-var-meta)(fork-world world
fork-value
snapshot-value
snapshot-var-meta
in-source
snapshot-extra)Fork world. The copy section excludes the source's slot writers and
publications (never its evaluations, which may include the caller's own):
it realizes a primary, copies the cells and the lazy realization caches
and calls snapshot-extra (the namespace environment), so all of them are
cut at one point. Host fork processing of the unpublished target runs
afterwards. in-source runs a thunk with the source's context bound
(primary realization reads host objects through it). Returns
[target-world extra].
Fork `world`. The copy section excludes the source's slot writers and publications (never its evaluations, which may include the caller's own): it realizes a primary, copies the cells and the lazy realization caches and calls `snapshot-extra` (the namespace environment), so all of them are cut at one point. Host fork processing of the unpublished target runs afterwards. `in-source` runs a thunk with the source's context bound (primary realization reads host objects through it). Returns [target-world extra].
Trusted provenance of :sci/built-in on a SCI Var or namespace. The flag,
not the object's stored metadata, decides write protection, a Var's
home, whether forks process its value (host-fork?) and :allow's
implicit permission of non-built-in Vars; metadata reads report it.
sci.core/new-var,
new-dynamic-var, new-macro-var and create-ns (and SCI's own
tables) from their construction metadata.sci.impl.vars/meta-write-source):
host code may set or clear it (JVM alter-meta! with no SCI context bound,
sci/alter-var-meta!, sci/reset-var-meta!; clearing still passes the
write check); an :unrestricted evaluation may only set it.def, defonce, intern, ns, alter-meta!,
reset-meta!) can neither set nor clear it, and interop cannot reach
-set-built-in! (sci.impl.reflector/internal-class?).
The flag belongs to the object: it holds for every world and lineage
holding it, also a fork whose stored metadata predates it.Trusted provenance of `:sci/built-in` on a SCI Var or namespace. The flag, not the object's stored metadata, decides write protection, a Var's home, whether forks process its value (`host-fork?`) and `:allow`'s implicit permission of non-built-in Vars; metadata reads report it. - Set at construction by the host constructors `sci.core/new-var`, `new-dynamic-var`, `new-macro-var` and `create-ns` (and SCI's own tables) from their construction metadata. - Afterwards by trusted metadata writes (`sci.impl.vars/meta-write-source`): host code may set or clear it (JVM `alter-meta!` with no SCI context bound, `sci/alter-var-meta!`, `sci/reset-var-meta!`; clearing still passes the write check); an `:unrestricted` evaluation may only set it. - Interpreted metadata (`def`, `defonce`, `intern`, `ns`, `alter-meta!`, `reset-meta!`) can neither set nor clear it, and interop cannot reach `-set-built-in!` (`sci.impl.reflector/internal-class?`). The flag belongs to the object: it holds for every world and lineage holding it, also a fork whose stored metadata predates it.
(-built-in? x)(-set-built-in! x built-in?)(-fork-world-cache! owner source target)Copy an existing source realization into the unpublished target without invoking deferred computation. Missing source state remains missing. Called inside the fork's copy section: it must not block or run user code.
Copy an existing source realization into the unpublished target without invoking deferred computation. Missing source state remains missing. Called inside the fork's copy section: it must not block or run user code.
(install-var-fork-fns! world fork-fns)Host install time only (init / merge-opts :fork-fns, and SCI's own
*loaded-libs* from init-env!): give each Var in fork-fns (Var ->
copier) that copy-time fork fn in world's lineage registry. The copier
then runs on the Var's value inside every later fork's copy section, under
the source's locks, so it is trusted host code that never blocks, takes a
lock or runs interpreted code.
The registry is shared by every context of the lineage (forks and siblings): this is lineage policy, applying to all their later forks. A descriptor's copier is set once and never changes: installing the same fn again is a no-op, a different one is refused. A Var registered earlier without a copier receives it here (still a host call, never an evaluation). Nothing in evaluation, including Var metadata, installs or upgrades a copier.
Host install time only (`init` / `merge-opts` `:fork-fns`, and SCI's own `*loaded-libs*` from `init-env!`): give each Var in `fork-fns` (Var -> copier) that copy-time fork fn in `world`'s lineage registry. The copier then runs on the Var's value inside every later fork's copy section, under the source's locks, so it is trusted host code that never blocks, takes a lock or runs interpreted code. The registry is shared by every context of the lineage (forks and siblings): this is lineage policy, applying to all their later forks. A descriptor's copier is set once and never changes: installing the same fn again is a no-op, a different one is refused. A Var registered earlier without a copier receives it here (still a host call, never an evaluation). Nothing in evaluation, including Var metadata, installs or upgrades a copier.
(instance-print-method type-meta)The print-method of type type-meta, or nil (see printing-entry).
The print-method of type `type-meta`, or nil (see `printing-entry`).
(-world-cache-entry owner world)This owner's realization for world, or nil. Retirement keeps it in the
retired world itself, so evaluations still running there find it after
the owner released it.
This owner's realization for `world`, or nil. Retirement keeps it in the retired world itself, so evaluations still running there find it after the owner released it.
A SCI Type's data under forks (type-data-of); implemented by
sci.lang.Type, which owns the host field.
A SCI Type's data under forks (`type-data-of`); implemented by `sci.lang.Type`, which owns the host field.
(-data-for t)The type's definition as its instances' methods see it
(type-data-of with instance-call?).
The type's definition as its instances' methods see it (`type-data-of` with `instance-call?`).
(-own-data t clone)The active world's own realization of the data, else (clone host-field):
the base of a (re)definition in that world. Writes nothing.
The active world's own realization of the data, else `(clone host-field)`: the base of a (re)definition in that world. Writes nothing.
(-own-data! t clone)The active world's own realization, first copied (copy-on-write, through
clone) from the authoritative data when that world has none.
The active world's own realization, first copied (copy-on-write, through `clone`) from the authoritative data when that world has none.
(-retire-world-cache! owner world)Release this managed owner's cache for one retired world. This internal hook only removes private cache entries: no user callbacks or I/O. It must be idempotent so failed retirement can be retried.
Release this managed owner's cache for one retired world. This internal hook only removes private cache entries: no user callbacks or I/O. It must be idempotent so failed retirement can be retried.
(-mark-world-tracked! handle home-ctx)(-world-home-ctx handle)(-world-tracked? handle)(managed-assoc! home registry slot k value)Associate one key in a managed persistent-map slot without the generic callback/validation path. Used by mutable SCI deftype fields.
Associate one key in a managed persistent-map slot without the generic callback/validation path. Used by mutable SCI deftype fields.
(managed-compare-and-set! home registry slot expected new validate! notify!)(managed-compare-and-set! home
registry
slot
expected
new
validate!
notify!
coordination)(managed-compare-and-set! home
registry
slot
expected
new
validate!
notify!
coordination
validation-current?)(managed-reset! home registry slot new validate! notify!)(managed-reset! home registry slot new validate! notify! coordination)(managed-reset! home
registry
slot
new
validate!
notify!
coordination
validation-current?)(managed-swap! home registry slot f args validate! notify!)(managed-swap! home registry slot f args validate! notify! coordination)(managed-swap! home
registry
slot
f
args
validate!
notify!
coordination
validation-current?)CAS a directly described slot. The logical fallback represents a slot allocated in another branch but not yet realized in the selected world.
CAS a directly described slot. The logical fallback represents a slot allocated in another branch but not yet realized in the selected world.
(managed-update-control-with-value! home
registry
value-slot
control-slot
coordination
validate-value!
update-control)Atomically validate the selected value and update a related control slot.
coordination must be the same stable handle used by value commits.
Atomically validate the selected value and update a related control slot. `coordination` must be the same stable handle used by value commits.
(managed-value home registry slot)Read a self-described managed slot in the active related world, falling back to the owner's creation world outside managed evaluation.
Read a self-described managed slot in the active related world, falling back to the owner's creation world outside managed evaluation.
(managed-value-in world home slot)Read a managed slot from an already selected world.
Read a managed slot from an already selected world.
(mutable-primary-write! handle value write-root!)Write value to the host object of handle (a volatile) in a
still-mutable primary world: (write-root! value) inside one slot
section, so the first fork's realization (which holds the section
exclusively) reads the root before or after the write, never in between
related writes. If the realization happened meanwhile, the write takes the
realized path: slot first, then the root mirrored from it.
Write `value` to the host object of `handle` (a volatile) in a still-mutable primary world: `(write-root! value)` inside one slot section, so the first fork's realization (which holds the section exclusively) reads the root before or after the write, never in between related writes. If the realization happened meanwhile, the write takes the realized path: slot first, then the root mirrored from it.
(own-realization handle)The current world's own slot value of type handle (also a declaration),
or nil: no home or host-field lookup (a fork copying a CLJS instance).
The current world's own slot value of type `handle` (also a declaration), or nil: no home or host-field lookup (a fork copying a CLJS instance).
(own-type-data handle fallback clone)The active world's own realization of handle's data, else (clone fallback) (clone may be nil). Writes nothing.
The active world's own realization of `handle`'s data, else `(clone fallback)` (`clone` may be nil). Writes nothing.
(own-type-data! handle read clone mirror)The active world's own realization of handle's data. A world without
one first gets a copy of the authoritative data ((read)) through
clone (copy-on-write): a write never mutates another world's data.
The active world's own realization of `handle`'s data. A world without one first gets a copy of the authoritative data (`(read)`) through `clone` (copy-on-write): a write never mutates another world's data.
(print-to t out render fallback)Print an instance of SCI type t to writer out with a user printer:
(render out) writes straight to out (no staging, as upstream), with
t's home admitted through rendering. When the home is already retired
the fallback form (fallback) is written instead. A refusal met after
the printer started (another retired world it reads) propagates.
Print an instance of SCI type `t` to writer `out` with a user printer: `(render out)` writes straight to `out` (no staging, as upstream), with `t`'s home admitted through rendering. When the home is already retired the fallback form `(fallback)` is written instead. A refusal met after the printer started (another retired world it reads) propagates.
(printing-entry type-meta k)The entry k (a print-method or pprint dispatch) of type type-meta as
its instances see it, or nil. Nil also when its home is retired: the
printer then prints the default form and calls no user code.
The entry `k` (a print-method or pprint dispatch) of type `type-meta` as its instances see it, or nil. Nil also when its home is retired: the printer then prints the default form and calls no user code.
(publishing f)publishing-in the world of SCI's current context, or plain (f) outside
a forkable context.
`publishing-in` the world of SCI's current context, or plain `(f)` outside a forkable context.
(publishing-in world f)Run f as one publication in world: a fork's copy observes all of its
writes or none. f must not run user code; callbacks it triggers through
run-after-publication! run after the publication, in order.
Run `f` as one publication in `world`: a fork's copy observes all of its writes or none. `f` must not run user code; callbacks it triggers through `run-after-publication!` run after the publication, in order.
(recover-failed-fork! error)Retry cleanup of the unpublished target retained by a failed SCI fork. Never re-executes the fork or changes its source. A subsequent cleanup failure retains the same target and original failure for another retry.
Retry cleanup of the unpublished target retained by a failed SCI fork. Never re-executes the fork or changes its source. A subsequent cleanup failure retains the same target and original failure for another retry.
(register-managed! kind values fork-indexes)Allocate dense slots whose owner carries the returned descriptor directly.
Managed descriptors contain no owner reference, so an unreachable SCI ref is
not retained by the lineage registry. fork-indexes names values that need
host Forkable/:fork-fn processing when a child world is copied.
Allocate dense slots whose owner carries the returned descriptor directly. Managed descriptors contain no owner reference, so an unreachable SCI ref is not retained by the lineage registry. `fork-indexes` names values that need host `Forkable`/`:fork-fn` processing when a child world is copied.
(register-var! handle value m)(register-var! handle value m watches)(register-var! handle value m watches mirror-root)Write a Var's value and metadata (and watches) in one slot section.
mirror-root, when given, writes the primary world's Var root in that
same section (see mirror!).
Write a Var's value and metadata (and watches) in one slot section. `mirror-root`, when given, writes the primary world's Var root in that same section (see `mirror!`).
(register-world-cache! owner)Register an identity-based internal owner of fork-local realizations. The lineage index retains the owner weakly and does not allocate dense slots. Owners must implement both cache protocols and must not use content-based hashing/equality (in particular, the owner is not a sequence view).
Register an identity-based internal owner of fork-local realizations. The lineage index retains the owner weakly and does not allocate dense slots. Owners must implement both cache protocols and must not use content-based hashing/equality (in particular, the owner is not a sequence view).
(reset-namespace-meta! handle m)(reset-namespace-meta! handle m mirror)(reset-value! handle value)(reset-value! handle value mirror)Reset a tracked slot; mirror (optional) writes the primary world's host
object in the same slot section.
Reset a tracked slot; `mirror` (optional) writes the primary world's host object in the same slot section.
(retire-world! world)Retire one interpreter world now. New evaluations and forks are refused; evaluations already running in it finish against it. Managed cache owners release their world-specific state (the world keeps what running evaluations still need). When no evaluation is in the world, now or once the last one leaves, its cells and retained caches are cleared; the small closed world remains for Vars whose home it is, which then refuse access. This does not close foreign host resources or retire sibling worlds. Safe to repeat after a failed cache cleanup.
Retire one interpreter world now. New evaluations and forks are refused; evaluations already running in it finish against it. Managed cache owners release their world-specific state (the world keeps what running evaluations still need). When no evaluation is in the world, now or once the last one leaves, its cells and retained caches are cleared; the small closed world remains for Vars whose home it is, which then refuse access. This does not close foreign host resources or retire sibling worlds. Safe to repeat after a failed cache cleanup.
(retired-cache-entry world owner)The realization owner held for the retired world when it was retired,
or nil. Evaluations still running in a retired world read their caches
here after the owners released them.
The realization `owner` held for the retired `world` when it was retired, or nil. Evaluations still running in a retired world read their caches here after the owners released them.
(retired-error? e)Whether e, or an exception it wraps (SCI wraps errors raised in
interpreted code with their location), is the engine's own refusal of a
retired world: identified by a private marker, never by the public
:type an application exception may also carry.
Whether `e`, or an exception it wraps (SCI wraps errors raised in interpreted code with their location), is the engine's own refusal of a retired world: identified by a private marker, never by the public `:type` an application exception may also carry.
(retired-refusal)The engine's refusal of an access to a retired world.
The engine's refusal of an access to a retired world.
(run-after-publication! thunk)Run thunk now, or after the publication this thread is inside ends.
Used for user callbacks (watches) triggered by a published write.
Run `thunk` now, or after the publication this thread is inside ends. Used for user callbacks (watches) triggered by a published write.
(selected-world)The actual selected world, including the target selected during copying.
The actual selected world, including the target selected during copying.
(slot-of world handle)Return the value slot assigned to handle, or nil when it is not registered
in this lineage. Intended for analyzer-time resolution.
Return the value slot assigned to `handle`, or nil when it is not registered in this lineage. Intended for analyzer-time resolution.
(swap-value! handle f args validate! notify!)Atomically update one tracked slot. Unrelated SCI atoms do not contend and
cannot cause f to be retried. f and validate! run outside every lock.
Atomically update one tracked slot. Unrelated SCI atoms do not contend and cannot cause `f` to be retried. `f` and `validate!` run outside every lock.
(sync-primary-root! handle read-root)After a root write to handle that ran user code (a host atom's swap!)
in a primary world: once that world is realized, make its slot agree with
the current root (read-root). Each syncing writer re-reads the root after
writing the slot, so the last one leaves them equal. The root write itself
precedes this section; no JVM/CLJS path tracks a host atom.
After a root write to `handle` that ran user code (a host atom's swap!) in a primary world: once that world is realized, make its slot agree with the current root (`read-root`). Each syncing writer re-reads the root after writing the slot, so the last one leaves them equal. The root write itself precedes this section; no JVM/CLJS path tracks a host atom.
(type-data handle fallback)A Type's data for a type-level read: see type-data-of.
A Type's data for a type-level read: see `type-data-of`.
(type-data-at handle home instance-call? fallback)type-data-of for a type known to be tracked, with its home's ReadWorld
(nil when it has no unambiguous home): sci.lang.Type calls this with
the home it holds, the hot path of every type method call.
`type-data-of` for a type known to be tracked, with its home's ReadWorld (nil when it has no unambiguous home): `sci.lang.Type` calls this with the home it holds, the hot path of every type method call.
(type-data-of handle instance-call? fallback)A SCI Type's data, which holds the built-in interface methods of its
instances (types/type-call):
fallback): a type never defined in a world, or
registered in unrelated lineages.
For a method lookup (instance-call?) a world that only has the
analysis-time declaration has no definition. A type-level read takes the
declaration as the world's own data, so a world forked between a type's
analysis and its definition elsewhere keeps the bare declaration.A SCI Type's data, which holds the built-in interface methods of its instances (`types/type-call`): 1. the active world's own realization (definitions resolve where they are invoked), read directly: its entry is already counted; 2. else the type's home (the world that evaluated its definition), inside a counted access of the home: refused once retired, as for a Var; 3. else the host field (`fallback`): a type never defined in a world, or registered in unrelated lineages. For a method lookup (`instance-call?`) a world that only has the analysis-time declaration has no definition. A type-level read takes the declaration as the world's own data, so a world forked between a type's analysis and its definition elsewhere keeps the bare declaration.
(type-method t k)The method stored under k in the definition of type t, or nil.
The method stored under `k` in the definition of type `t`, or nil.
(type-usable? t)Whether the methods of SCI type t may run here: false when its home is
retired and the active world has no definition of its own. Used where a
method runs without reading the type's data first (CLJS native protocol
slots, toString, invoke, printing).
Whether the methods of SCI type `t` may run here: false when its home is retired and the active world has no definition of its own. Used where a method runs without reading the type's data first (CLJS native protocol slots, `toString`, invoke, printing).
(var-meta handle fallback)A Var's metadata in its selected world. Unlike its value, metadata without a realization there falls back to the Var's own field (name, namespace), so printing a retired world's Var still works.
A Var's metadata in its selected world. Unlike its value, metadata without a realization there falls back to the Var's own field (name, namespace), so printing a retired world's Var still works.
(var-value handle fallback)Primary contexts retain their direct Var realization. Descendants resolve the stable Var handle through its dense lineage slot.
Primary contexts retain their direct Var realization. Descendants resolve the stable Var handle through its dense lineage slot.
(var-value-at slot fallback)Read a Var through a slot already resolved by the analyzer: its value in
the active world, absent when that world has no realization of it (the
caller then reads the Var fully, which consults its home), or fallback
outside a forked world.
Read a Var through a slot already resolved by the analyzer: its value in the active world, `absent` when that world has no realization of it (the caller then reads the Var fully, which consults its home), or `fallback` outside a forked world.
(with-active-world ctx f)Run f with the context's world installed. Evaluation takes no world
lock: a fork excludes only slot writers, for its copy, and a retirement
only refuses new entries.
Run `f` with the context's world installed. Evaluation takes no world lock: a fork excludes only slot writers, for its copy, and a retirement only refuses new entries.
(with-selected-slot-section f)Run f (no user code) as one slot write of the selected world, so a fork's
copy sees it entirely or not at all. Used for lazy realization steps.
Run `f` (no user code) as one slot write of the selected world, so a fork's copy sees it entirely or not at all. Used for lazy realization steps.
(world-cache-owners)(world-cache-owners world)An eager strong snapshot of currently live cache owners in a lineage. Inspection also removes dead weak entries. Closed worlds retain their registry until cleanup succeeds, so retirement may call this function.
An eager strong snapshot of currently live cache owners in a lineage. Inspection also removes dead weak entries. Closed worlds retain their registry until cleanup succeeds, so retirement may call this function.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |