<-Back

Function: Gendl::%Demand-Value-Structurally%

%DEMAND-VALUE-STRUCTURALLY%

Compute-once demand discipline for one slot (Race A) with edge recording through ADD-NOTIFY-CONS (which, under *run-with-structural-thread-safety?*, appends to the lock-free notify log -- Races B/C). READER and WRITER close over the slot accessor; COMPUTE closes over the rule body with the usual *notify-cons* rebinding. Returns a FRESH cons whose FIRST is the validated value -- never the live cell: the caller's FIRST would otherwise re-read a car that an invalidator may have re-claimed between our re-validation and the read (marker-escape TOCTOU, found by the Allegro-SMP throughput A/B 2026-07-21). Publication and invalidation both go through CAS on the cell's car (which doubles as a memory barrier on the supported implementations): a failed publish means an invalidator stole our claim mid-compute (our inputs changed under us), so we discard and retry. The bound path re-validates the car after recording its edge: if an invalidation intervened, the edge may have missed the walk, so we retry rather than return a value that would never be invalidated for us (Race D, reader side). The claim is released on ALL exits, including a signaling rule body -- a leaked marker would strand every future demander of the slot.


<-Back