-
- 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 booleanisCancellationRequested()CancellationTokengetToken()voidcancel()Cancels the token if it has not already been cancelled. voidcancelAfter(long delay)Schedules a cancel operation on this {@code CancellationTokenSource}after the specified number of milliseconds.voidclose()CancellationTokenRegistrationregister(Runnable action)voidthrowIfCancellationRequested()voidunregister(CancellationTokenRegistration registration)StringtoString()-
-
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)
-
-
-
-