Class ThreadInterruptingCancellable
- java.lang.Object
-
- io.servicetalk.concurrent.internal.ThreadInterruptingCancellable
-
- All Implemented Interfaces:
Cancellable
public final class ThreadInterruptingCancellable extends java.lang.Object implements Cancellable
ACancellablethat willinterrupt a thread.It is important that
setDone()(orsetDone(Throwable)) is called after the associated blocking operation completes to avoid "spurious" thread interrupts.
-
-
Field Summary
-
Fields inherited from interface io.servicetalk.concurrent.Cancellable
IGNORE_CANCEL
-
-
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 voidcancel()Sends a hint to the producer of the associated asynchronous execution that the consumer related to thisCancellableis not interested in the outcome of the execution.voidsetDone()Indicates the operation associated with thisCancellableis done and future calls tocancel()should be NOOPs.voidsetDone(java.lang.Throwable cause)Indicates the operation associated with thisCancellableis done and future calls tocancel()should be NOOPs.
-
-
-
Constructor Detail
-
ThreadInterruptingCancellable
public ThreadInterruptingCancellable(java.lang.Thread threadToInterrupt)
Create a new instance.- Parameters:
threadToInterrupt- The threadinterruptincancel().
-
-
Method Detail
-
cancel
public void cancel()
Description copied from interface:CancellableSends a hint to the producer of the associated asynchronous execution that the consumer related to thisCancellableis not interested in the outcome of the execution.- Specified by:
cancelin interfaceCancellable
-
setDone
public void setDone()
Indicates the operation associated with thisCancellableis done and future calls tocancel()should be NOOPs.
-
setDone
public void setDone(java.lang.Throwable cause)
Indicates the operation associated with thisCancellableis done and future calls tocancel()should be NOOPs.- Parameters:
cause- The operation failed, and this is theThrowablethat indicates why. If this isInterruptedExceptionthenThread.interrupted()will be called for the current thread to clear the interrupt status.
-
-