< prev index next >

src/java.base/unix/classes/sun/nio/ch/SinkChannelImpl.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 write, 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 write, for signalling
!     private NativeThread writer;
  
      // 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 write end of the pipe if there are no write 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 write end of the pipe if there are no write 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 (writer == 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, null, writer);
              }
          }
      }
  
      /**

*** 268,11 ***
              begin();
          }
          synchronized (stateLock) {
              ensureOpen();
              if (blocking)
!                 thread = NativeThread.current();
          }
      }
  
      /**
       * Marks the end of a write operation that may have blocked.
--- 268,11 ---
              begin();
          }
          synchronized (stateLock) {
              ensureOpen();
              if (blocking)
!                 writer = NativeThread.current();
          }
      }
  
      /**
       * Marks the end of a write operation that may have blocked.

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