public abstract class AbstractInterruptibleChannel extends Object implements Channel, InterruptibleChannel
AbstractInterruptibleChannelis the root class for interruptible channels.
The basic usage pattern for an interruptible channel is to invoke
begin() before any I/O operation that potentially blocks
end(boolean) after completing the operation. The
argument to the
end method should indicate if the I/O operation has
actually completed so that any change may be visible to the invoker.
|Modifier||Constructor and Description|
|Modifier and Type||Method and Description|
Indicates the beginning of a code section that includes an I/O operation that is potentially blocking.
Closes an open channel.
Indicates the end of a code section that has been started with
Implements the channel closing behavior.
Returns true if this channel is open.
public final boolean isOpen()
public final void close() throws IOException
If an attempt is made to perform an operation on a closed channel then a
ClosedChannelException is thrown.
If multiple threads attempt to simultaneously close a channel, then only one thread will run the closure code and the others will be blocked until the first one completes.
protected final void begin()
protected final void end(boolean success) throws AsynchronousCloseException
begin()and that includes a potentially blocking I/O operation.
trueif the blocking operation has succeeded and has had a noticeable effect;
AsynchronousCloseException- if this channel is closed by another thread while this method is executing.
ClosedByInterruptException- if another thread interrupts the calling thread while this method is executing.
protected abstract void implCloseChannel() throws IOException
Closes the channel with a guarantee that the channel is not currently
closed through another invocation of
close() and that the method
Any outstanding threads blocked on I/O operations on this channel must be
released with either a normal return code, or by throwing an
IOException- if a problem occurs while closing the channel.