[foreign-preview] RFR: 8281855: Rename ResourceScope to MemorySession [v6]
Jorn Vernee
jvernee at openjdk.java.net
Mon Feb 21 13:36:12 UTC 2022
On Mon, 21 Feb 2022 12:16:01 GMT, Jorn Vernee <jvernee at openjdk.org> wrote:
>> Maurizio Cimadamore has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Fix spurious reference to ResourceScopeImpl after merge
>
> src/java.base/share/classes/java/lang/foreign/MemorySession.java line 147:
>
>> 145: * a thread other than the thread {@linkplain #ownerThread() owning} this memory session.
>> 146: */
>> 147: void addCloseAction(Runnable runnable);
>
> A note here, or on `openImplicit`, saying that a close action should not reference the session itself would be good I think. Suggestion inline (feel free to change).
> Suggestion:
>
> /**
> * Add a custom cleanup action which will be executed when the memory session is closed.
> * The order in which custom cleanup actions are invoked once the memory session is closed is unspecified.
> * <p>
> * Users should take care so that the {@code Runnable} instance provided as a close action does not reference this
> * memory sessison. This will create a reference cycle that will keep the session alive indefinitely if it is expected to be
> * cleanup up by a cleaner.
> * @param runnable the custom cleanup action to be associated with this memory session.
> * @throws IllegalStateException if this memory session is not {@linkplain #isAlive() alive}, or if access occurs from
> * a thread other than the thread {@linkplain #ownerThread() owning} this memory session.
> */
> void addCloseAction(Runnable runnable);
Though, this was pre-existing... so could be done in a followup as well.
-------------
PR: https://git.openjdk.java.net/panama-foreign/pull/641
More information about the panama-dev
mailing list