Class ThreadInterruptingCancellable

  • All Implemented Interfaces:
    Cancellable

    public final class ThreadInterruptingCancellable
    extends java.lang.Object
    implements Cancellable
    A Cancellable that will interrupt a thread.

    It is important that setDone() (or setDone(Throwable)) is called after the associated blocking operation completes to avoid "spurious" thread interrupts.

    • Constructor Summary

      Constructors 
      Constructor Description
      ThreadInterruptingCancellable​(java.lang.Thread threadToInterrupt)
      Create a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void cancel()
      Sends a hint to the producer of the associated asynchronous execution that the consumer related to this Cancellable is not interested in the outcome of the execution.
      void setDone()
      Indicates the operation associated with this Cancellable is done and future calls to cancel() should be NOOPs.
      void setDone​(java.lang.Throwable cause)
      Indicates the operation associated with this Cancellable is done and future calls to cancel() should be NOOPs.
      • Methods inherited from class java.lang.Object

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

      • ThreadInterruptingCancellable

        public ThreadInterruptingCancellable​(java.lang.Thread threadToInterrupt)
        Create a new instance.
        Parameters:
        threadToInterrupt - The thread interrupt in cancel().
    • Method Detail

      • cancel

        public void cancel()
        Description copied from interface: Cancellable
        Sends a hint to the producer of the associated asynchronous execution that the consumer related to this Cancellable is not interested in the outcome of the execution.
        Specified by:
        cancel in interface Cancellable
      • setDone

        public void setDone()
        Indicates the operation associated with this Cancellable is done and future calls to cancel() should be NOOPs.
      • setDone

        public void setDone​(java.lang.Throwable cause)
        Indicates the operation associated with this Cancellable is done and future calls to cancel() should be NOOPs.
        Parameters:
        cause - The operation failed, and this is the Throwable that indicates why. If this is InterruptedException then Thread.interrupted() will be called for the current thread to clear the interrupt status.