Package 

Class CancellationTokenSource

  • All Implemented Interfaces:
    java.io.Closeable , java.lang.AutoCloseable

    
    public class CancellationTokenSource
     implements Closeable
                        

    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 numberof milliseconds.
      void close()
      String toString()
      • Methods inherited from class java.io.Closeable

        close
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CancellationTokenSource

        CancellationTokenSource()
        Create a new {@code CancellationTokenSource}.
    • Method Detail

      • 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 numberof milliseconds.

        Parameters:
        delay - The number of milliseconds to wait before completing the returned task.