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

Print this page
rev 12972 : 8140606: Update library code to use internal Unsafe
Reviewed-by: duke


  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.ref.SoftReference;
  29 import java.lang.reflect.*;
  30 import java.io.IOException;
  31 import java.io.FileDescriptor;
  32 import java.nio.ByteBuffer;
  33 import java.nio.MappedByteBuffer;
  34 import java.nio.channels.*;
  35 import java.security.AccessController;
  36 import java.security.PrivilegedAction;
  37 import java.util.*;
  38 import sun.misc.Unsafe;
  39 import sun.misc.Cleaner;
  40 import sun.security.action.GetPropertyAction;
  41 
  42 
  43 public class Util {
  44 
  45     // -- Caches --
  46 
  47     // The number of temp buffers in our pool
  48     private static final int TEMP_BUF_POOL_SIZE = IOUtil.IOV_MAX;
  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();
  57         }
  58     };




  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.ref.SoftReference;
  29 import java.lang.reflect.*;
  30 import java.io.IOException;
  31 import java.io.FileDescriptor;
  32 import java.nio.ByteBuffer;
  33 import java.nio.MappedByteBuffer;
  34 import java.nio.channels.*;
  35 import java.security.AccessController;
  36 import java.security.PrivilegedAction;
  37 import java.util.*;
  38 import jdk.internal.misc.Unsafe;
  39 import sun.misc.Cleaner;
  40 import sun.security.action.GetPropertyAction;
  41 
  42 
  43 public class Util {
  44 
  45     // -- Caches --
  46 
  47     // The number of temp buffers in our pool
  48     private static final int TEMP_BUF_POOL_SIZE = IOUtil.IOV_MAX;
  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();
  57         }
  58     };