Class SlotSupplierFuture
- All Implemented Interfaces:
CompletionStage<SlotPermit>,Future<SlotPermit>
Represents a future that will be completed with a
SlotPermit when a slot is available.
This class exists to provide a reliable cancellation mechanism, since CompletableFuture does not provide cancellations that properly propagate up the chain.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTaskNested classes/interfaces inherited from interface java.util.concurrent.Future
Future.State -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract SlotPermitAbort the reservation attempt.booleancancel(boolean mayInterruptIfRunning) static SlotSupplierFuturecompletedFuture(SlotPermit permit) static SlotSupplierFuturefromCompletableFuture(CompletableFuture<SlotPermit> future, Runnable abortHandler) Create a newSlotSupplierFuturefrom aCompletableFutureMethods inherited from class java.util.concurrent.CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, exceptionNow, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, resultNow, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, state, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsync
-
Constructor Details
-
SlotSupplierFuture
public SlotSupplierFuture()
-
-
Method Details
-
abortReservation
Abort the reservation attempt. Direct implementations should cancel or interrupt any underlying processes that are attempting to reserve a slot. -
cancel
public boolean cancel(boolean mayInterruptIfRunning) - Specified by:
cancelin interfaceFuture<SlotPermit>- Overrides:
cancelin classCompletableFuture<SlotPermit>
-
completedFuture
-
fromCompletableFuture
public static SlotSupplierFuture fromCompletableFuture(CompletableFuture<SlotPermit> future, Runnable abortHandler) Create a newSlotSupplierFuturefrom aCompletableFuture- Parameters:
abortHandler- The handler to call when the reservation is aborted. This should abort the furthest-upstream future, or call being waited on, in order to properly propagate cancellation downstream.
-