Repository navigation
Lean NativeObject: NativeObjectChild/Parent split, lock-free plain close - #353
Merged
Merged
Conversation
NativeObject keeps only the pointer, close-once and immortal state; the parents array and borrowedFrom move to NativeChild, which only the wrappers that borrow from an owner extend. NativeObjectWithChildren creates its children set on the first registerChild, so a parent that never gets a child allocates none. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…oses lock-free NativeObject holds its pointer in a volatile field swapped with a VarHandle, so it allocates no AtomicReference and takes no monitor. release(), the private monitor and the wait-for-an-in-progress-release behavior move to NativeObjectChild, the only class a parent's sweep releases. The hook is now afterRelease(). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…the second only if the first kept us The two-parent form no longer keeps the caller's varargs array; childOf takes one or two parents. If the first parent abandoned the child there is nothing to register with the second. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.
Summary
NativeObjectChild(extended by the 7 wrappers that borrow from an owner) holdsparents,borrowedFrom,release(), its private monitor and the wait for an in-progress release.NativeObjectWithChildrenis renamedNativeObjectParentand extends it (aTransactionis both).NativeObject(45 classes, includingPinnableHandleon everyget) holds its pointer in a volatile field swapped with aVarHandle: noAtomicReferenceallocation and nosynchronizedonclose(). A racingclose()loser returns at once, as before.NativeObjectParentcreates its children set on the firstregisterChild.afterRelease();doRelease()is the one shared swap,tryClose, hook sequence.Test plan
./mvnw test -pl core -am,./mvnw package -pl core -am -DskipTests(javadoc),java scripts/CheckPrototypes.javagetpath is unmeasured🤖 Generated with Claude Code