Class ThreadInterruptingCancellable
- java.lang.Object
-
- io.servicetalk.concurrent.internal.ThreadInterruptingCancellable
-
- All Implemented Interfaces:
Cancellable
public final class ThreadInterruptingCancellable extends java.lang.Object implements Cancellable
ACancellable
that 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 void
cancel()
Sends a hint to the producer of the associated asynchronous execution that the consumer related to thisCancellable
is not interested in the outcome of the execution.void
setDone()
Indicates the operation associated with thisCancellable
is done and future calls tocancel()
should be NOOPs.void
setDone(java.lang.Throwable cause)
Indicates the operation associated with thisCancellable
is done and future calls tocancel()
should be NOOPs.
-
-
-
Constructor Detail
-
ThreadInterruptingCancellable
public ThreadInterruptingCancellable(java.lang.Thread threadToInterrupt)
Create a new instance.- Parameters:
threadToInterrupt
- The threadinterrupt
incancel()
.
-
-
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 thisCancellable
is not interested in the outcome of the execution.- Specified by:
cancel
in interfaceCancellable
-
setDone
public void setDone()
Indicates the operation associated with thisCancellable
is done and future calls tocancel()
should be NOOPs.
-
setDone
public void setDone(java.lang.Throwable cause)
Indicates the operation associated with thisCancellable
is done and future calls tocancel()
should be NOOPs.- Parameters:
cause
- The operation failed, and this is theThrowable
that indicates why. If this isInterruptedException
thenThread.interrupted()
will be called for the current thread to clear the interrupt status.
-
-