APIdia Launch Partner
Top Description Fields Constructors Methods
sun.nio.ch

pack-priv final Class PendingFuture<V, A>

extends Object
implements Future<V>
Class Inheritance
All Implemented Interfaces
java.util.concurrent.Future
Imports
java.nio.channels.*, java.util.concurrent.*, java.io.IOException

A Future for a pending I/O operation. A PendingFuture allows for the attachment of an additional arbitrary context object and a timer task.

Field Summary

Modifier and TypeField and Description
private final A
private final AsynchronousChannel
private volatile Object
private volatile Throwable
private final CompletionHandler<V, ? super A>
private volatile boolean
private CountDownLatch
private volatile V
private Future<?>

Constructor Summary

AccessConstructor and Description
pack-priv
PendingFuture(AsynchronousChannel channel, CompletionHandler<V, ? super A> handler, A attachment, Object context)

pack-priv
PendingFuture(AsynchronousChannel channel, CompletionHandler<V, ? super A> handler, A attachment)

pack-priv
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv A
public boolean
cancel(boolean mayInterruptIfRunning)

Implements java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task.

pack-priv AsynchronousChannel
pack-priv Throwable
public V
get()

Implements java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

public V
get(long timeout, TimeUnit unit)

Implements java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

pack-priv Object
pack-priv CompletionHandler<V, ? super A>
public boolean
isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

public boolean
isDone()

Implements java.util.concurrent.Future.isDone.

Returns true if this task completed.

private boolean
pack-priv void
setContext(Object context)

pack-priv void
setFailure(Throwable x)

Sets the result, or a no-op if the result or exception is already set.

pack-priv void
setResult(V res)

Sets the result, or a no-op if the result or exception is already set.

pack-priv void
setResult(V res, Throwable x)

Sets the result

pack-priv void
pack-priv V
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

attachmentback to summary
private final A attachment
channelback to summary
private final AsynchronousChannel channel
contextback to summary
private volatile Object context
excback to summary
private volatile Throwable exc
handlerback to summary
private final CompletionHandler<V, ? super A> handler
haveResultback to summary
private volatile boolean haveResult
latchback to summary
private CountDownLatch latch
resultback to summary
private volatile V result
timeoutTaskback to summary
private Future<?> timeoutTask

Constructor Detail

PendingFutureback to summary
pack-priv PendingFuture(AsynchronousChannel channel, CompletionHandler<V, ? super A> handler, A attachment, Object context)
PendingFutureback to summary
pack-priv PendingFuture(AsynchronousChannel channel, CompletionHandler<V, ? super A> handler, A attachment)
PendingFutureback to summary
pack-priv PendingFuture(AsynchronousChannel channel)
PendingFutureback to summary
pack-priv PendingFuture(AsynchronousChannel channel, Object context)

Method Detail

attachmentback to summary
pack-priv A attachment()
cancelback to summary
public boolean cancel(boolean mayInterruptIfRunning)

Implements java.util.concurrent.Future.cancel.

Doc from java.util.concurrent.Future.cancel.

Attempts to cancel execution of this task. This method has no effect if the task is already completed or cancelled, or could not be cancelled for some other reason. Otherwise, if this task has not started when cancel is called, this task should never run. If the task has already started, then the mayInterruptIfRunning parameter determines whether the thread executing this task (when known by the implementation) is interrupted in an attempt to stop the task.

The return value from this method does not necessarily indicate whether the task is now cancelled; use isCancelled.

Annotations
@Override
channelback to summary
pack-priv AsynchronousChannel channel()
exceptionback to summary
pack-priv Throwable exception()
getback to summary
public V get() throws ExecutionException, InterruptedException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for the computation to complete, and then retrieves its result.

Annotations
@Override
Exceptions
ExecutionException:
if the computation threw an exception
InterruptedException:
if the current thread was interrupted while waiting
getback to summary
public V get(long timeout, TimeUnit unit) throws ExecutionException, InterruptedException, TimeoutException

Implements java.util.concurrent.Future.get.

Doc from java.util.concurrent.Future.get.

Waits if necessary for at most the given time for the computation to complete, and then retrieves its result, if available.

Annotations
@Override
Exceptions
ExecutionException:
if the computation threw an exception
InterruptedException:
if the current thread was interrupted while waiting
TimeoutException:
if the wait timed out
getContextback to summary
pack-priv Object getContext()
handlerback to summary
pack-priv CompletionHandler<V, ? super A> handler()
isCancelledback to summary
public boolean isCancelled()

Implements java.util.concurrent.Future.isCancelled.

Doc from java.util.concurrent.Future.isCancelled.

Returns true if this task was cancelled before it completed normally.

Annotations
@Override
isDoneback to summary
public boolean isDone()

Implements java.util.concurrent.Future.isDone.

Doc from java.util.concurrent.Future.isDone.

Returns true if this task completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.

Annotations
@Override
prepareForWaitback to summary
private boolean prepareForWait()
setContextback to summary
pack-priv void setContext(Object context)
setFailureback to summary
pack-priv void setFailure(Throwable x)

Sets the result, or a no-op if the result or exception is already set.

setResultback to summary
pack-priv void setResult(V res)

Sets the result, or a no-op if the result or exception is already set.

setResultback to summary
pack-priv void setResult(V res, Throwable x)

Sets the result

setTimeoutTaskback to summary
pack-priv void setTimeoutTask(Future<?> task)
valueback to summary
pack-priv V value()