-
- All Implemented Interfaces:
-
java.io.Closeable
,java.lang.AutoCloseable
public class CancellationTokenSource implements Closeable
Copyright 2017 Meniga Iceland Inc. Signals to a CancellationToken that it should be canceled. To create a
{@code CancellationToken}
first create a{@code CancellationTokenSource}
then call getToken to retrieve the token for the source.
-
-
Constructor Summary
Constructors Constructor Description CancellationTokenSource()
Create a new {@code CancellationTokenSource}
.
-
Method Summary
Modifier and Type Method Description boolean
isCancellationRequested()
CancellationToken
getToken()
void
cancel()
Cancels the token if it has not already been cancelled. void
cancelAfter(long delay)
Schedules a cancel operation on this {@code CancellationTokenSource}
after the specified number of milliseconds.void
close()
CancellationTokenRegistration
register(Runnable action)
void
throwIfCancellationRequested()
void
unregister(CancellationTokenRegistration registration)
String
toString()
-
-
Method Detail
-
isCancellationRequested
boolean isCancellationRequested()
-
getToken
CancellationToken getToken()
-
cancel
void cancel()
Cancels the token if it has not already been cancelled.
-
cancelAfter
void cancelAfter(long delay)
Schedules a cancel operation on this
{@code CancellationTokenSource}
after the specified number of milliseconds.- Parameters:
delay
- The number of milliseconds to wait before completing the returned task.
-
close
void close()
-
register
CancellationTokenRegistration register(Runnable action)
-
throwIfCancellationRequested
void throwIfCancellationRequested()
-
unregister
void unregister(CancellationTokenRegistration registration)
-
-
-
-