T - The type of the futures that this class works with.public class ReusableFutureLatch<T>
extends java.lang.Object
ReusableLatch but that works with CompletableFuture so
that blocking can be async and exceptions and results can be passed.| Constructor and Description |
|---|
ReusableFutureLatch() |
| Modifier and Type | Method and Description |
|---|---|
void |
register(java.util.concurrent.CompletableFuture<T> toNotify)
Supply a future to be notified when
release(Object) is called. |
void |
registerAndRunReleaser(java.lang.Runnable willCallRelease,
java.util.concurrent.CompletableFuture<T> toNotify)
If the latch is released, completes the provided future without invoking the provided
runnable.
|
void |
release(T result)
Complete all waiting futures, and all future calls to register be notified immediately.
|
void |
releaseExceptionally(java.lang.Throwable e)
Complete all waiting futures, and all future calls to register be notified immediately.
|
void |
releaseExceptionallyAndReset(java.lang.Throwable e)
Identical to calling
#releaseExceptionally(Exception); #reset() except it is atomic. |
void |
reset()
If
release(Object) or #releaseExceptionally(Exception) has been called it
resets the object into the unreleased state. |
java.lang.String |
toString() |
public void register(java.util.concurrent.CompletableFuture<T> toNotify)
release(Object) is called. If release has already been
called, it will be completed immediately.toNotify - The future that should be completed.public void registerAndRunReleaser(java.lang.Runnable willCallRelease,
java.util.concurrent.CompletableFuture<T> toNotify)
willCallRelease - A runnable that should result in release(Object) being called.toNotify - The future to notify once release is called.public void release(T result)
register(CompletableFuture)result - The result to pass to waiting futures.public void releaseExceptionally(java.lang.Throwable e)
register(CompletableFuture)e - The exception to pass to waiting futures.public void reset()
release(Object) or #releaseExceptionally(Exception) has been called it
resets the object into the unreleased state. If release has not been called this will have no effect.public void releaseExceptionallyAndReset(java.lang.Throwable e)
#releaseExceptionally(Exception); #reset() except it is atomic.e - The exception to fail all waiting futures with.public java.lang.String toString()
toString in class java.lang.Object