public class Canceller
extends java.lang.Object
Modifier and Type | Method and Description |
---|---|
Cancellation |
check()
Check if cancellation has been requested.
|
static Canceller |
newCanceller()
Create a new
Canceller which is trivially empty. |
Canceller |
withCondition(java.lang.String reason,
java.util.function.BooleanSupplier condition)
Return a new
Canceller based on a boolean predicate. |
Canceller |
withShortCircuit()
|
Canceller |
withTimeout(java.lang.String reason,
long duration,
java.util.concurrent.TimeUnit unit)
Return a new
Canceller based on time duration. |
public static Canceller newCanceller()
Canceller
which is trivially empty. The returned
Canceller
will never relay a positive cancellation request.Canceller
.public Cancellation check()
Cancellation
should be inspected
and reacted upon.Cancellation
.public Canceller withCondition(java.lang.String reason, java.util.function.BooleanSupplier condition)
Canceller
based on a boolean predicate. The returned
instance will relay a positive cancellation request when either the
supplied boolean predicate is true
or this Canceller
is
cancelled.reason
- The reason associated to the boolean condition.condition
- A boolean predicate.Canceller
.public Canceller withTimeout(java.lang.String reason, long duration, java.util.concurrent.TimeUnit unit)
Canceller
based on time duration. The returned
instance will relay a positive cancellation request when either the
duration expires or this Canceller
is cancelled.reason
- The reason associated to the boolean condition.duration
- The duration for the timeout.unit
- The time unit for the duration.Canceller
.Copyright © 2012–2022 The Apache Software Foundation. All rights reserved.