Repository navigation
origins.mojo on threads-mojo 0.3.0: the state by ref, the task by mut - #5
Merged
Merged
Conversation
The typed parallel_for does in the library what this file did in user code: the origin of `totals` is bound to a ref argument, alive for the whole call, and the void * erasure happens once, out of sight. So Ctx, share and run go, and the program is the post's listing minus the pointer plumbing. Rewritten in place — the file has been linked to. Tests follow the API. The two Ctx-lifetime cases (returning one to a local, one outliving its block) have no equivalent now that there is no user-visible value carrying the origin, and are removed. share_* become state_*, the same diagnostic from parallel_for's ref argument. opaque_escapes_origin now uses the opaque overload directly: Int(…) on a tracked Pointer is where the origin stops. 6 passed, 0 failed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015or6oTZmb7EQTXTbALbBXY
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.
src/origins.mojorewritten in place — same file, same link — against threads-mojo 0.3.0's typedparallel_for:Ctx,shareandrunare gone: the library now binds the origin to therefargument and does the onevoid *erasure itself. The docstring keeps a paragraph on the earlier version for anyone arriving from the posted file.Tests follow the API.
share_immutable/share_temporary→state_immutable/state_temporary, same diagnostic fromparallel_for'srefargument.return_ctx_to_localandctx_outlives_blockare removed — there is no user-visible value carrying the origin any more, so nothing to leak.opaque_escapes_originnow calls the opaque overload onopaque_ptr(Int(Pointer(to=totals))):Int(…)is where the origin stops. The other three uncaught cases are the same bugs through the typed call.pixi.lockregenerated with pixi 0.78.0 (CI's pin). Both programs printsum: 499500;pixi run check: 6 passed, 0 failed.🤖 Generated with Claude Code
https://claude.ai/code/session_015or6oTZmb7EQTXTbALbBXY