|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.sgs.impl.nio.AttachedFuture<R,A>
R - the result typeA - the attachment typepublic class AttachedFuture<R,A>
An implementation of IoFuture that adds an object attachment
to an arbitrary Future.
| Constructor Summary | |
|---|---|
protected |
AttachedFuture(Future<R> future,
A attachment)
Creates an AttachedFuture from the given future
and attachment. |
| Method Summary | ||
|---|---|---|
A |
attach(A ob)
Attaches the given object to this channel future. |
|
A |
attachment()
Retrieves the current attachment. |
|
boolean |
cancel(boolean mayInterruptIfRunning)
Attempts to cancel execution of the operation. |
|
R |
get()
|
|
R |
get(long timeout,
TimeUnit unit)
|
|
R |
getNow()
Retrieves the result of a completed operation. |
|
boolean |
isCancelled()
|
|
boolean |
isDone()
|
|
static
|
wrap(Future<R> future,
A attachment)
Creates an AttachedFuture from the given future
and attachment. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
protected AttachedFuture(Future<R> future,
A attachment)
AttachedFuture from the given future
and attachment.
future - the Future to wrapattachment - the initial attachment, or null| Method Detail |
|---|
public static <R,A> AttachedFuture<R,A> wrap(Future<R> future,
A attachment)
AttachedFuture from the given future
and attachment. Provided as a static factory method so that
the template types can be inferred by the compiler.
R - the result typeA - the attachment typefuture - the Future to wrapattachment - the initial attachment, or null
AttachedFuturepublic A attach(A ob)
An attached object may later be retrieved via the
attachment method. Only one object may be
attached at a time; invoking this method causes any previous
attachment to be discarded. The current attachment may be discarded
by attaching null.
attach in interface IoFuture<R,A>ob - the object to be attached; may be null
nullpublic A attachment()
attachment in interface IoFuture<R,A>null if there is no attachmentpublic boolean cancel(boolean mayInterruptIfRunning)
If the value of mayInterruptIfRunning is true then
this method may cancel the operation forcefully by
closing the channel. Whether it
does close the channel is implementation and operation specific. If
the channel is closed then all outstanding operations on the channel
complete by throwing ExecutionException with cause
AsynchronousCloseException. Where an implementation does not
close the channel then the channel may be put into an error state
that prevents further operations on the channel. For example, if a
read operation is cancelled and the implementation cannot guarantee
that no bytes have been read from the channel then it puts the
channel into an implementation specific error state. Any subsequent
attempt to initiate a read operation on the channel throws an
unspecified runtime exception.
This method otherwise behaves exactly as specified by the
Future interface.
cancel in interface IoFuture<R,A>cancel in interface Future<R>mayInterruptIfRunning - true if the operation can be
cancelled forcefully (possibily by closing the channel),
false otherwise
false if the operation could not be cancelled,
true if the operation has been cancelled
public R getNow()
throws ExecutionException
The method is intended to be invoked from a CompletionHandler
to retrieve the result of a completed operation. It is equivalent to
invoking the get method to retrieve the result
except that the method does not wait for the result.
getNow in interface IoFuture<R,A>ExecutionException - if the operation threw an exception
public R get()
throws InterruptedException,
ExecutionException
get in interface Future<R>InterruptedException
ExecutionException
public R get(long timeout,
TimeUnit unit)
throws InterruptedException,
ExecutionException,
TimeoutException
get in interface Future<R>InterruptedException
ExecutionException
TimeoutExceptionpublic boolean isCancelled()
isCancelled in interface Future<R>public boolean isDone()
isDone in interface Future<R>
|
RedDwarf, Version 0.10.1 2010-03-14 10:56:12 |
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||