1adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project/* Licensed to the Apache Software Foundation (ASF) under one or more 2adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * contributor license agreements. See the NOTICE file distributed with 3adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * this work for additional information regarding copyright ownership. 4adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * The ASF licenses this file to You under the Apache License, Version 2.0 5adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * (the "License"); you may not use this file except in compliance with 6adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * the License. You may obtain a copy of the License at 7f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * 8adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * http://www.apache.org/licenses/LICENSE-2.0 9f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * 10adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Unless required by applicable law or agreed to in writing, software 11adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS, 12adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * See the License for the specific language governing permissions and 14adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * limitations under the License. 15adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */ 16adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 17adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectpackage java.nio.channels; 18adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 19adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectimport java.io.IOException; 20adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 21adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project/** 22adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Channels that implement this interface can be asynchronously closed and 23adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * interrupted. 24adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * <p> 25adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * A channel that can be asynchronously closed permits that a thread blocked on 26adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * an I/O operation (the I/O thread) can be released by another thread calling 27adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * the channel's {@link #close()} method. The I/O thread will throw an 28adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * {@link AsynchronousCloseException} and the channel will be closed. 29adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * <p> 30adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * A channel that is interruptible permits a thread blocked on an I/O operation 31adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * (the I/O thread) to be interrupted by another thread (by invoking 32adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * {@link Thread#interrupt()} on the I/O thread). When the I/O thread is 33adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * interrupted it will throw a {@link ClosedByInterruptException}, it will have 34adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * its interrupted status set and the channel will be closed. If the I/O thread 35adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * attempts to make an I/O call with the interrupt status set the call will 36adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * immediately fail with a {@link ClosedByInterruptException}. 37adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */ 38adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Projectpublic interface InterruptibleChannel extends Channel { 39adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project 40adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project /** 41adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Closes the channel. 42adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * <p> 43adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * Any threads that are blocked on I/O operations on this channel will be 44adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * interrupted with an {@link AsynchronousCloseException}. Otherwise, this 45adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * method behaves the same as defined in the {@code Channel} interface. 46f33eae7e84eb6d3b0f4e86b59605bb3de73009f3Elliott Hughes * 47adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * @throws IOException 48adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project * if an I/O error occurs while closing the channel. 49adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project */ 50adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project public void close() throws IOException; 51adc854b798c1cfe3bfd4c27d68d5cee38ca617daThe Android Open Source Project} 52