[]
AutoCloseable
CancellationTokenSource
allows you to issue cancellation requests to one or more methods.To use a token source: getToken()
as parameter.cancel()
on this token source.This class is thread safe.
close()
method when you don't need to use it anymore.void
cancel()
void
cancelAfter(Duration delay)
CancellationTokenSource
after the specified time span.void
close()
getToken()
CancellationTokenSource
.It is assumed that the consumers of getToken()
will do 'best-effort' attempt to perform cancellation.This method returns immediately and if the cancellation is successful the cancelled operation will throw CancellationException
.
CancellationTokenSource
after the specified time span.delay
- The time span to wait before canceling this CancellationTokenSource
. This value can't be null.CancellationTokenSource
.close
in interface AutoCloseable
Exception