Class ThreadInterruptingCancellable

java.lang.Object
io.servicetalk.concurrent.internal.ThreadInterruptingCancellable
All Implemented Interfaces:
Cancellable

public final class ThreadInterruptingCancellable extends 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 Details

    • ThreadInterruptingCancellable

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

    • 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(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.