< prev index next >

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

Print this page




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.nio.ch;
  27 
  28 import java.lang.reflect.*;
  29 import java.io.FileDescriptor;
  30 import java.nio.ByteBuffer;
  31 import java.nio.MappedByteBuffer;
  32 import java.security.AccessController;
  33 import java.security.PrivilegedAction;
  34 import java.util.*;
  35 import jdk.internal.misc.Unsafe;
  36 import jdk.internal.ref.Cleaner;
  37 import sun.security.action.GetPropertyAction;
  38 
  39 
  40 public class Util {
  41 
  42     // -- Caches --
  43 
  44     // The number of temp buffers in our pool
  45     private static final int TEMP_BUF_POOL_SIZE = IOUtil.IOV_MAX;
  46 
  47     // The max size allowed for a cached temp buffer, in bytes
  48     private static final long MAX_CACHED_BUFFER_SIZE = getMaxCachedBufferSize();
  49 
  50     // Per-thread cache of temporary direct buffers
  51     private static ThreadLocal<BufferCache> bufferCache =
  52         new ThreadLocal<BufferCache>()
  53     {
  54         @Override
  55         protected BufferCache initialValue() {
  56             return new BufferCache();




  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.nio.ch;
  27 
  28 import java.lang.reflect.*;
  29 import java.io.FileDescriptor;
  30 import java.nio.ByteBuffer;
  31 import java.nio.MappedByteBuffer;
  32 import java.security.AccessController;
  33 import java.security.PrivilegedAction;
  34 import java.util.*;
  35 import jdk.internal.misc.Unsafe;

  36 import sun.security.action.GetPropertyAction;
  37 
  38 
  39 public class Util {
  40 
  41     // -- Caches --
  42 
  43     // The number of temp buffers in our pool
  44     private static final int TEMP_BUF_POOL_SIZE = IOUtil.IOV_MAX;
  45 
  46     // The max size allowed for a cached temp buffer, in bytes
  47     private static final long MAX_CACHED_BUFFER_SIZE = getMaxCachedBufferSize();
  48 
  49     // Per-thread cache of temporary direct buffers
  50     private static ThreadLocal<BufferCache> bufferCache =
  51         new ThreadLocal<BufferCache>()
  52     {
  53         @Override
  54         protected BufferCache initialValue() {
  55             return new BufferCache();


< prev index next >