Class CallbackCompletable<T>
java.lang.Object
ca.spottedleaf.concurrentutil.completable.CallbackCompletable<T>
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddAsynchronousWaiter(BiConsumer<T, Throwable> consumer) Adds a waiter that should only be completed asynchronously by the complete() calls.addWaiter(BiConsumer<T, Throwable> consumer) Adds a waiter that will be completed asynchronously by the complete() calls.voidvoidcompleteWithThrowable(Throwable throwable) Note: Can only use after callingaddAsynchronousWaiter(BiConsumer), as this function performs zero synchronisationNote: Can only use after callingaddAsynchronousWaiter(BiConsumer), as this function performs zero synchronisationboolean
-
Constructor Details
-
CallbackCompletable
public CallbackCompletable()
-
-
Method Details
-
isCompleted
public boolean isCompleted() -
getResult
Note: Can only use after callingaddAsynchronousWaiter(BiConsumer), as this function performs zero synchronisation -
getThrowable
Note: Can only use after callingaddAsynchronousWaiter(BiConsumer), as this function performs zero synchronisation -
addAsynchronousWaiter
Adds a waiter that should only be completed asynchronously by the complete() calls. If complete() has already been called, returnsnulland does not invoke the specified consumer.- Parameters:
consumer- Consumer to be executed on completion- Returns:
- A cancellable which will control the execution of the specified consumer
- Throws:
NullPointerException- If consumer is null
-
addWaiter
Adds a waiter that will be completed asynchronously by the complete() calls. If complete() has already been called, then invokes the consumer synchronously with the completed result.- Parameters:
consumer- Consumer to be executed on completion- Returns:
- A cancellable which will control the execution of the specified consumer
- Throws:
NullPointerException- If consumer is null
-
complete
-
completeWithThrowable
-