hudson.model.Executor Maven / Gradle / Ivy
package hudson.model;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import javax.servlet.ServletException;
import java.io.IOException;
/**
* Thread that executes builds.
*
* @author Kohsuke Kawaguchi
*/
public class Executor extends Thread {
private final Computer owner;
private final Queue queue;
private Build build;
private long startTime;
/**
* Executor number that identifies it among other executors for the same {@link Computer}.
*/
private int number;
public Executor(Computer owner) {
super("Executor #"+owner.getExecutors().size()+" for "+owner.getDisplayName());
this.owner = owner;
this.queue = Hudson.getInstance().getQueue();
this.number = owner.getExecutors().size();
start();
}
public void run() {
while(true) {
if(Hudson.getInstance().isTerminating())
return;
synchronized(owner) {
if(owner.getNumExecutors()=100) num=99;
return num;
}
/**
* Stops the current build.
*/
public void doStop( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
if(!Hudson.adminCheck(req,rsp))
return;
interrupt();
rsp.forwardToPreviousPage(req);
}
public Computer getOwner() {
return owner;
}
/**
* Returns the executor of the current thread.
*/
public static Executor currentExecutor() {
return (Executor)Thread.currentThread();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy