1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, 13 * software distributed under the License is distributed on an 14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 * KIND, either express or implied. See the License for the 16 * specific language governing permissions and limitations 17 * under the License. 18 * 19 */ 20 package org.apache.mina.common; 21 22 import java.util.concurrent.TimeUnit; 23 24 /** 25 * Represents the result of an ashynchronous I/O operation. 26 * 27 * @author The Apache MINA Project (dev@mina.apache.org) 28 * @version $Rev: 588579 $, $Date: 2007-10-26 03:21:01 -0600 (Fri, 26 Oct 2007) $ 29 */ 30 public interface IoFuture { 31 /** 32 * Returns the {@link IoSession} which is associated with this future. 33 */ 34 IoSession getSession(); 35 36 /** 37 * Wait for the asynchronous operation to end. 38 */ 39 IoFuture await() throws InterruptedException; 40 41 /** 42 * Wait for the asynchronous operation to end with the specified timeout. 43 * 44 * @return <tt>true</tt> if the operation is finished. 45 */ 46 boolean await(long timeout, TimeUnit unit) throws InterruptedException; 47 48 /** 49 * Wait for the asynchronous operation to end with the specified timeout. 50 * 51 * @return <tt>true</tt> if the operation is finished. 52 */ 53 boolean await(long timeoutMillis) throws InterruptedException; 54 55 /** 56 * Wait for the asynchronous operation to end uninterruptibly. 57 */ 58 IoFuture awaitUninterruptibly(); 59 60 /** 61 * Wait for the asynchronous operation to end with the specified timeout 62 * uninterruptibly. 63 * 64 * @return <tt>true</tt> if the operation is finished. 65 */ 66 boolean awaitUninterruptibly(long timeout, TimeUnit unit); 67 68 /** 69 * Wait for the asynchronous operation to end with the specified timeout 70 * uninterruptibly. 71 * 72 * @return <tt>true</tt> if the operation is finished. 73 */ 74 boolean awaitUninterruptibly(long timeoutMillis); 75 76 /** 77 * @deprecated Replaced with {@link #awaitUninterruptibly()}. 78 */ 79 @Deprecated 80 void join(); 81 82 /** 83 * @deprecated Replaced with {@link #awaitUninterruptibly(long)}. 84 */ 85 @Deprecated 86 boolean join(long timeoutMillis); 87 88 /** 89 * Returns if the asynchronous operation is finished. 90 */ 91 boolean isReady(); 92 93 /** 94 * Adds an event <tt>listener</tt> which is notified when 95 * the state of this future changes. 96 */ 97 IoFuture addListener(IoFutureListener<?> listener); 98 99 /** 100 * Removes an existing event <tt>listener</tt> which is notified when 101 * the state of this future changes. 102 */ 103 IoFuture removeListener(IoFutureListener<?> listener); 104 }