893N/A/*
2362N/A * Copyright (c) 2007, 2009, Oracle and/or its affiliates. All rights reserved.
893N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
893N/A *
893N/A * This code is free software; you can redistribute it and/or modify it
893N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
893N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
893N/A *
893N/A * This code is distributed in the hope that it will be useful, but WITHOUT
893N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
893N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
893N/A * version 2 for more details (a copy is included in the LICENSE file that
893N/A * accompanied this code).
893N/A *
893N/A * You should have received a copy of the GNU General Public License version
893N/A * 2 along with this work; if not, write to the Free Software Foundation,
893N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
893N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
893N/A */
893N/A
893N/Apackage java.nio.channels;
893N/A
893N/A/**
893N/A * A handler for consuming the result of an asynchronous I/O operation.
893N/A *
893N/A * <p> The asynchronous channels defined in this package allow a completion
893N/A * handler to be specified to consume the result of an asynchronous operation.
893N/A * The {@link #completed completed} method is invoked when the I/O operation
893N/A * completes successfully. The {@link #failed failed} method is invoked if the
1580N/A * I/O operations fails. The implementations of these methods should complete
1580N/A * in a timely manner so as to avoid keeping the invoking thread from dispatching
1580N/A * to other completion handlers.
893N/A *
893N/A * @param <V> The result type of the I/O operation
893N/A * @param <A> The type of the object attached to the I/O operation
893N/A *
893N/A * @since 1.7
893N/A */
893N/A
893N/Apublic interface CompletionHandler<V,A> {
893N/A
893N/A /**
893N/A * Invoked when an operation has completed.
893N/A *
893N/A * @param result
893N/A * The result of the I/O operation.
893N/A * @param attachment
893N/A * The object attached to the I/O operation when it was initiated.
893N/A */
893N/A void completed(V result, A attachment);
893N/A
893N/A /**
893N/A * Invoked when an operation fails.
893N/A *
893N/A * @param exc
893N/A * The exception to indicate why the I/O operation failed
893N/A * @param attachment
893N/A * The object attached to the I/O operation when it was initiated.
893N/A */
893N/A void failed(Throwable exc, A attachment);
893N/A}