Interface CancellationToken

    • Method Detail

      • isCancellationRequested

        boolean isCancellationRequested()
        Returns whether cancellation has been requested.
        Returns:
        true, if cancellation has already been requested, false if not.
      • getMessage

        String getMessage()
        Returns the cancellation message if any.
        Returns:
        the cancellation message if any.
        Throws:
        IllegalStateException - if the token has not been cancelled.
      • throwIfCancellationRequested

        void throwIfCancellationRequested()
        Throws an exception in case isCancellationRequested() evaluates to true.
      • register

        CancellationTokenRegistration register​(Action<? extends RuntimeException> observer)
        Registers a function that is invoked when cancellation is requested. The callback is invoked on the current AsyncScheduler. If a listener is added while already in a cancelled state, this listener is called immediately and synchronously.
        Parameters:
        observer - the action to invoke when cancellation is requested.
        Returns:
        an Observable that is invoked if cancellation is requested or immediately if already cancelled.
      • register

        CancellationTokenRegistration register​(Action<? extends RuntimeException> observer,
                                               boolean useScheduler)
        Registers a function that is invoked when cancellation is requested. If a listener is added while already in a cancelled state, this listener is called immediately and synchronously.
        Parameters:
        observer - the action to invoke when cancellation is requested.
        useScheduler - if set to true, the current AsyncScheduler is captured and used for invoking the callback.
        Returns:
        an Observable that is invoked if cancellation is requested or immediately if already cancelled.