Class AsynchronousExecution
- All Implemented Interfaces:
- Serializable
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 Executor.getAsynchronousExecution().
 
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 OneOffExecutor (from a 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.
 
ResourceController/ResourceActivity/ResourceList/Resource are not currently supported.
 Nor are Queue.Task.getSubTasks() other than the primary task.
- Since:
- 1.607
- See Also:
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionabstract booleanAllows an executable to indicate whether it is currently doing something which should prevent Jenkins from being shut down safely.final voidTo be called when the task is actually complete.abstract booleanAllows an executable to control whether or not to displayexecutorCell.jelly.final ExecutorObtains the associated executor.abstract voidinterrupt(boolean forShutdown) Called in lieu ofThread.interrupt()byExecutor.interrupt()and its overloads.final voidIf there is a pending completion notification, deliver it to the executor.final voidsetExecutorWithoutCompleting(Executor executor) Set the executor without notifying it about task completion.Methods inherited from class java.lang.ThrowableaddSuppressed, fillInStackTrace, getCause, getLocalizedMessage, getMessage, getStackTrace, getSuppressed, initCause, printStackTrace, printStackTrace, printStackTrace, setStackTrace, toString
- 
Constructor Details- 
AsynchronousExecutionprotected AsynchronousExecution()Constructor for subclasses.
 
- 
- 
Method Details- 
interruptpublic abstract void interrupt(boolean forShutdown) Called in lieu ofThread.interrupt()byExecutor.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 callExecutor.recordCauseOfInterruption(hudson.model.Run<?, ?>, hudson.model.TaskListener)ongetExecutor().- Parameters:
- forShutdown- if true, this interruption is because Jenkins is shutting down (and thus- Computer.interrupt()was called from- Jenkins.cleanUp()); otherwise, a normal interrupt such as by- Executor.doStop()
 
- 
blocksRestartpublic 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 passedforShutdown=true.)- Returns:
- traditionally always true
- See Also:
 
- 
displayCellpublic abstract boolean displayCell()Allows an executable to control whether or not to displayexecutorCell.jelly.If this method returns false, the asynchronous execution becomes invisible from UI. - Returns:
- traditionally always true
 
- 
getExecutorObtains the associated executor.- Returns:
- Associated Executor. May be nullifsetExecutorWithoutCompleting(hudson.model.Executor)has not been called yet.
 
- 
setExecutorWithoutCompleting@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 callmaybeComplete()after releasing any problematic locks.
- 
maybeComplete@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 aftersetExecutorWithoutCompleting(Executor).
- 
completedTo be called when the task is actually complete.- Parameters:
- 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)
 
 
-