@AutoFinal
@CompileStatic
@GroovyASTTransformation
class ThreadInterruptibleASTTransformation
extends AbstractInterruptibleASTTransformation
Allows "interrupt-safe" executions of scripts by adding Thread.currentThread().isInterrupted() checks on loops (for, while, do) and first statement of closures. By default, also adds an interrupt check statement on the beginning of method calls.
| Fields inherited from class | Fields |
|---|---|
class AbstractInterruptibleASTTransformation |
CHECK_METHOD_START_MEMBER, THROWN_EXCEPTION_TYPE, applyToAllClasses, applyToAllMembers, checkOnMethodStart, source, thrownExceptionType |
| Constructor and description |
|---|
ThreadInterruptibleASTTransformation() |
| Type Params | Return Type | Name and description |
|---|---|---|
|
protected Expression |
createCondition()Builds the condition that checks the current thread interruption flag. |
|
protected String |
getErrorMessage()Returns the message used when the current thread has been interrupted. |
|
protected ClassNode |
type()Returns the annotation type handled by this transformation. |
|
void |
visitClosureExpression(ClosureExpression closure)Wraps closure bodies with the thread interruption check. |
|
void |
visitMethod(MethodNode method)Wraps eligible methods with the thread interruption check. |
Builds the condition that checks the current thread interruption flag.
Returns the message used when the current thread has been interrupted.
Returns the annotation type handled by this transformation.
Wraps closure bodies with the thread interruption check.
closure - the closure being visitedWraps eligible methods with the thread interruption check.
method - the method being visitedCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.