/** * Called within the queue maintenance process to create a {@link WorkUnit} for the given {@link SubTask} */ public WorkUnit createWorkUnit(SubTask execUnit) { WorkUnit wu = new WorkUnit(this, execUnit); workUnits.add(wu); return wu; }
/** * When one of the work unit is aborted, call this method to abort all the other work units. */ public synchronized void abort(Throwable cause) { if (cause==null) throw new IllegalArgumentException(); if (aborted!=null) return; // already aborted aborted = cause; startLatch.abort(cause); endLatch.abort(cause); Thread c = Thread.currentThread(); for (WorkUnit wu : workUnits) { Executor e = wu.getExecutor(); if (e!=null && e!=c) e.interrupt(); } } }
@Override protected void onCriteriaMet() { // on behalf of the member Executors, // the one that executes the main thing will send notifications // Unclear if this will work with AsynchronousExecution; it *seems* this is only called from synchronize which is only called from synchronizeStart which is only called from an executor thread. Executor e = Executor.currentExecutor(); if (e.getCurrentWorkUnit().isMainWork()) { e.getOwner().taskAccepted(e,task); } } };
private void finish1(@CheckForNull Throwable problems) { if (problems != null) { // for some reason the executor died. this is really // a bug in the code, but we don't want the executor to die, // so just leave some info and go on to build other things LOGGER.log(Level.SEVERE, "Executor threw an exception", problems); workUnit.context.abort(problems); } long time = System.currentTimeMillis() - startTime; LOGGER.log(FINE, "{0} completed {1} in {2}ms", new Object[]{getName(), executable, time}); try { workUnit.context.synchronizeEnd(this, executable, problems, time); } catch (InterruptedException e) { workUnit.context.abort(e); } finally { workUnit.setExecutor(null); } }
/** * If this is representing an item that started executing, this property returns * the primary executable (such as {@link AbstractBuild}) that created out of it. */ @Exported public @CheckForNull Executable getExecutable() { return outcome!=null ? outcome.getPrimaryWorkUnit().getExecutable() : null; }
private void finish1(@CheckForNull Throwable problems) { if (problems != null) { // for some reason the executor died. this is really // a bug in the code, but we don't want the executor to die, // so just leave some info and go on to build other things LOGGER.log(Level.SEVERE, "Executor threw an exception", problems); workUnit.context.abort(problems); } long time = System.currentTimeMillis() - startTime; LOGGER.log(FINE, "{0} completed {1} in {2}ms", new Object[]{getName(), executable, time}); try { workUnit.context.synchronizeEnd(this, executable, problems, time); } catch (InterruptedException e) { workUnit.context.abort(e); } finally { workUnit.setExecutor(null); } }
for (Executor e : c.getAllExecutors()) { final WorkUnit workUnit = e.getCurrentWorkUnit(); final Executable executable = workUnit != null ? workUnit.getExecutable() : null; final SubTask subtask = executable != null ? getParentOf(executable) : null;
/** * All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the start. */ public void synchronizeStart() throws InterruptedException { startLatch.synchronize(); // the main thread will send a notification Executor e = Executor.currentExecutor(); WorkUnit wu = e.getCurrentWorkUnit(); if (wu.isMainWork()) { future.start.set(e.getCurrentExecutable()); } }
/** * Called within the queue maintenance process to create a {@link WorkUnit} for the given {@link SubTask} */ public WorkUnit createWorkUnit(SubTask execUnit) { WorkUnit wu = new WorkUnit(this, execUnit); workUnits.add(wu); return wu; }
/** * When one of the work unit is aborted, call this method to abort all the other work units. */ public synchronized void abort(Throwable cause) { if (cause==null) throw new IllegalArgumentException(); if (aborted!=null) return; // already aborted aborted = cause; startLatch.abort(cause); endLatch.abort(cause); Thread c = Thread.currentThread(); for (WorkUnit wu : workUnits) { Executor e = wu.getExecutor(); if (e!=null && e!=c) e.interrupt(); } } }
workUnit.setExecutor(this); task = workUnit.work; startTime = System.currentTimeMillis(); continue; } finally { workUnit.setExecutor(null);
/** * If this is representing an item that started executing, this property returns * the primary executable (such as {@link AbstractBuild}) that created out of it. */ @Exported public @CheckForNull Executable getExecutable() { return outcome!=null ? outcome.getPrimaryWorkUnit().getExecutable() : null; }
/** * All the {@link Executor}s that jointly execute a {@link Task} call this method to synchronize on the end of the task. * * @throws InterruptedException * If any of the member thread is interrupted while waiting for other threads to join, all * the member threads will report {@link InterruptedException}. */ public void synchronizeEnd(Executor e, Queue.Executable executable, Throwable problems, long duration) throws InterruptedException { endLatch.synchronize(); // the main thread will send a notification WorkUnit wu = e.getCurrentWorkUnit(); if (wu.isMainWork()) { if (problems == null) { future.set(executable); e.getOwner().taskCompleted(e, task, duration); } else { future.set(problems); e.getOwner().taskCompletedWithProblems(e, task, duration, problems); } } }
/** * Called by the executor that executes a member {@link SubTask} that belongs to this task * to create its {@link WorkUnit}. */ public WorkUnit createWorkUnit(SubTask execUnit) { future.addExecutor(Executor.currentExecutor()); WorkUnit wu = new WorkUnit(this, execUnit); workUnits.add(wu); return wu; }
/** * When one of the work unit is aborted, call this method to abort all the other work units. */ public synchronized void abort(Throwable cause) { if (cause==null) throw new IllegalArgumentException(); if (aborted!=null) return; // already aborted aborted = cause; startLatch.abort(cause); endLatch.abort(cause); Thread c = Thread.currentThread(); for (WorkUnit wu : workUnits) { Executor e = wu.getExecutor(); if (e!=null && e!=c) e.interrupt(); } } }
workUnit.setExecutor(this); task = workUnit.work; startTime = System.currentTimeMillis(); continue; } finally { workUnit.setExecutor(null);
for (Executor e : c.getAllExecutors()) { final WorkUnit workUnit = e.getCurrentWorkUnit(); final Executable executable = workUnit != null ? workUnit.getExecutable() : null; final SubTask subtask = executable != null ? getParentOf(executable) : null;
@Override protected void onCriteriaMet() { // on behalf of the member Executors, // the one that executes the main thing will send notifications // Unclear if this will work with AsynchronousExecution; it *seems* this is only called from synchronize which is only called from synchronizeStart which is only called from an executor thread. Executor e = Executor.currentExecutor(); if (e.getCurrentWorkUnit().isMainWork()) { e.getOwner().taskAccepted(e,task); } } };
/** * Called by the executor that executes a member {@link SubTask} that belongs to this task * to create its {@link WorkUnit}. */ public WorkUnit createWorkUnit(SubTask execUnit) { future.addExecutor(Executor.currentExecutor()); WorkUnit wu = new WorkUnit(this, execUnit); workUnits.add(wu); return wu; }
/** * When one of the work unit is aborted, call this method to abort all the other work units. */ public synchronized void abort(Throwable cause) { if (cause==null) throw new IllegalArgumentException(); if (aborted!=null) return; // already aborted aborted = cause; startLatch.abort(cause); endLatch.abort(cause); Thread c = Thread.currentThread(); for (WorkUnit wu : workUnits) { Executor e = wu.getExecutor(); if (e!=null && e!=c) e.interrupt(); } } }