Package org.apache.mina.core.future
Class DefaultCloseFuture
- java.lang.Object
-
- org.apache.mina.core.future.DefaultIoFuture
-
- org.apache.mina.core.future.DefaultCloseFuture
-
- All Implemented Interfaces:
CloseFuture
,IoFuture
public class DefaultCloseFuture extends DefaultIoFuture implements CloseFuture
A default implementation ofCloseFuture
.- Author:
- Apache MINA Project
-
-
Constructor Summary
Constructors Constructor Description DefaultCloseFuture(IoSession session)
Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CloseFuture
addListener(IoFutureListener<?> listener)
Adds an event listener which is notified when this future is completed.CloseFuture
await()
Wait for the asynchronous operation to complete.CloseFuture
awaitUninterruptibly()
Wait for the asynchronous operation to complete uninterruptibly.boolean
isClosed()
CloseFuture
removeListener(IoFutureListener<?> listener)
Removes an existing event listener so it won't be notified when the future is completed.void
setClosed()
Marks this future as closed and notifies all threads waiting for this future.-
Methods inherited from class org.apache.mina.core.future.DefaultIoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, getSession, getValue, isDone, join, join, setValue
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.mina.core.future.IoFuture
await, await, awaitUninterruptibly, awaitUninterruptibly, getSession, isDone, join, join
-
-
-
-
Constructor Detail
-
DefaultCloseFuture
public DefaultCloseFuture(IoSession session)
Creates a new instance.- Parameters:
session
- The associated session
-
-
Method Detail
-
isClosed
public boolean isClosed()
- Specified by:
isClosed
in interfaceCloseFuture
- Returns:
- true if the close request is finished and the session is closed.
-
setClosed
public void setClosed()
Marks this future as closed and notifies all threads waiting for this future. This method is invoked by MINA internally. Please do not call this method directly.- Specified by:
setClosed
in interfaceCloseFuture
-
await
public CloseFuture await() throws InterruptedException
Wait for the asynchronous operation to complete. The attached listeners will be notified when the operation is completed.- Specified by:
await
in interfaceCloseFuture
- Specified by:
await
in interfaceIoFuture
- Overrides:
await
in classDefaultIoFuture
- Returns:
- The instance of IoFuture that we are waiting for
- Throws:
InterruptedException
- If the thread is interrupted while waiting
-
awaitUninterruptibly
public CloseFuture awaitUninterruptibly()
Wait for the asynchronous operation to complete uninterruptibly. The attached listeners will be notified when the operation is completed.- Specified by:
awaitUninterruptibly
in interfaceCloseFuture
- Specified by:
awaitUninterruptibly
in interfaceIoFuture
- Overrides:
awaitUninterruptibly
in classDefaultIoFuture
- Returns:
- the current IoFuture
-
addListener
public CloseFuture addListener(IoFutureListener<?> listener)
Adds an event listener which is notified when this future is completed. If the listener is added after the completion, the listener is directly notified.- Specified by:
addListener
in interfaceCloseFuture
- Specified by:
addListener
in interfaceIoFuture
- Overrides:
addListener
in classDefaultIoFuture
- Parameters:
listener
- The listener to add- Returns:
- the current IoFuture
-
removeListener
public CloseFuture removeListener(IoFutureListener<?> listener)
Removes an existing event listener so it won't be notified when the future is completed.- Specified by:
removeListener
in interfaceCloseFuture
- Specified by:
removeListener
in interfaceIoFuture
- Overrides:
removeListener
in classDefaultIoFuture
- Parameters:
listener
- The listener to remove- Returns:
- the current IoFuture
-
-