return new Executor(threadpool, new IExecutable()
/** * Set the stepmode. * @param stepmode True for stepmode. */ public void setStepmode(boolean stepmode) { this.stepmode = stepmode; if(!stepmode) executor.execute(); }
/** * Called, when the clock is no longer used. */ public void dispose() { executor.shutdown(); // Wake up timer thread, if currently waiting. synchronized(this) { this.notify(); } // notificator.shutdown(null); }
/** * Unblock the thread waiting for the given monitor * and cease execution on the current thread. * @param monitor The monitor to notify. */ public void unblock(Object monitor, boolean kill) { if(Thread.currentThread()!=componentthread) { throw new RuntimeException("Can only unblock current component thread: "+componentthread+", "+Thread.currentThread()); } Executor exe = blocked.remove(monitor); if(blocked.isEmpty()) { blocked = null; } // Throw thread death if component already has been terminated. Throwable t = kill ? new StepAborted() : null; exe.switchThread(monitor, t); }
exe.blockThread(monitor);
/** * Unblock the thread waiting for the given monitor * and cease execution on the current thread. * @param monitor The monitor to notify. */ public void unblock(Object monitor, Throwable exception) { if(!isComponentThread()) { throw new RuntimeException("Can only unblock from component thread: "+componentthread+", "+Thread.currentThread()); } if(parenta!=null) { parenta.unblock(monitor, exception); } else { // System.out.println("unblock: "+monitor); Executor exe = blocked.remove(monitor); if(blocked.isEmpty()) { blocked = null; } exe.switchThread(monitor, exception); } }
try exe.blockThread(monitor);
/** * Execute a step. */ public void doStep() { dostep = true; if(stepmode) executor.execute(); }
return new Executor(threadpool, new IExecutable()
/** * Called, when the clock is no longer used. */ public void dispose() { executor.shutdown(); // Wake up timer thread, if currently waiting. synchronized(this) { timers.clear(); // Todo: should still send notifications? this.notify(); } // notificator.shutdown(null); }
public void run() { super.run(); // ICommand[] commands = null; Future<Void> idf = null; synchronized(AsyncExecutionService.this) { synchronized(this) { // isRunning() refers to running state of executor! // Do not remove when a new executor has already been added for the task. if(!this.isRunning() && executors!=null && executors.get(task)==this) { idf = removeTask(task); } } } if(idf!=null) idf.setResult(null); // for(int i=0; commands!=null && i<commands.length; i++) // { // commands[i].execute(null); // } } };
/** * Set the stepmode. * @param stepmode True for stepmode. */ public void setStepmode(boolean stepmode) { this.stepmode = stepmode; if(!stepmode) executor.execute(); }
return new Executor(threadpool, new IExecutable()
/** * Called, when the clock is no longer used. */ public void dispose() { executor.shutdown(); // Wake up timer thread, if currently waiting. synchronized(this) { timers.clear(); // Todo: should still send notifications? this.notify(); } // notificator.shutdown(null); }
/** * Execute a step. */ public void doStep() { dostep = true; if(stepmode) executor.execute(); }
this.limit = 1; this.tasks = new TreeSet(); this.executor = new Executor(pool, new IExecutable()
public IFuture<Void> shutdown() { if(task instanceof AbstractComponentFeature && ((AbstractComponentFeature)task).getComponent().getComponentIdentifier().equals(getServiceIdentifier().getProviderId())) { return IFuture.DONE; } else { return super.shutdown(); } } };
/** * Execute a task. Triggers the task to * be executed in future. * @param task The task to execute. */ public void execute(IExecutable task) { if(state==State.SHUTDOWN) return; // if(DEBUG) // System.out.println("execute called: "+task+", "+this.task); boolean added; synchronized(this) { // new RuntimeException().printStackTrace(System.out); added = queue.add(task); // if(DEBUG) // System.out.println("Task added: "+queue+", "+this.task); } // On change, wake up the main executor for executing tasks if(added) { if(state==State.RUNNING) executor.execute(); } }