001/*
002 *  Licensed to the Apache Software Foundation (ASF) under one
003 *  or more contributor license agreements.  See the NOTICE file
004 *  distributed with this work for additional information
005 *  regarding copyright ownership.  The ASF licenses this file
006 *  to you under the Apache License, Version 2.0 (the
007 *  "License"); you may not use this file except in compliance
008 *  with the License.  You may obtain a copy of the License at
009 *
010 *    http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *  Unless required by applicable law or agreed to in writing,
013 *  software distributed under the License is distributed on an
014 *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 *  KIND, either express or implied.  See the License for the
016 *  specific language governing permissions and limitations
017 *  under the License.
018 *
019 */
020package org.apache.mina.core.future;
021
022/**
023 * An {@link IoFuture} for asynchronous close requests.
024 *
025 * <h3>Example</h3>
026 * <pre>
027 * IoSession session = ...;
028 * CloseFuture future = session.close(true);
029 * 
030 * // Wait until the connection is closed
031 * future.awaitUninterruptibly();
032 * 
033 * // Now connection should be closed.
034 * assert future.isClosed();
035 * </pre>
036 *
037 * @author <a href="http://mina.apache.org">Apache MINA Project</a>
038 */
039public interface CloseFuture extends IoFuture {
040    /**
041     * @return <tt>true</tt> if the close request is finished and the session is closed.
042     */
043    boolean isClosed();
044
045    /**
046     * Marks this future as closed and notifies all threads waiting for this
047     * future. This method is invoked by MINA internally.  Please do not call
048     * this method directly.
049     */
050    void setClosed();
051
052    /**
053     * {@inheritDoc}
054     */
055    CloseFuture await() throws InterruptedException;
056
057    /**
058     * {@inheritDoc}
059     */
060    CloseFuture awaitUninterruptibly();
061
062    /**
063     * {@inheritDoc}
064     */
065    CloseFuture addListener(IoFutureListener<?> listener);
066
067    /**
068     * {@inheritDoc}
069     */
070    CloseFuture removeListener(IoFutureListener<?> listener);
071}