< prev index next >

src/java.base/share/classes/sun/nio/ch/Util.java

Print this page

        

*** 35,49 **** --- 35,52 ---- import java.security.PrivilegedAction; import java.util.Collection; import java.util.Iterator; import java.util.Set; + import jdk.internal.access.JavaLangAccess; + import jdk.internal.access.SharedSecrets; import jdk.internal.misc.TerminatingThreadLocal; import jdk.internal.misc.Unsafe; import sun.security.action.GetPropertyAction; public class Util { + private static JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); // -- Caches -- // The number of temp buffers in our pool private static final int TEMP_BUF_POOL_SIZE = IOUtil.IOV_MAX;
*** 225,235 **** // below) given that we won't put the new buffer in the cache. if (isBufferTooLarge(size)) { return ByteBuffer.allocateDirect(size); } ! BufferCache cache = bufferCache.get(); ByteBuffer buf = cache.get(size); if (buf != null) { return buf; } else { // No suitable buffer in the cache so we need to allocate a new --- 228,238 ---- // below) given that we won't put the new buffer in the cache. if (isBufferTooLarge(size)) { return ByteBuffer.allocateDirect(size); } ! BufferCache cache = JLA.getCarrierThreadLocal(bufferCache); ByteBuffer buf = cache.get(size); if (buf != null) { return buf; } else { // No suitable buffer in the cache so we need to allocate a new
*** 252,262 **** if (isBufferTooLarge(size)) { return ByteBuffer.allocateDirect(size + alignment - 1) .alignedSlice(alignment); } ! BufferCache cache = bufferCache.get(); ByteBuffer buf = cache.get(size); if (buf != null) { if (buf.alignmentOffset(0, alignment) == 0) { return buf; } --- 255,265 ---- if (isBufferTooLarge(size)) { return ByteBuffer.allocateDirect(size + alignment - 1) .alignedSlice(alignment); } ! BufferCache cache = JLA.getCarrierThreadLocal(bufferCache); ByteBuffer buf = cache.get(size); if (buf != null) { if (buf.alignmentOffset(0, alignment) == 0) { return buf; }
*** 289,299 **** free(buf); return; } assert buf != null; ! BufferCache cache = bufferCache.get(); if (!cache.offerFirst(buf)) { // cache is full free(buf); } } --- 292,302 ---- free(buf); return; } assert buf != null; ! BufferCache cache = JLA.getCarrierThreadLocal(bufferCache); if (!cache.offerFirst(buf)) { // cache is full free(buf); } }
*** 311,321 **** free(buf); return; } assert buf != null; ! BufferCache cache = bufferCache.get(); if (!cache.offerLast(buf)) { // cache is full free(buf); } } --- 314,324 ---- free(buf); return; } assert buf != null; ! BufferCache cache = JLA.getCarrierThreadLocal(bufferCache); if (!cache.offerLast(buf)) { // cache is full free(buf); } }
< prev index next >