File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
src/main/java/org/truffleruby/extra/ffi Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,10 @@ public static Pointer callocAutoRelease(long size, RubyLanguage langauge) {
65
65
private Cleanable cleanable = null ;
66
66
private AutoReleaseState autoReleaseState = null ;
67
67
68
+ /** This is needed because we need a mutable object to hold the pointer address so that it can be freed or marked as
69
+ * not to be freed if auto-release is disabled. THis can't be the address field on the pointer itself as that would
70
+ * prevent the pointer from being collected, and we can't retrieve this from the cleaner as it is effectively
71
+ * opaque. */
68
72
private static class AutoReleaseState implements Runnable {
69
73
70
74
long address ;
@@ -352,8 +356,9 @@ public synchronized void enableAutorelease(RubyLanguage language) {
352
356
353
357
@ TruffleBoundary
354
358
private void enableAutoreleaseUnsynchronized (RubyLanguage language ) {
355
- // We must be careful here that the finalizer does not capture the Pointer itself that we'd
356
- // like to finalize.
359
+ // We must be careful here that the cleaner does not capture
360
+ // the Pointer itself, and that we a form of mutable state
361
+ // that will allow use to disable autorelease later.
357
362
autoReleaseState = new AutoReleaseState (address );
358
363
cleanable = language .cleaner .register (this , autoReleaseState );
359
364
You can’t perform that action at this time.
0 commit comments