TError - type of exception it may raise.public interface ISynchronizationPoint<TError extends Exception>
| Modifier and Type | Method and Description |
|---|---|
void |
block(long timeout)
Pause the current thread to wait for this synchronization point to be unblocked.
|
default void |
blockException(long timeout)
Pause the current thread to wait for this synchronization point to be unblocked,
and if it has an error it is thrown.
|
void |
blockPause(long logWarningAfterMillis)
Really block, using wait method (used by threading system to know when a thread can be resumed).
|
default void |
blockThrow(long timeout)
Pause the current thread to wait for this synchronization point to be unblocked.
|
void |
cancel(CancelException reason)
Cancel this synchronization point: unblock it immediately, and set the cancellation reason.
|
void |
error(TError error)
Unblock with an error.
|
default void |
forwardCancel(ISynchronizationPoint<?> sp)
If this synchronization point is cancelled, the given synchronization point will be cancelled as well with the same reason.
|
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 unblocked because of a cancellation.
|
default boolean |
isSuccessful()
Return true if unblocked with success: it must be unblocked, without error, and without a cancel event.
|
boolean |
isUnblocked()
Return true if unblocked (success or cancelled).
|
default void |
listenAsync(Task<?,? extends Exception> task,
boolean evenIfErrorOrCancel)
Start the given task when this synchronization point is unblocked.
|
default void |
listenAsync(Task<?,? extends Exception> task,
ISynchronizationPoint<TError> onErrorOrCancel)
Start the given task when this synchronization point is successfully unblocked, else the error or cancel
event are forwarded to the given synchronization point.
|
default void |
listenAsyncSP(Task<?,? extends Exception> task,
ISynchronizationPoint<Exception> onErrorOrCancel)
Start the given task when this synchronization point is successfully unblocked, else the error or cancel
event are forwarded to the given synchronization point.
|
void |
listenInline(Runnable listener)
Call listener when unblocked (whatever the result is successful, has error or is cancelled).
|
default void |
listenInline(Runnable onReady,
ISynchronizationPoint<TError> onErrorOrCancel)
Call listener when unblocked, or forward error/cancellation to onErrorOrCancel.
|
default void |
listenInline(Runnable onReady,
Listener<TError> onError,
Listener<CancelException> onCancel)
Call listeners when unblocked.
|
default void |
listenInline(SynchronizationPoint<TError> sp)
Transfer the result of this blocking point to the given synchronization point:
unblock it on success, call error method on error, or call cancel method on cancellation.
|
default void |
listenInlineSP(Runnable onReady,
ISynchronizationPoint<Exception> onErrorOrCancel)
Call listener when unblocked, or forward error/cancellation to onErrorOrCancel.
|
default void |
listenInlineSP(SynchronizationPoint<Exception> sp)
Same as listenInline but does not restrict to a synchronization point with the same exception type as parameter.
|
default void |
onCancel(Listener<CancelException> listener)
Call the given listener, only when this synchronization point is unblocked due to cancellation.
|
default void |
onError(Listener<TError> listener)
Call the given listener, only when this synchronization point is unblocked with an error.
|
default void |
onException(Listener<Exception> listener)
Call the given listener, only when this synchronization point is unblocked with an error.
|
default void |
onSuccess(Runnable listener)
Call the given listener, only when this synchronization point is unblocked without error or cancellation.
|
default void |
synchWithNoError(SynchronizationPoint<?> sp)
Unblock the given synchronization point whatever the result is successful, has error or is cancelled.
|
default AsyncWork<Void,TError> |
toAsyncWorkVoid()
Convert this synchronization point into an AsyncWork with Void result.
|
boolean isUnblocked()
boolean isCancelled()
void cancel(CancelException reason)
CancelException getCancelEvent()
boolean hasError()
void error(TError error)
TError getError()
default boolean isSuccessful()
void block(long timeout)
default void blockException(long timeout)
throws TError extends Exception
default void blockThrow(long timeout)
throws TError extends Exception,
CancelException
TError extends ExceptionCancelExceptionvoid blockPause(long logWarningAfterMillis)
void listenInline(Runnable listener)
default void listenInline(Runnable onReady, Listener<TError> onError, Listener<CancelException> onCancel)
default void listenInline(Runnable onReady, ISynchronizationPoint<TError> onErrorOrCancel)
default void listenInline(SynchronizationPoint<TError> sp)
default void listenInlineSP(Runnable onReady, ISynchronizationPoint<Exception> onErrorOrCancel)
default void listenInlineSP(SynchronizationPoint<Exception> sp)
default void synchWithNoError(SynchronizationPoint<?> sp)
default void onSuccess(Runnable listener)
default void onError(Listener<TError> listener)
default void onException(Listener<Exception> listener)
default void onCancel(Listener<CancelException> listener)
default void forwardCancel(ISynchronizationPoint<?> sp)
default void listenAsync(Task<?,? extends Exception> task, boolean evenIfErrorOrCancel)
default void listenAsync(Task<?,? extends Exception> task, ISynchronizationPoint<TError> onErrorOrCancel)
default void listenAsyncSP(Task<?,? extends Exception> task, ISynchronizationPoint<Exception> onErrorOrCancel)
default AsyncWork<Void,TError> toAsyncWorkVoid()
Collection<?> getAllListeners()
Copyright © 2018. All rights reserved.