java.lang.Object
org.elasticsearch.common.util.CancellableThreads
A utility class for multi threaded operation that needs to be cancellable via interrupts. Every cancellable operation should be
 executed via 
execute(Interruptible), which will capture the executing thread and make sure it is interrupted in the case
 of cancellation.
 Cancellation policy: This class does not support external interruption via Thread#interrupt(). Always use #cancel() instead.- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic classstatic interfacestatic interface
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidcancel all current running operations.voidvoidexecute(CancellableThreads.Interruptible interruptible) run the Interruptible, capturing the executing thread.booleanvoidsetOnCancel(CancellableThreads.OnCancel onCancel) Registers a callback that will be invoked when some running operations are cancelled orcheckForCancel()is called.
- 
Constructor Details- 
CancellableThreadspublic CancellableThreads()
 
- 
- 
Method Details- 
isCancelledpublic boolean isCancelled()
- 
checkForCancelpublic void checkForCancel()
- 
executerun the Interruptible, capturing the executing thread. Concurrent calls tocancel(String)will interrupt this thread causing the call to prematurely return.- Parameters:
- interruptible- code to run
 
- 
cancelcancel all current running operations. Future calls tocheckForCancel()will be failed with the given reason
- 
setOnCancelRegisters a callback that will be invoked when some running operations are cancelled orcheckForCancel()is called.
 
-