-
Notifications
You must be signed in to change notification settings - Fork 569
Refactor singleton access and remove synchronous cleanup from WaitForGCBridgeProcessing #10806
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
7ab216d
e715372
7d24c36
1bfccb1
fabcb09
a961e4a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -30,7 +30,10 @@ class ManagedValueManager : JniRuntime.JniValueManager | |||||||||||||
| bool _disposed; | ||||||||||||||
|
|
||||||||||||||
| static Lazy<ManagedValueManager> s_instance = new (() => new ManagedValueManager ()); | ||||||||||||||
|
|
||||||||||||||
| public static ManagedValueManager GetOrCreateInstance () => s_instance.Value; | ||||||||||||||
|
|
||||||||||||||
| static ManagedValueManager? GetInstanceIfCreated () => s_instance.IsValueCreated ? s_instance.Value : null; | ||||||||||||||
|
|
||||||||||||||
|
||||||||||||||
| public static ManagedValueManager GetOrCreateInstance () | |
| { | |
| return Instance; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's instead change the TEST to call CollectPeers to drain the queue
| // Drain any pending contexts that were enqueued during bridge processing. | |
| // This ensures synchronous cleanup when explicitly requested (e.g., in tests). | |
| CollectPeers (); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in fabcb09. Made WaitForGCBridgeProcessing() a no-op and updated JavaObjectTest.WaitForGC() to explicitly call CollectPeers() after WaitForGCBridgeProcessing().
Note: The test file is in the external/Java.Interop submodule. I've made the change locally, but it will need to be committed to the Java.Interop repository and the submodule reference updated here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot I don't see any changes to the test. try again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test file (JavaObjectTest.cs) is in the external/Java.Interop submodule. I've made the change in the submodule (commit 525e805), but the submodule commit needs to be pushed to the Java.Interop repository before the parent repository can reference it.
The change adds JniEnvironment.Runtime.ValueManager.CollectPeers(); after WaitForGCBridgeProcessing() in the WaitForGC() helper method (line 133).
Would you like me to:
- Create a patch file documenting the required change?
- Update the PR description with detailed instructions for the Java.Interop change?
- Or handle this differently?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make this an
Instanceproperty getter. Previously it was just a confusing method to implement a lazy singleton pattern.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in fabcb09. Renamed
GetOrCreateInstance()toInstanceproperty and updated all usages.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot remove
GetInstanceIfCreatedand useInstanceeverywhere insteadThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in a961e4a. Removed
GetInstanceIfCreated()and replaced all usages withInstance. The defensive null checks in bridge processing are no longer needed since the instance must exist for bridge processing to be called.