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: */
020: package org.apache.mina.common;
021:
022: import java.util.concurrent.TimeUnit;
023:
024: /**
025: * Represents the result of an ashynchronous I/O operation.
026: *
027: * @author The Apache MINA Project (dev@mina.apache.org)
028: * @version $Rev: 588579 $, $Date: 2007-10-26 03:21:01 -0600 (Fri, 26 Oct 2007) $
029: */
030: public interface IoFuture {
031: /**
032: * Returns the {@link IoSession} which is associated with this future.
033: */
034: IoSession getSession();
035:
036: /**
037: * Wait for the asynchronous operation to end.
038: */
039: IoFuture await() throws InterruptedException;
040:
041: /**
042: * Wait for the asynchronous operation to end with the specified timeout.
043: *
044: * @return <tt>true</tt> if the operation is finished.
045: */
046: boolean await(long timeout, TimeUnit unit)
047: throws InterruptedException;
048:
049: /**
050: * Wait for the asynchronous operation to end with the specified timeout.
051: *
052: * @return <tt>true</tt> if the operation is finished.
053: */
054: boolean await(long timeoutMillis) throws InterruptedException;
055:
056: /**
057: * Wait for the asynchronous operation to end uninterruptibly.
058: */
059: IoFuture awaitUninterruptibly();
060:
061: /**
062: * Wait for the asynchronous operation to end with the specified timeout
063: * uninterruptibly.
064: *
065: * @return <tt>true</tt> if the operation is finished.
066: */
067: boolean awaitUninterruptibly(long timeout, TimeUnit unit);
068:
069: /**
070: * Wait for the asynchronous operation to end with the specified timeout
071: * uninterruptibly.
072: *
073: * @return <tt>true</tt> if the operation is finished.
074: */
075: boolean awaitUninterruptibly(long timeoutMillis);
076:
077: /**
078: * @deprecated Replaced with {@link #awaitUninterruptibly()}.
079: */
080: @Deprecated
081: void join();
082:
083: /**
084: * @deprecated Replaced with {@link #awaitUninterruptibly(long)}.
085: */
086: @Deprecated
087: boolean join(long timeoutMillis);
088:
089: /**
090: * Returns if the asynchronous operation is finished.
091: */
092: boolean isReady();
093:
094: /**
095: * Adds an event <tt>listener</tt> which is notified when
096: * the state of this future changes.
097: */
098: IoFuture addListener(IoFutureListener<?> listener);
099:
100: /**
101: * Removes an existing event <tt>listener</tt> which is notified when
102: * the state of this future changes.
103: */
104: IoFuture removeListener(IoFutureListener<?> listener);
105: }
|