< prev index next >

src/java.base/unix/classes/sun/nio/ch/SourceChannelImpl.java

Print this page
*** 62,11 ***
      private static final int ST_CLOSING = 1;
      private static final int ST_CLOSED = 2;
      private int state;
  
      // ID of native thread doing read, for signalling
!     private long thread;
  
      // True if the channel's socket has been forced into non-blocking mode
      // by a virtual thread. It cannot be reset. When the channel is in
      // blocking mode and the channel's socket is in non-blocking mode then
      // operations that don't complete immediately will poll the socket and
--- 62,11 ---
      private static final int ST_CLOSING = 1;
      private static final int ST_CLOSED = 2;
      private int state;
  
      // ID of native thread doing read, for signalling
!     private NativeThread reader;
  
      // True if the channel's socket has been forced into non-blocking mode
      // by a virtual thread. It cannot be reset. When the channel is in
      // blocking mode and the channel's socket is in non-blocking mode then
      // operations that don't complete immediately will poll the socket and

*** 118,11 ***
       * Closes the read end of the pipe if there are no read operation in
       * progress and the channel is not registered with a Selector.
       */
      private boolean tryClose() throws IOException {
          assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
!         if (thread == 0 && !isRegistered()) {
              state = ST_CLOSED;
              nd.close(fd);
              return true;
          } else {
              return false;
--- 118,11 ---
       * Closes the read end of the pipe if there are no read operation in
       * progress and the channel is not registered with a Selector.
       */
      private boolean tryClose() throws IOException {
          assert Thread.holdsLock(stateLock) && state == ST_CLOSING;
!         if (reader == null && !isRegistered()) {
              state = ST_CLOSED;
              nd.close(fd);
              return true;
          } else {
              return false;

*** 150,11 ***
      private void implCloseBlockingMode() throws IOException {
          synchronized (stateLock) {
              assert state < ST_CLOSING;
              state = ST_CLOSING;
              if (!tryClose()) {
!                 nd.preClose(fd, thread, 0);
              }
          }
      }
  
      /**
--- 150,11 ---
      private void implCloseBlockingMode() throws IOException {
          synchronized (stateLock) {
              assert state < ST_CLOSING;
              state = ST_CLOSING;
              if (!tryClose()) {
!                 nd.preClose(fd, reader, null);
              }
          }
      }
  
      /**

*** 267,12 ***
              // set hook for Thread.interrupt
              begin();
          }
          synchronized (stateLock) {
              ensureOpen();
!             if (blocking)
!                 thread = NativeThread.current();
          }
      }
  
      /**
       * Marks the end of a read operation that may have blocked.
--- 267,13 ---
              // set hook for Thread.interrupt
              begin();
          }
          synchronized (stateLock) {
              ensureOpen();
!             if (blocking) {
!                 reader = NativeThread.current();
+             }
          }
      }
  
      /**
       * Marks the end of a read operation that may have blocked.

*** 283,11 ***
      private void endRead(boolean blocking, boolean completed)
          throws AsynchronousCloseException
      {
          if (blocking) {
              synchronized (stateLock) {
!                 thread = 0;
                  if (state == ST_CLOSING) {
                      tryFinishClose();
                  }
              }
              // remove hook for Thread.interrupt
--- 284,11 ---
      private void endRead(boolean blocking, boolean completed)
          throws AsynchronousCloseException
      {
          if (blocking) {
              synchronized (stateLock) {
!                 reader = null;
                  if (state == ST_CLOSING) {
                      tryFinishClose();
                  }
              }
              // remove hook for Thread.interrupt
< prev index next >