Package ghidra.async
Class AsyncFence
java.lang.Object
ghidra.async.AsyncFence
A fence that completes when all participating futures complete
This provides an alternative shorthand for Java's
CompletableFuture.thenAcceptBoth(CompletionStage, BiConsumer)
or
CompletableFuture.allOf(CompletableFuture...)
.
Example:
public CompletableFuture<Void> processAll(List<Integer> list) {
AsyncFence fence = new AsyncFence();
for (int entry : list) {
fence.include(process(entry));
}
return fence.ready();
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSet
<CompletableFuture<?>> Diagnostic: Get the participants which have not yet completedinclude
(CompletableFuture<?> future) Include a participant with this fence The result of the participating future is ignored implicitly.ready()
Obtain a future that completes when all participating futures have completed Calling this method more than once will yield undefined results.
-
Constructor Details
-
AsyncFence
public AsyncFence()
-
-
Method Details
-
include
Include a participant with this fence The result of the participating future is ignored implicitly. If the result is needed, it must be consumed out of band, e.g., by usingCompletableFuture.thenAccept(Consumer)
:fence.include(process(entry).thenAccept(result::addTo));
Calling this method afterready()
will yield undefined results.- Parameters:
future
- the participant to add- Returns:
- this fence
-
ready
Obtain a future that completes when all participating futures have completed Calling this method more than once will yield undefined results.- Returns:
- the "all of" future
-
getPending
Diagnostic: Get the participants which have not yet completed- Returns:
- the pending participants
-