Class SlotSupplierFuture

  • All Implemented Interfaces:
    java.util.concurrent.CompletionStage<SlotPermit>, java.util.concurrent.Future<SlotPermit>

    public abstract class SlotSupplierFuture
    extends java.util.concurrent.CompletableFuture<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

        java.util.concurrent.CompletableFuture.AsynchronousCompletionTask
    • Method Summary

      All Methods Static Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      abstract SlotPermit abortReservation()
      Abort the reservation attempt.
      boolean cancel​(boolean mayInterruptIfRunning)  
      static SlotSupplierFuture completedFuture​(SlotPermit permit)
      See CompletableFuture.completedFuture(Object)
      static SlotSupplierFuture fromCompletableFuture​(java.util.concurrent.CompletableFuture<SlotPermit> future, java.lang.Runnable abortHandler)
      Create a new SlotSupplierFuture from a CompletableFuture
      • Methods 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, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, 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
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • SlotSupplierFuture

        public SlotSupplierFuture()
    • Method Detail

      • abortReservation

        @Nullable
        @CheckReturnValue
        public abstract SlotPermit 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:
        cancel in interface java.util.concurrent.Future<SlotPermit>
        Overrides:
        cancel in class java.util.concurrent.CompletableFuture<SlotPermit>
      • fromCompletableFuture

        public static SlotSupplierFuture fromCompletableFuture​(java.util.concurrent.CompletableFuture<SlotPermit> future,
                                                               java.lang.Runnable abortHandler)
        Create a new SlotSupplierFuture from a CompletableFuture
        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.