T
- object typepublic final class CountDownCompleter<T>
extends java.lang.Object
consumer
callback until a set number of actions tracked by a long
counter complete.
Each completion is recorded by invoking the countDown
method. When the total number of completions is equal to the preset counter value,
this instance is marked as completed and the callback invoked by supplying the object
held by this instance.
Constructor and Description |
---|
CountDownCompleter(T object,
long count,
java.util.function.Consumer<T> onCompleteCallback)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
countDown()
Records a single completion.
|
boolean |
isComplete()
Returns if this instance has completed.
|
T |
object()
Returns the object.
|
public CountDownCompleter(T object, long count, java.util.function.Consumer<T> onCompleteCallback)
object
- objectcount
- total number of times countDown must be invoked for this completer to completeonCompleteCallback
- callback to invoke when completer is completedpublic T object()
public void countDown()
If this instance has already completed, this method has no effect
public boolean isComplete()
true
if completed