mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8287809: Revisit implementation of memory session
Reviewed-by: jvernee
This commit is contained in:
parent
cb6e9cb728
commit
fed3af8ae0
21 changed files with 328 additions and 383 deletions
|
@ -1199,9 +1199,6 @@ public class FileChannelImpl
|
|||
}
|
||||
}
|
||||
|
||||
private static final int MAP_MEM_SEG_DEFAULT_MODES = 0;
|
||||
private static final int MAP_MEM_SEG_READ_ONLY = 1;
|
||||
|
||||
@Override
|
||||
public MemorySegment map(MapMode mode, long offset, long size,
|
||||
MemorySession session)
|
||||
|
@ -1210,7 +1207,7 @@ public class FileChannelImpl
|
|||
Objects.requireNonNull(mode,"Mode is null");
|
||||
Objects.requireNonNull(session, "Session is null");
|
||||
MemorySessionImpl sessionImpl = MemorySessionImpl.toSessionImpl(session);
|
||||
sessionImpl.checkValidStateSlow();
|
||||
sessionImpl.checkValidState();
|
||||
if (offset < 0)
|
||||
throw new IllegalArgumentException("Requested bytes offset must be >= 0.");
|
||||
if (size < 0)
|
||||
|
@ -1219,14 +1216,14 @@ public class FileChannelImpl
|
|||
boolean isSync = isSync(mode);
|
||||
int prot = toProt(mode);
|
||||
Unmapper unmapper = mapInternal(mode, offset, size, prot, isSync);
|
||||
int modes = MAP_MEM_SEG_DEFAULT_MODES;
|
||||
boolean readOnly = false;
|
||||
if (mode == MapMode.READ_ONLY) {
|
||||
modes |= MAP_MEM_SEG_READ_ONLY;
|
||||
readOnly = true;
|
||||
}
|
||||
if (unmapper != null) {
|
||||
AbstractMemorySegmentImpl segment =
|
||||
new MappedMemorySegmentImpl(unmapper.address(), unmapper, size,
|
||||
modes, session);
|
||||
readOnly, session);
|
||||
MemorySessionImpl.ResourceList.ResourceCleanup resource =
|
||||
new MemorySessionImpl.ResourceList.ResourceCleanup() {
|
||||
@Override
|
||||
|
@ -1237,7 +1234,7 @@ public class FileChannelImpl
|
|||
sessionImpl.addOrCleanupIfFail(resource);
|
||||
return segment;
|
||||
} else {
|
||||
return new MappedMemorySegmentImpl.EmptyMappedMemorySegmentImpl(modes, session);
|
||||
return new MappedMemorySegmentImpl.EmptyMappedMemorySegmentImpl(readOnly, sessionImpl);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue