You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Current AsyncContext spec proposal allows Variable.prototype.run to be implemented very efficiently by saving and restoring an immutable context mapping. Essentially:
This will no longer work if we want v1.run not to clobber a value set by v2.withValue - implementations would instead need to do something more along the lines of
Variable.prototype.run=function(newValue,func){constoldValue=GLOBAL_MAPPING[this.key];try{GLOBAL_MAPPING={...GLOBAL_MAPPING,[this.key]: newValue};returnfunc();}finally{GLOBAL_MAPPING={...GLOBAL_MAPPING,[this.key]: oldValue};// extra copy}}
or else we could make GLOBAL_MAPPING mutable and make Snapshot construction much slower by needing to make defensive copies.
It may be possible to use a persistent data structure (e.g. a HAMT or some such) so that the copies/updates are O(log n) instead of O(n), but AIUI that's not currently the implementation plan.
The text was updated successfully, but these errors were encountered:
Current
AsyncContext
spec proposal allowsVariable.prototype.run
to be implemented very efficiently by saving and restoring an immutable context mapping. Essentially:This will no longer work if we want
v1.run
not to clobber a value set byv2.withValue
- implementations would instead need to do something more along the lines ofor else we could make
GLOBAL_MAPPING
mutable and makeSnapshot
construction much slower by needing to make defensive copies.It may be possible to use a persistent data structure (e.g. a HAMT or some such) so that the copies/updates are O(log n) instead of O(n), but AIUI that's not currently the implementation plan.
The text was updated successfully, but these errors were encountered: