public class Canceller extends 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(String reason,
BooleanSupplier condition)
Return a new
Canceller based on a boolean predicate. |
Canceller |
withShortCircuit()
|
Canceller |
withTimeout(String reason,
long duration,
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(String reason, 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(String reason, long duration, 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–2020 The Apache Software Foundation. All rights reserved.