mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8310644: Make panama memory segment close use async handshakes
Reviewed-by: jvernee, mcimadamore, pchilanomate
This commit is contained in:
parent
65dfcae6d6
commit
159465324f
8 changed files with 162 additions and 149 deletions
|
@ -55,8 +55,7 @@ public abstract sealed class MemorySessionImpl
|
|||
implements Scope
|
||||
permits ConfinedSession, GlobalSession, SharedSession {
|
||||
static final int OPEN = 0;
|
||||
static final int CLOSING = -1;
|
||||
static final int CLOSED = -2;
|
||||
static final int CLOSED = -1;
|
||||
|
||||
static final VarHandle STATE;
|
||||
static final int MAX_FORKS = Integer.MAX_VALUE;
|
||||
|
|
|
@ -77,17 +77,13 @@ sealed class SharedSession extends MemorySessionImpl permits ImplicitSession {
|
|||
}
|
||||
|
||||
void justClose() {
|
||||
int prevState = (int) STATE.compareAndExchange(this, OPEN, CLOSING);
|
||||
int prevState = (int) STATE.compareAndExchange(this, OPEN, CLOSED);
|
||||
if (prevState < 0) {
|
||||
throw alreadyClosed();
|
||||
} else if (prevState != OPEN) {
|
||||
throw alreadyAcquired(prevState);
|
||||
}
|
||||
boolean success = SCOPED_MEMORY_ACCESS.closeScope(this);
|
||||
STATE.setVolatile(this, success ? CLOSED : OPEN);
|
||||
if (!success) {
|
||||
throw alreadyAcquired(1);
|
||||
}
|
||||
SCOPED_MEMORY_ACCESS.closeScope(this, ALREADY_CLOSED);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -83,11 +83,11 @@ public class ScopedMemoryAccess {
|
|||
registerNatives();
|
||||
}
|
||||
|
||||
public boolean closeScope(MemorySessionImpl session) {
|
||||
return closeScope0(session);
|
||||
public void closeScope(MemorySessionImpl session, ScopedAccessError error) {
|
||||
closeScope0(session, error);
|
||||
}
|
||||
|
||||
native boolean closeScope0(MemorySessionImpl session);
|
||||
native void closeScope0(MemorySessionImpl session, ScopedAccessError error);
|
||||
|
||||
private ScopedMemoryAccess() {}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue