TError - type of exception it may raisepublic class Async<TError extends Exception> extends Object implements IAsync<TError>, Future<Void>
| Constructor and Description |
|---|
Async()
Constructor.
|
Async(boolean unblocked)
Constructor with an initial state.
|
Async(CancelException cancel)
Create an unblocked point with a cancellation.
|
Async(IAsync<TError2> toConvert,
Function<TError2,TError> errorConverter)
Create an asynchronous unit from the given one, converting the error using the given converter.
|
Async(TError error)
Create an unblocked point with an error.
|
| Modifier and Type | Method and Description |
|---|---|
void |
block(long timeout)
Pause the current thread to wait for this asynchronous unit to be unblocked.
|
boolean |
blockPauseCondition()
Return true if blockPause should still block.
|
boolean |
cancel(boolean mayInterruptIfRunning) |
void |
cancel(CancelException reason)
Cancel this object: unblock it immediately, and set the cancellation reason.
|
void |
error(TError error)
Unblock with an error.
|
Void |
get() |
Void |
get(long timeout,
TimeUnit unit) |
Collection<?> |
getAllListeners()
Return a collection with all listeners, only for debugging purposes.
|
CancelException |
getCancelEvent()
Get the reason of the cancellation.
|
TError |
getError()
Return the error.
|
boolean |
hasError()
Return true if unblocked because of an error.
|
boolean |
isCancelled()
Return true if this object is cancelled.
|
boolean |
isDone()
Return true if unblocked (success or cancelled).
|
void |
onDone(Runnable r)
Call listener when unblocked (whatever the result is successful, has error or is cancelled).
|
void |
reset()
Reset this synchronization point to reuse it.
|
void |
restart()
Same as the method reset except that listeners are kept.
|
void |
unblock()
Unblock this synchronization point without error.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitblockException, blockPause, blockThrow, forwardIfNotSuccessful, isSuccessful, logListenerError, onCancel, onDone, onDone, onDone, onDone, onDone, onDone, onError, onErrorOrCancel, onSuccess, thenDoOrStart, thenDoOrStart, thenDoOrStart, thenStart, thenStart, thenStart, thenStart, thenStart, thenStart, toAsyncSupplierpublic Async()
public Async(boolean unblocked)
public Async(TError error)
public Async(CancelException cancel)
public Collection<?> getAllListeners()
IAsyncgetAllListeners in interface IAsync<TError extends Exception>public final void onDone(Runnable r)
IAsyncpublic final void unblock()
public final void error(TError error)
IAsyncpublic final void cancel(CancelException reason)
Cancellablecancel in interface Cancellablepublic final void block(long timeout)
IAsyncpublic boolean blockPauseCondition()
IAsyncblockPauseCondition in interface IAsync<TError extends Exception>public final boolean isDone()
IAsyncpublic final boolean isCancelled()
CancellableisCancelled in interface Future<Void>isCancelled in interface Cancellablepublic final boolean hasError()
IAsyncpublic final CancelException getCancelEvent()
CancellablegetCancelEvent in interface Cancellablepublic final void reset()
public final void restart()
public final Void get() throws InterruptedException, ExecutionException
get in interface Future<Void>InterruptedExceptionExecutionExceptionpublic final Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
get in interface Future<Void>InterruptedExceptionExecutionExceptionTimeoutExceptionCopyright © 2019. All rights reserved.