Build 1.0_r1(from source)

java.nio.channels.spi
Class AbstractInterruptibleChannel

java.lang.Object
  extended by java.nio.channels.spi.AbstractInterruptibleChannel
All Implemented Interfaces:
Closeable, Channel, InterruptibleChannel
Direct Known Subclasses:
FileChannel, SelectableChannel

public abstract class AbstractInterruptibleChannel
extends Object
implements Channel, InterruptibleChannel

This class roots the implementation of interruptible channels.

The basic usage pattern for an interruptible channel is to invoke begin() before any IO operations, then end(boolean) after completing the operation. The argument to the end method shows whether there has been any change to the java environment that is visible to the API user.


Field Summary
(package private)  boolean interrupted
           
(package private) static Method setInterruptAction
           
 
Constructor Summary
protected AbstractInterruptibleChannel()
          Default constructor.
 
Method Summary
protected  void begin()
          Start an IO operation that is potentially blocking.
 void close()
          Closes the channel.
protected  void end(boolean success)
          End an IO operation that was previously started with begin().
protected abstract  void implCloseChannel()
          Implements the close channel behavior.
 boolean isOpen()
          Returns whether the channel is open.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

setInterruptAction

static Method setInterruptAction

interrupted

volatile boolean interrupted
Constructor Detail

AbstractInterruptibleChannel

protected AbstractInterruptibleChannel()
Default constructor.

Method Detail

isOpen

public final boolean isOpen()
Returns whether the channel is open.

Specified by:
isOpen in interface Channel
Returns:
true if the channel is open, and false if it is closed.
See Also:
Channel.isOpen()

close

public final void close()
                 throws IOException
Closes the channel.

If the channel is already closed then this method has no effect, otherwise it closes the receiver via the implCloseChannel method.

Specified by:
close in interface Closeable
Specified by:
close in interface Channel
Specified by:
close in interface InterruptibleChannel
Throws:
IOException - if a problem occurs closing the channel.
See Also:
Channel.close()

begin

protected final void begin()
Start an IO operation that is potentially blocking.

Once the operation is completed the application should invoke a corresponding end(boolean).


end

protected final void end(boolean success)
                  throws AsynchronousCloseException
End an IO operation that was previously started with begin().

Parameters:
success - pass true if the operation succeeded and had a side effect on the Java system, or false if not.
Throws:
AsynchronousCloseException - the channel was closed while the IO operation was in progress.
ClosedByInterruptException - the thread conducting the IO operation was interrupted.

implCloseChannel

protected abstract void implCloseChannel()
                                  throws IOException
Implements the close channel behavior.

Closes the channel with a guarantee that the channel is not currently closed via close() and that the method is thread-safe.

any outstanding threads blocked on IO operations on this channel must be released with either a normal return code, or an AsynchronousCloseException.

Throws:
IOException - if a problem occurs closing the channel.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature