Package org.infinispan.util.concurrent
Class NonBlockingManagerImpl
- java.lang.Object
-
- org.infinispan.util.concurrent.NonBlockingManagerImpl
-
- All Implemented Interfaces:
NonBlockingManager
public class NonBlockingManagerImpl extends Object implements NonBlockingManager
-
-
Constructor Summary
Constructors Constructor Description NonBlockingManagerImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description <T> void
complete(CompletableFuture<? super T> future, T value)
Completes the provided future with the given value.void
completeExceptionally(CompletableFuture<?> future, Throwable t)
Exceptionally completes the provided future with the given throble.AutoCloseable
scheduleWithFixedDelay(Supplier<CompletionStage<?>> supplier, long initialDelay, long delay, TimeUnit unit, Predicate<? super Throwable> mayRepeatOnThrowable)
Schedules the supplier that is executed after the initialDelay period and subsequently runs delay after the previous stage completes.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.infinispan.util.concurrent.NonBlockingManager
scheduleWithFixedDelay
-
-
-
-
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 interfaceNonBlockingManager
- 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 interfaceNonBlockingManager
- Type Parameters:
T
- the type of the value- Parameters:
future
- the future to completevalue
- 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 interfaceNonBlockingManager
- Parameters:
future
- future to completet
- throwable to complete the future with
-
-