- All Implemented Interfaces:
public abstract class AsynchronousExecution extends RuntimeExceptionSpecial means of indicating that an executable will proceed in the background without consuming a native thread (
Executor). May be thrown from
Queue.Executable.run()after doing any preparatory work synchronously.
Executor.isActive()will remain true (even though
Thread.isAlive()is not) until
completed(java.lang.Throwable)is called. The thrower could hold on to a reference to this instance as a handle to call
completed(java.lang.Throwable), or look it up later via
The execution may not extend into another Jenkins session; if you wish to model a long-running execution, you must schedule a new task after restart. This class is not serializable anyway.
Mainly intended for use with
Queue.FlyweightTask), of which there could be many, but could also be used with a heavyweight executor even though the number of executors is bounded by node configuration.
- See Also:
- Serialized Form
Constructors Modifier Constructor Description
AsynchronousExecution()Constructor for subclasses.
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description
blocksRestart()Allows an executable to indicate whether it is currently doing something which should prevent Jenkins from being shut down safely.
completed(Throwable error)To be called when the task is actually complete.
displayCell()Allows an executable to control whether or not to display
getExecutor()Obtains the associated executor.
maybeComplete()If there is a pending completion notification, deliver it to the executor.
setExecutorWithoutCompleting(Executor executor)Set the executor without notifying it about task completion.
Methods inherited from class java.lang.Throwable
addSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
public abstract void interrupt(boolean forShutdown)Called in lieu of
Executor.interrupt()and its overloads. As with the standard Java method, you are requested to cease work as soon as possible, but there is no enforcement of this. You might also want to call
Executor.recordCauseOfInterruption(hudson.model.Run<?, ?>, hudson.model.TaskListener)on
public abstract boolean blocksRestart()Allows an executable to indicate whether it is currently doing something which should prevent Jenkins from being shut down safely. You may return false if it is fine for an administrator to exit/restart Jenkins despite this executable still being running. (If so,
interrupt(boolean)will be passed
- traditionally always true
- See Also:
public abstract boolean displayCell()Allows an executable to control whether or not to display
If this method returns false, the asynchronous execution becomes invisible from UI.
- traditionally always true
@CheckForNull public final Executor getExecutor()Obtains the associated executor.
- Associated Executor. May be
setExecutorWithoutCompleting(hudson.model.Executor)has not been called yet.
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final void setExecutorWithoutCompleting(@NonNull Executor executor)Set the executor without notifying it about task completion. The caller must also call
maybeComplete()after releasing any problematic locks.
@Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public final void maybeComplete()If there is a pending completion notification, deliver it to the executor. Must be called after
public final void completed(@CheckForNull Throwable error)To be called when the task is actually complete.
error- normally null (preferable to handle errors yourself), but may be specified to simulate an exception from
Queue.Executable.run(), as per
ExecutorListener.taskCompletedWithProblems(hudson.model.Executor, hudson.model.Queue.Task, long, java.lang.Throwable)