Class CompletableFutureUtils
java.lang.Object
dev.langchain4j.internal.CompletableFutureUtils
Utility methods for working with
CompletableFuture.-
Method Summary
Modifier and TypeMethodDescriptionstatic voidpropagateCancellation(CompletableFuture<?> from, CompletableFuture<?> to) Forwards cancellation from one future to another.
-
Method Details
-
propagateCancellation
Forwards cancellation from one future to another.CompletableFuture.cancel(boolean)does not propagate to the stages a future was derived from, so whenfromrepresents the future handed to a caller andtorepresents the underlying work (e.g. an in-flight HTTP request), cancellingfromwould otherwise leavetorunning. This method bridges that gap: oncefromcompletes, if it was cancelled,tois cancelled too.- Parameters:
from- the future whose cancellation should be propagated; ignored ifnull.to- the future to cancel whenfromis cancelled.
-