-
- 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
CancellationToken
first create aCancellationTokenSource
then use token to retrieve the token for the source.
-
-
Field Summary
Fields Modifier and Type Field Description private final Boolean
isCancellationRequested
private final CancellationToken
token
-
Constructor Summary
Constructors Constructor Description CancellationTokenSource()
-
Method Summary
Modifier and Type Method Description final Boolean
getIsCancellationRequested()
final CancellationToken
getToken()
final Unit
cancel()
Cancels the token if it has not already been cancelled. final Unit
cancelAfter(Long delay)
Schedules a cancel operation on this CancellationTokenSource
after the specified number of milliseconds.Unit
close()
String
toString()
-
-
Method Detail
-
getIsCancellationRequested
final Boolean getIsCancellationRequested()
-
getToken
final CancellationToken getToken()
-
cancelAfter
final Unit cancelAfter(Long delay)
Schedules a cancel operation on this
CancellationTokenSource
after the specified number of milliseconds.- Parameters:
delay
- The number of milliseconds to wait before completing the returned task.
-
-
-
-