Class NonBlockingManagerImpl

    • Constructor Detail

      • NonBlockingManagerImpl

        public NonBlockingManagerImpl()
    • Method Detail

      • scheduleWithFixedDelay

        public AutoCloseable scheduleWithFixedDelay​(Supplier<CompletionStage<?>> supplier,
                                                    long initialDelay,
                                                    long delay,
                                                    TimeUnit unit,
                                                    Predicate<? super Throwable> mayRepeatOnThrowable)
        Description copied from interface: NonBlockingManager
        Schedules the supplier that is executed after the initialDelay period and subsequently runs delay after the previous stage completes. The supplier must not block the thread in which it runs and should immediately return to avoid blocking the scheduling thread.

        This supplier method will not be rescheduled if the supplier throws any Throwable directly. If the CompletionStage returned from the supplier produces a Throwable, it is possible to reschedule the supplier if the given Throwable passes the mayRepeatOnThrowable predicate.

        Specified by:
        scheduleWithFixedDelay in interface NonBlockingManager
        Parameters:
        supplier - non-blocking operation supplier.
        initialDelay - period of time before the supplier is invoked.
        delay - delay between subsequent supplier invocations.
        unit - time unit for delays.
        mayRepeatOnThrowable - whether to continue scheduling if the provided supplier returns a Throwable
        Returns:
        an AutoCloseable that cancels the scheduled task.
      • complete

        public <T> void complete​(CompletableFuture<? super T> future,
                                 T value)
        Description copied from interface: NonBlockingManager
        Completes the provided future with the given value. If the future does not have any dependents it will complete it in the invoking thread. However, if there are any dependents it will complete it in a non blocking thread. This is a best effort to prevent a context switch for a stage that does not yet have a dependent while also handing off the dependent processing to a non blocking thread if necessary.
        Specified by:
        complete in interface NonBlockingManager
        Type Parameters:
        T - the type of the value
        Parameters:
        future - the future to complete
        value - the value to complete the future with
      • completeExceptionally

        public void completeExceptionally​(CompletableFuture<?> future,
                                          Throwable t)
        Description copied from interface: NonBlockingManager
        Exceptionally completes the provided future with the given throble. If the future does not have any dependents it will complete it in the invoking thread. However, if there are any dependents it will complete it in a non blocking thread. This is a best effort to prevent a context switch for a stage that does not yet have a dependent while also handing off the dependent processing to a non blocking thread if necessary.
        Specified by:
        completeExceptionally in interface NonBlockingManager
        Parameters:
        future - future to complete
        t - throwable to complete the future with