Path: blob/master/src/java.base/share/classes/jdk/internal/access/JavaNioAccess.java
41159 views
/*1* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package jdk.internal.access;2627import jdk.internal.access.foreign.MemorySegmentProxy;28import jdk.internal.access.foreign.UnmapperProxy;29import jdk.internal.misc.ScopedMemoryAccess.Scope;30import jdk.internal.misc.VM.BufferPool;3132import java.io.FileDescriptor;33import java.nio.Buffer;34import java.nio.ByteBuffer;3536public interface JavaNioAccess {3738/**39* Used by {@code jdk.internal.misc.VM}.40*/41BufferPool getDirectBufferPool();4243/**44* Constructs a direct ByteBuffer referring to the block of memory starting45* at the given memory address and extending {@code cap} bytes.46* The {@code ob} parameter is an arbitrary object that is attached47* to the resulting buffer.48* Used by {@code jdk.internal.foreignMemorySegmentImpl}.49*/50ByteBuffer newDirectByteBuffer(long addr, int cap, Object obj, MemorySegmentProxy segment);5152/**53* Constructs a mapped ByteBuffer referring to the block of memory starting54* at the given memory address and extending {@code cap} bytes.55* The {@code ob} parameter is an arbitrary object that is attached56* to the resulting buffer. The {@code sync} and {@code fd} parameters of the mapped57* buffer are derived from the {@code UnmapperProxy}.58* Used by {@code jdk.internal.foreignMemorySegmentImpl}.59*/60ByteBuffer newMappedByteBuffer(UnmapperProxy unmapperProxy, long addr, int cap, Object obj, MemorySegmentProxy segment);6162/**63* Constructs an heap ByteBuffer with given backing array, offset, capacity and segment.64* Used by {@code jdk.internal.foreignMemorySegmentImpl}.65*/66ByteBuffer newHeapByteBuffer(byte[] hb, int offset, int capacity, MemorySegmentProxy segment);6768/**69* Used by {@code jdk.internal.foreign.Utils}.70*/71Object getBufferBase(ByteBuffer bb);7273/**74* Used by {@code jdk.internal.foreign.Utils}.75*/76long getBufferAddress(ByteBuffer bb);7778/**79* Used by {@code jdk.internal.foreign.Utils}.80*/81UnmapperProxy unmapper(ByteBuffer bb);8283/**84* Used by {@code jdk.internal.foreign.AbstractMemorySegmentImpl} and byte buffer var handle views.85*/86MemorySegmentProxy bufferSegment(Buffer buffer);8788/**89* Used by I/O operations to make a buffer's resource scope non-closeable90* (for the duration of the I/O operation) by acquiring a new resource91* scope handle. Null is returned if the buffer has no scope, or92* acquiring is not required to guarantee safety.93*/94Scope.Handle acquireScope(Buffer buffer, boolean async);9596/**97* Used by {@code jdk.internal.foreign.MappedMemorySegmentImpl} and byte buffer var handle views.98*/99void force(FileDescriptor fd, long address, boolean isSync, long offset, long size);100101/**102* Used by {@code jdk.internal.foreign.MappedMemorySegmentImpl} and byte buffer var handle views.103*/104void load(long address, boolean isSync, long size);105106/**107* Used by {@code jdk.internal.foreign.MappedMemorySegmentImpl}.108*/109void unload(long address, boolean isSync, long size);110111/**112* Used by {@code jdk.internal.foreign.MappedMemorySegmentImpl} and byte buffer var handle views.113*/114boolean isLoaded(long address, boolean isSync, long size);115116/**117* Used by {@code jdk.internal.foreign.NativeMemorySegmentImpl}.118*/119void reserveMemory(long size, long cap);120121/**122* Used by {@code jdk.internal.foreign.NativeMemorySegmentImpl}.123*/124void unreserveMemory(long size, long cap);125126/**127* Used by {@code jdk.internal.foreign.NativeMemorySegmentImpl}.128*/129int pageSize();130}131132133