[foreign-jextract] RFR: Improve NIO channel support for buffer views over segments [v3]

Maurizio Cimadamore mcimadamore at openjdk.java.net
Thu Apr 22 12:50:40 UTC 2021


On Thu, 22 Apr 2021 11:39:46 GMT, Chris Hegarty <chegar at openjdk.org> wrote:

>> Initial prototype changes to use resource scope handles when performing I/O operations with synchronous and asynchronous channels.
>
> Chris Hegarty has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Resolve outstanding TODO in MemoryScope spec

src/java.base/share/classes/java/nio/Buffer.java line 828:

> 826:                 public Scope.Handle acquireScope(Buffer buffer, boolean async) {
> 827:                     var scope = buffer.scope();
> 828:                     if (scope == null || scope.isImplicit()) {

do you still need the null handling (both here and in IOUtil) ? We just return a singleton now for implicit scope, so I think you can make the code more regular w/o losing any performance.

src/java.base/share/classes/java/nio/Buffer.java line 831:

> 829:                         return null;
> 830:                     }
> 831:                     if (async && scope.ownerThread() != null) {

Crazy idea - are we sure we need this check? If user wants to really pass a confined buffer to an async IO, I belive a failure would still occur when the segment is accessed by a different thread - do you see reporting an error eagerly as something important? Will fibers change things so that e.g. we might be able to do more with a _single_ thread?

src/java.base/share/classes/jdk/internal/misc/X-ScopedMemoryAccess.java.template line 109:

> 107:         Thread ownerThread();
> 108: 
> 109:         boolean isImplicit();

sorry for the extra shuffling - this will all go away when we exit incubation ;-)

src/jdk.incubator.foreign/share/classes/jdk/incubator/foreign/ResourceScope.java line 118:

> 116:  * accessing/closing the resources associated with the shared resource scope.
> 117:  *
> 118:  * <h2>Resource scope handles</h2>

Not sure why I'm seeing these changes?

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

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


More information about the panama-dev mailing list