-
- All Implemented Interfaces:
-
java.io.Closeable,java.lang.AutoCloseable
public final class CancellationTokenSource implements Closeable
Signals to a CancellationToken that it should be canceled. To create a
CancellationTokenfirst create aCancellationTokenSourcethen use token to retrieve the token for the source.
-
-
Field Summary
Fields Modifier and Type Field Description private final BooleanisCancellationRequestedprivate final CancellationTokentoken
-
Constructor Summary
Constructors Constructor Description CancellationTokenSource()
-
Method Summary
Modifier and Type Method Description final BooleangetIsCancellationRequested()final CancellationTokengetToken()final Unitcancel()Cancels the token if it has not already been cancelled. final UnitcancelAfter(Long delay)Schedules a cancel operation on this CancellationTokenSourceafter the specified number of milliseconds.Unitclose()StringtoString()-
-
Method Detail
-
getIsCancellationRequested
final Boolean getIsCancellationRequested()
-
getToken
final CancellationToken getToken()
-
cancelAfter
final Unit cancelAfter(Long delay)
Schedules a cancel operation on this
CancellationTokenSourceafter the specified number of milliseconds.- Parameters:
delay- The number of milliseconds to wait before completing the returned task.
-
-
-
-