notifyCompletion()is allowed to be executed from an outside of the task thread.
It solves a problem of a potential memory leak as described in FLINK-25728. In short we have
to ensure, that if there is one input (future) that rarely (or never) completes, that such future
would not prevent previously returned combined futures (like
CompletableFuture.anyOf(CompletableFuture) from being garbage collected. Additionally, we
don't want to accumulate more and more completion stages on such rarely completed future, so we
CompletableFuture.thenRun(Runnable) only if it has not already been done.
resetToUnAvailable() doesn't de register previously registered futures. If
future was registered in the past, but for whatever reason now it is not, such future can still
complete the newly created future.
It might be no longer needed after upgrading to JDK9 (https://bugs.openjdk.java.net/browse/JDK-8160402).
|Constructor and Description|
|Modifier and Type||Method and Description|
public MultipleFuturesAvailabilityHelper(int size)
public CompletableFuture<?> getAvailableFuture()
public void resetToUnAvailable()
public void anyOf(int idx, CompletableFuture<?> availabilityFuture)
availabilityFutureusing anyOf logic with other previously registered futures.
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.