< prev index next > src/java.base/unix/classes/sun/nio/ch/SourceChannelImpl.java
Print this page
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;
+ 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
* 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()) {
+ if (reader == null && !isRegistered()) {
state = ST_CLOSED;
nd.close(fd);
return true;
} else {
return false;
private void implCloseBlockingMode() throws IOException {
synchronized (stateLock) {
assert state < ST_CLOSING;
state = ST_CLOSING;
if (!tryClose()) {
- nd.preClose(fd, thread, 0);
+ nd.preClose(fd, reader, null);
}
}
}
/**
// set hook for Thread.interrupt
begin();
}
synchronized (stateLock) {
ensureOpen();
- if (blocking)
- thread = NativeThread.current();
+ if (blocking) {
+ reader = NativeThread.current();
+ }
}
}
/**
* Marks the end of a read operation that may have blocked.
private void endRead(boolean blocking, boolean completed)
throws AsynchronousCloseException
{
if (blocking) {
synchronized (stateLock) {
- thread = 0;
+ reader = null;
if (state == ST_CLOSING) {
tryFinishClose();
}
}
// remove hook for Thread.interrupt
< prev index next >