@@ -73,40 +73,18 @@ static WritableMemory writableWrap(
7373 /**
7474 * Maps the entire given file into native-ordered WritableMemory for write operations with Arena.ofConfined().
7575 * Calling this method is equivalent to calling
76- * {@link #writableMap(File, long, long, ByteOrder) writableMap(file, 0, file.length(), ByteOrder.nativeOrder())}.
76+ * {@link #writableMap(File, long, long, ByteOrder, Arena ) writableMap(file, 0, file.length(), ByteOrder.nativeOrder(), arena )}.
7777 * @param file the given file to map. It must be non-null and writable.
78+ * @param arena the given arena to manage the new off-heap WritableMemory. It must be non-null.
79+ * Warning: This class is not thread-safe. Specifying an Arena that allows multiple threads is not recommended.
7880 * @return a file-mapped WritableMemory
7981 * @throws IllegalArgumentException if file is not readable or not writable.
8082 * @throws IOException if the specified path does not point to an existing file, or if some other I/O error occurs.
8183 * @throws SecurityException If a security manager is installed and it denies an unspecified permission
8284 * required by the implementation.
8385 */
84- static WritableMemory writableMap (File file ) throws IOException {
85- return WritableMemoryImpl .wrapMap (file , 0 , file .length (), ByteOrder .nativeOrder (), false , Arena .ofConfined ());
86- }
87-
88- /**
89- * Maps the specified portion of the given file into Memory for write operations with Arena.ofConfined().
90- * Calling this method is equivalent to calling
91- * {@link #writableMap(File, long, long, ByteOrder, Arena)
92- * writableMap(file, fileOffsetBytes, capacityBytes, ByteOrder, Arena.ofConfined())}.
93- * @param file the given file to map. It must be non-null with a non-negative length and writable.
94- * @param fileOffsetBytes the position in the given file in bytes. It must not be negative.
95- * @param capacityBytes the size of the mapped Memory. It must be ≥ 0.
96- * @param byteOrder the byte order to be used. It must be non-null.
97- * @return mapped WritableMemory.
98- * @throws IllegalArgumentException -- if file is not readable or writable.
99- * @throws IllegalArgumentException -- if file is not writable.
100- * @throws IOException - if the specified path does not point to an existing file, or if some other I/O error occurs.
101- * @throws SecurityException - If a security manager is installed and it denies an unspecified permission
102- * required by the implementation.
103- */
104- static WritableMemory writableMap (
105- File file ,
106- long fileOffsetBytes ,
107- long capacityBytes ,
108- ByteOrder byteOrder ) throws IOException {
109- return WritableMemoryImpl .wrapMap (file , fileOffsetBytes , capacityBytes , byteOrder , false , Arena .ofConfined ());
86+ static WritableMemory writableMap (File file , Arena arena ) throws IOException {
87+ return WritableMemoryImpl .wrapMap (file , 0 , file .length (), ByteOrder .nativeOrder (), false , arena );
11088 }
11189
11290 /**
@@ -115,8 +93,9 @@ static WritableMemory writableMap(
11593 * @param fileOffsetBytes the position in the given file in bytes. It must not be negative.
11694 * @param capacityBytes the size of the mapped Memory.
11795 * @param byteOrder the given <i>ByteOrder</i>. It must be non-null.
118- * @param arena the given arena to map . It must be non-null.
96+ * @param arena the given arena to manage the new off-heap WritableMemory . It must be non-null.
11997 * Warning: This class is not thread-safe. Specifying an Arena that allows multiple threads is not recommended.
98+ *
12099 * @return a file-mapped WritableMemory.
121100 * @throws IllegalArgumentException if file is not readable or not writable.
122101 * @throws IOException if the specified path does not point to an existing file, or if some other I/O error occurs.
@@ -139,34 +118,15 @@ static WritableMemory writableMap(
139118 * The allocated memory will be 8-byte aligned.
140119 * Native byte order is assumed.
141120 * A new DefaultMemoryRequestServer() is created.
142- * A new Arena.ofConfined() is created.
143121 *
144122 * <p><b>NOTE:</b> Native/Direct memory acquired may have garbage in it.
145123 * It is the responsibility of the using application to clear this memory, if required,
146124 * and to call <i>close()</i> when done.</p>
147125 * @param capacityBytes the size of the desired memory in bytes.
148- * Warning: This class is not thread-safe.
149- *
150- * @return WritableMemory for this off-heap, native resource.
151- */
152- static WritableMemory allocateDirect (long capacityBytes ) {
153- return allocateDirect (capacityBytes , 8 , ByteOrder .nativeOrder (), new DefaultMemoryRequestServer (), Arena .ofConfined ());
154- }
155-
156- /**
157- * Allocates and provides access to capacityBytes directly in native (off-heap) memory.
158- * The allocated memory will be 8-byte aligned.
159- * Native byte order is assumed.
160- * A new DefaultMemoryRequestServer() is created.
161- *
162- * <p><b>NOTE:</b> Native/Direct memory acquired may have garbage in it.
163- * It is the responsibility of the using application to clear this memory, if required,
164- * and to call <i>close()</i> when done.</p>
165- * @param capacityBytes the size of the desired memory in bytes.
166- * @param arena the given arena to use. It must be non-null.
126+ * @param arena the given arena to manage the new off-heap WritableMemory. It must be non-null.
167127 * Warning: This class is not thread-safe. Specifying an Arena that allows multiple threads is not recommended.
168128 *
169- * @return WritableMemory for this off-heap, native resource.
129+ * @return a WritableMemory for this off-heap resource.
170130 */
171131 static WritableMemory allocateDirect (long capacityBytes , Arena arena ) {
172132 return allocateDirect (capacityBytes , 8 , ByteOrder .nativeOrder (), new DefaultMemoryRequestServer (), arena );
@@ -184,7 +144,7 @@ static WritableMemory allocateDirect(long capacityBytes, Arena arena) {
184144 * @param byteOrder the given <i>ByteOrder</i>. It must be non-null.
185145 * @param memReqSvr A user-specified MemoryRequestServer, which may be null.
186146 * This is a callback mechanism for a user client of direct memory to request more memory.
187- * @param arena the given arena to use . It must be non-null.
147+ * @param arena the given arena to manage the new off-heap WritableMemory . It must be non-null.
188148 * Warning: This class is not thread-safe. Specifying an Arena that allows multiple threads is not recommended.
189149 *
190150 * @return a WritableMemory for this off-heap resource.
0 commit comments