java.lang.Object
org.evrete.util.CompletionManager<K,T>
- Type Parameters:
K- the type of keys maintained by this managerT- the type of values associated with the CompletableFutures
Manages
CompletableFuture instances associated with given keys.
This class provides a mechanism to retrieve or compute a completion for a given key,
ensuring that each key is only associated with one future which is removed upon completion.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionEnqueues a new CompletableFuture for the given key.int
-
Constructor Details
-
CompletionManager
public CompletionManager()
-
-
Method Details
-
enqueue
public CompletableFuture<T> enqueue(K key, Function<? super K, ? extends CompletableFuture<T>> mappingFunction) Enqueues a new CompletableFuture for the given key. If a future is already associated with the key, the new future is chained to execute after the existing one completes. Regardless of whether the future was newly created or enqueued after an existing one, it is removed from the manager once completed.- Parameters:
key- the key whose future is to be enqueued or retrievedmappingFunction- the function to compute a future if none is associated with the key- Returns:
- a new or updated CompletableFuture associated with the given key
-
taskCount
public int taskCount()
-