T
- the type of result that this operation producespublic class FinishedIoFuture<T> extends Object implements IoFuture<T>
IoFuture
that represents an immediately-successful operation.IoFuture.HandlingNotifier<T,A>, IoFuture.Notifier<T,A>, IoFuture.Status
Constructor and Description |
---|
FinishedIoFuture(T result)
Create an instance.
|
Modifier and Type | Method and Description |
---|---|
<A> IoFuture<T> |
addNotifier(IoFuture.Notifier<? super T,A> notifier,
A attachment)
Add a notifier to be called when this operation is complete.
|
IoFuture.Status |
await()
Wait for the operation to complete.
|
IoFuture.Status |
await(long time,
TimeUnit timeUnit)
Wait for the operation to complete, with a timeout.
|
IoFuture.Status |
awaitInterruptibly()
Wait for the operation to complete.
|
IoFuture.Status |
awaitInterruptibly(long time,
TimeUnit timeUnit)
Wait for the operation to complete, with a timeout.
|
IoFuture<T> |
cancel()
Cancel the operation.
|
T |
get()
Get the result of the operation.
|
IOException |
getException()
Get the failure reason.
|
T |
getInterruptibly()
Get the result of the operation.
|
IoFuture.Status |
getStatus()
Get the current status.
|
public FinishedIoFuture(T result)
result
- the operation resultpublic IoFuture<T> cancel()
cancel
in interface Cancellable
cancel
in interface IoFuture<T>
public IoFuture.Status getStatus()
IoFuture
public IoFuture.Status await()
IoFuture
IoFuture.Status.WAITING
.public IoFuture.Status await(long time, TimeUnit timeUnit)
IoFuture
IoFuture.Status.WAITING
,
or the given time elapses. If the time elapses before the operation is complete, IoFuture.Status.WAITING
is
returned.await
in interface IoFuture<T>
time
- the amount of time to waittimeUnit
- the time unitIoFuture.Status.WAITING
if the timeout expiredpublic IoFuture.Status awaitInterruptibly() throws InterruptedException
IoFuture
IoFuture.Status.WAITING
,
or the current thread is interrupted.awaitInterruptibly
in interface IoFuture<T>
InterruptedException
- if the operation is interruptedpublic IoFuture.Status awaitInterruptibly(long time, TimeUnit timeUnit) throws InterruptedException
IoFuture
IoFuture.Status.WAITING
,
the given time elapses, or the current thread is interrupted. If the time elapses before the operation is complete, IoFuture.Status.WAITING
is
returned.awaitInterruptibly
in interface IoFuture<T>
time
- the amount of time to waittimeUnit
- the time unitIoFuture.Status.WAITING
if the timeout expiredInterruptedException
- if the operation is interruptedpublic T get() throws IOException, CancellationException
IoFuture
get
in interface IoFuture<T>
IOException
- if the operation failedCancellationException
- if the operation was cancelledpublic T getInterruptibly() throws IOException, InterruptedException, CancellationException
IoFuture
getInterruptibly
in interface IoFuture<T>
IOException
- if the operation failedInterruptedException
- if the operation is interruptedCancellationException
- if the operation was cancelledpublic IOException getException() throws IllegalStateException
IoFuture
getException
in interface IoFuture<T>
IllegalStateException
- if the operation did not failpublic <A> IoFuture<T> addNotifier(IoFuture.Notifier<? super T,A> notifier, A attachment)
IoFuture
addNotifier
in interface IoFuture<T>
A
- the attachment typenotifier
- the notifier to be calledattachment
- the attachment to pass in to the notifierCopyright © 2020 JBoss by Red Hat. All rights reserved.