public static final class CompletableFutureExtensions.TimeoutConfig extends Object
orTimeout(CompletableFuture<R>, (TimeoutConfig)=>void)
extension method.Modifier and Type | Method and Description |
---|---|
void |
setBackwardPropagateCancel(boolean cancelPropagation)
If this method is called with
true , canceling the created timeout future
will try to cancel the original future.Default value is false |
void |
setCancelOriginalOnTimeout(boolean cancelOriginalOnTimeout)
If this method is called with
true , the original future will be
tried to be canceled if the created timeout future will cancelled.Default value is false |
void |
setExceptionProvider(Functions.Function0<? extends Throwable> exceptionProvider)
Sets the provider of an exception that will be called on timeout.
|
void |
setScheduler(ScheduledExecutorService scheduler)
Sets the scheduler used to schedule the timeout operation.
|
void |
setTimeout(Duration timeout)
Sets the time duration after which the timeout operation is triggered.
Default value is 1 second . |
void |
setTimeout(Pair<Long,TimeUnit> timeout)
Sets the time duration after which the timeout operation is triggered.
Default value is 1 second . |
void |
setTryShutdownScheduler(boolean doShutdown)
Defines if the scheduler for cancellation operation should be shut down after
the original future completes or a timeout occurs.
|
public void setTimeout(Pair<Long,TimeUnit> timeout)
1 second
.timeout
- Pair of time amount and time unit of duration of timeout.public void setTimeout(Duration timeout)
1 second
.timeout
- time duration of timeoutpublic void setScheduler(ScheduledExecutorService scheduler)
ScheduledExecutorService
is created and
shut down after completion of the original future or after timeout.scheduler
- the scheduler used to schedule the timeout operationpublic void setTryShutdownScheduler(boolean doShutdown)
setScheduler
is used
to set custom scheduler.false
.doShutdown
- if true
the given scheduler
should be shut down after the original future completes or a timeout occurs.public void setExceptionProvider(Functions.Function0<? extends Throwable> exceptionProvider)
TimeoutException
will be used to complete
the future on timeout.exceptionProvider
- constructor operation to create exception to
be set when timeout occurs.public void setBackwardPropagateCancel(boolean cancelPropagation)
true
, canceling the created timeout future
will try to cancel the original future.false
cancelPropagation
- if true
, canceling the created timeout future
will try to cancel the original future.public void setCancelOriginalOnTimeout(boolean cancelOriginalOnTimeout)
true
, the original future will be
tried to be canceled if the created timeout future will cancelled.false
cancelOriginalOnTimeout
- if true
, the original future will be
tried to be canceled if the created timeout future will cancelled.Copyright © 2019. All rights reserved.