Repository navigation
feat(ts): write a lazy cell, a lazy lock, a poll_fn, and a thread-local key whole through a reference - #508
Merged
Merged
Conversation
Quest-Claim: 8179264eb8ad9f1d
…al key whole through a reference Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
# Conflicts: # ts/fixtures/reject/census.txt # ts/fixtures/reject/expected.txt # ts/runtime/rt.ts # ts/runtime/rt/task.ts
kixelated
marked this pull request as ready for review
November 3, 2026 09:50
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 38 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. CodeRabbit Verify
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A whole write through a
&mutto aLazyCell,LazyLock,PollFn, orLocalKey(*r = v,mem::replace,mem::swap,Cell::from_mut(r).set, a mappedRefMut) was refused since #386, because the runtime keeps their state in#privatefields that theObject.assignfield copy misses.Approach
rt.LazyCell(sort.LazyLock) andrt.PollFneach own a$move(to?)method that moves their private state intoto, or into a new object.ptrWrite,replaceIn,objectCopy(socellInandpartPlace) use it when an object has it.*r = von these types lowers tort.ptrWriteinstead ofObject.assign.LocalKeyis a handle: every copy of theconstnames the same storage, so moving its state into another key would change that key for every user. A&mut LocalKeyis now anrt.Place, as anArc's is, so a write changes which key the place holds. A key'sconstused as a value, not only borrowed, now maps to its module value. Without that, a stock crate can't get an owned key to write.$move), not a symbol, because esbuild keeps any class with a computed key and that broke the codec tree-shake test. No Rust field can be named$move.Tests, each differential against native Rust:
lang/staticswrites: aLazyCelland aLazyLockwhose function owns a value with aDropimpl. Each write way, with neither, either, or both forced first. It checksDebug, the value, how many times the function ran, and drop order.lang/localskeys: a copy of one key written with another by each way. It checks which key the copy names after the write and that neither key's storage changed.taskfutures::boxed:poll_fns written by each way, plus aPin<Box<PollFn>>written whole. It checks drop order and which function polls.I confirmed the statics and task tests fail when the runtime move is disabled. The four reject cases these replace are removed.
Impact
&mut LocalKeyis anrt.Place<rt.LocalKey<T>>.objectCopyandptrWritemove$moveclasses.rt.PollFn's fields are no longerreadonly. Nothing is breaking.Alternatives
rt.MOVE): this broke tree-shaking (above).replaceIn,cellIn, andpartPlaceper class, for the same result.LocalKey's state like a lazy cell's: this is wrong, because the key's other copies share that storage.Follow-ups
None.
Review
Codex gpt-6.1-sol, medium, round 1 on d90460f: no findings. Since then, a conflict-free merge of origin/main into 26361c3.
🤖 Generated with Claude Code