[foreign-memaccess] RFR: Alternative scalable MemoryScope

Peter Levart plevart at openjdk.java.net
Tue May 5 07:08:39 UTC 2020


On Mon, 4 May 2020 16:55:20 GMT, Paul Sandoz <psandoz at openjdk.org> wrote:

>> This is an alternative MemoryScope which is more scalable when used in a scenario where child scope is frequently
>> acquired and closed concurrently from multiple threads (for example in parallel Stream.findAny())
>
> src/jdk.incubator.foreign/share/classes/jdk/internal/foreign/MemoryScope.java line 158:
> 
>> 157:             int state = (int) STATE.getVolatile(this);
>> 158:             while (state > STATE_OPEN) {
>> 159:                 if (state == STATE_CLOSED) {
> 
> You could do the following to limit to one VH call:
> int state;  // perhaps rename to not shadow the field
> while ((state = (int) STATE.getVolatile(this)) > STATE_OPEN) {
>    ...
> }

Sure, that's possible. Thanks.

-------------

PR: https://git.openjdk.java.net/panama-foreign/pull/142


More information about the panama-dev mailing list