src/java.base/windows/classes/sun/nio/ch/WindowsAsynchronousSocketChannelImpl.java

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


  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.nio.channels.*;
  29 import java.nio.ByteBuffer;
  30 import java.nio.BufferOverflowException;
  31 import java.net.*;
  32 import java.util.concurrent.*;
  33 import java.io.IOException;
  34 import java.security.AccessController;
  35 import java.security.PrivilegedActionException;
  36 import java.security.PrivilegedExceptionAction;
  37 import sun.misc.Unsafe;
  38 
  39 /**
  40  * Windows implementation of AsynchronousSocketChannel using overlapped I/O.
  41  */
  42 
  43 class WindowsAsynchronousSocketChannelImpl
  44     extends AsynchronousSocketChannelImpl implements Iocp.OverlappedChannel
  45 {
  46     private static final Unsafe unsafe = Unsafe.getUnsafe();
  47     private static int addressSize = unsafe.addressSize();
  48 
  49     private static int dependsArch(int value32, int value64) {
  50         return (addressSize == 4) ? value32 : value64;
  51     }
  52 
  53     /*
  54      * typedef struct _WSABUF {
  55      *     u_long      len;
  56      *     char FAR *  buf;
  57      * } WSABUF;




  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.nio.channels.*;
  29 import java.nio.ByteBuffer;
  30 import java.nio.BufferOverflowException;
  31 import java.net.*;
  32 import java.util.concurrent.*;
  33 import java.io.IOException;
  34 import java.security.AccessController;
  35 import java.security.PrivilegedActionException;
  36 import java.security.PrivilegedExceptionAction;
  37 import jdk.internal.misc.Unsafe;
  38 
  39 /**
  40  * Windows implementation of AsynchronousSocketChannel using overlapped I/O.
  41  */
  42 
  43 class WindowsAsynchronousSocketChannelImpl
  44     extends AsynchronousSocketChannelImpl implements Iocp.OverlappedChannel
  45 {
  46     private static final Unsafe unsafe = Unsafe.getUnsafe();
  47     private static int addressSize = unsafe.addressSize();
  48 
  49     private static int dependsArch(int value32, int value64) {
  50         return (addressSize == 4) ? value32 : value64;
  51     }
  52 
  53     /*
  54      * typedef struct _WSABUF {
  55      *     u_long      len;
  56      *     char FAR *  buf;
  57      * } WSABUF;