Package cn.sliew.milky.concurrent
Class CompletableContext<T>
- java.lang.Object
-
- cn.sliew.milky.concurrent.CompletableContext<T>
-
- Type Parameters:
T- the result type
public class CompletableContext<T> extends Object
A thread-safe completable context that allows listeners to be attached. This class relies on theCompletableFuturefor the concurrency logic. However, it does not acceptThrowableas an exceptional result. This allows attaching listeners that only handleException.
-
-
Constructor Summary
Constructors Constructor Description CompletableContext()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddListener(BiConsumer<T,? super Exception> listener)booleancomplete(T value)booleancompleteExceptionally(Exception ex)booleanisCompletedExceptionally()booleanisDone()
-
-
-
Method Detail
-
addListener
public void addListener(BiConsumer<T,? super Exception> listener)
-
isDone
public boolean isDone()
-
isCompletedExceptionally
public boolean isCompletedExceptionally()
-
completeExceptionally
public boolean completeExceptionally(Exception ex)
-
complete
public boolean complete(T value)
-
-