/** * Set the stepmode. * @param stepmode True for stepmode. */ public void setStepmode(boolean stepmode) { this.stepmode = stepmode; if(!stepmode) executor.execute(); }
/** * Execute a step. */ public void doStep() { dostep = true; if(stepmode) executor.execute(); }
/** * Execute a step. */ public void doStep() { dostep = true; if(stepmode) executor.execute(); }
/** * Set the stepmode. * @param stepmode True for stepmode. */ public void setStepmode(boolean stepmode) { this.stepmode = stepmode; if(!stepmode) executor.execute(); }
/** * 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(); } }
/** * Execute a task. Triggers the task to * be executed in future. * @param task The task to execute. */ public void execute(IExecutable task) { if(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(running) executor.execute(); } }
/** * Execute a task. Triggers the task to * be executed in future. * @param task The task to execute. */ public void execute(IExecutable task) { if(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(running) executor.execute(); } }
/** * Remove a timer. * @param timer The timer. */ public void removeTimer(ITimer timer) { super.removeTimer(timer); synchronized(this) { this.notify(); } executor.execute(); }
/** * Add a timer. * @param timer The timer. */ public void addTimer(ITimer timer) { super.addTimer(timer); synchronized(this) { this.notify(); } executor.execute(); }
/** * Add a timer. * @param timer The timer. */ public void addTimer(ITimer timer) { super.addTimer(timer); // naked notify due to notifications in addTimer() must not be synchronized. synchronized(this) { this.notify(); } executor.execute(); }
/** * Remove a timer. * @param timer The timer. */ public void removeTimer(ITimer timer) { super.removeTimer(timer); // naked notify due to notifications in removeTimer() must not be synchronized. synchronized(this) { this.notify(); } executor.execute(); }
/** * Add a timer. * @param timer The timer. */ public void addTimer(ITimer timer) { super.addTimer(timer); // naked notify due to notifications in addTimer() must not be synchronized. synchronized(this) { this.notify(); } executor.execute(); }
/** * Remove a timer. * @param timer The timer. */ public void removeTimer(ITimer timer) { super.removeTimer(timer); // naked notify due to notifications in removeTimer() must not be synchronized. synchronized(this) { this.notify(); } executor.execute(); }
/** * Execute a task. Triggers the task to * be executed in future. * @param executable The task to execute. * @param listener Called when execution has started. */ public synchronized void execute(IExecutable executable, double priority) { tasks.add(new Task(executable, priority)); // Concurrency==0 means not currently running -> start. if(concurrency==0) { try { executor.execute(); } catch(Exception e) { // ignore, can only be caused by terminated threadpool service. } } }
/** * Start the clock. */ public void start() { boolean notify = false; synchronized(this) { if(!STATE_RUNNING.equals(state)) { this.state = STATE_RUNNING; this.laststart = System.currentTimeMillis(); executor.execute(); notify = true; } } if(notify) { notifyListeners(new ChangeEvent(this, EVENT_TYPE_STARTED)); } }
/** * Start the clock. */ public void start() { boolean notify = false; synchronized(this) { if(!STATE_RUNNING.equals(state)) { this.state = STATE_RUNNING; this.laststart = System.currentTimeMillis(); executor.execute(); notify = true; } } if(notify) { notifyListeners(new ChangeEvent(this, EVENT_TYPE_STARTED)); } }
/** * Start the clock. */ public void start() { boolean notify = false; synchronized(this) { if(!STATE_RUNNING.equals(state)) { this.state = STATE_RUNNING; this.laststart = System.currentTimeMillis(); executor.execute(); notify = true; } } if(notify) { notifyListeners(new ChangeEvent(this, EVENT_TYPE_STARTED)); } }
/** * Set the clocks dilation. * @param dilation The clocks dilation. */ public void setDilation(double dilation) { synchronized(this) { if(STATE_RUNNING.equals(state)) { long ct = System.currentTimeMillis(); this.elapsed += (ct-laststart)*getDilation(); this.laststart = ct; } this.dilation = dilation; this.notify(); executor.execute(); } notifyListeners(new ChangeEvent(this, EVENT_TYPE_NEW_DILATION)); }
/** * Set the clocks dilation. * @param dilation The clocks dilation. */ public void setDilation(double dilation) { synchronized(this) { if(STATE_RUNNING.equals(state)) { long ct = System.currentTimeMillis(); this.elapsed += (ct-laststart)*getDilation(); this.laststart = ct; } this.dilation = dilation; this.notify(); executor.execute(); } notifyListeners(new ChangeEvent(this, EVENT_TYPE_NEW_DILATION)); }
/** * Set the clocks dilation. * @param dilation The clocks dilation. */ public void setDilation(double dilation) { synchronized(this) { if(STATE_RUNNING.equals(state)) { long ct = System.currentTimeMillis(); this.elapsed += (ct-laststart)*getDilation(); this.laststart = ct; } this.dilation = dilation; this.notify(); executor.execute(); } notifyListeners(new ChangeEvent(this, EVENT_TYPE_NEW_DILATION)); }