8275063: Implementation of Foreign Function & Memory API (Second incubator)

Reviewed-by: erikj, psandoz, jvernee, darcy
This commit is contained in:
Maurizio Cimadamore 2021-11-24 11:51:16 +00:00
parent 17e68caad7
commit 96e36071b6
191 changed files with 9463 additions and 7631 deletions

View file

@ -475,15 +475,15 @@ public class IOUtil {
private static final JavaNioAccess NIO_ACCESS = SharedSecrets.getJavaNioAccess();
static Scope.Handle acquireScope(ByteBuffer bb, boolean async) {
static Runnable acquireScope(ByteBuffer bb, boolean async) {
return NIO_ACCESS.acquireScope(bb, async);
}
private static void releaseScope(Scope.Handle handle) {
private static void releaseScope(Runnable handle) {
if (handle == null)
return;
try {
handle.scope().release(handle);
handle.run();
} catch (Exception e) {
throw new IllegalStateException(e);
}
@ -535,11 +535,11 @@ public class IOUtil {
}
}
static record Releaser(Scope.Handle handle) implements Runnable {
static record Releaser(Runnable handle) implements Runnable {
Releaser { Objects.requireNonNull(handle) ; }
@Override public void run() { releaseScope(handle); }
static Runnable of(Scope.Handle handle) { return new Releaser(handle); }
static Runnable ofNullable(Scope.Handle handle) {
static Runnable of(Runnable handle) { return new Releaser(handle); }
static Runnable ofNullable(Runnable handle) {
if (handle == null)
return () -> { };
return new Releaser(handle);