public void run() { if(isDone()) return; super.run(); if(cancelled) return; done=false; // run again switch(type) { case dynamic: long next_interval=TimeUnit.NANOSECONDS.convert(((TimeScheduler.Task)runnable).nextInterval(), TimeUnit.MILLISECONDS); if(next_interval <= 0) { if(log.isTraceEnabled()) log.trace("task will not get rescheduled as interval is " + next_interval); done=true; return; } creation_time=System.nanoTime(); delay=next_interval; break; case fixed_rate: delay=initial_delay + cnt++ * period; break; case fixed_delay: creation_time=System.nanoTime(); delay=period; break; } add(this); // schedule this task again } }
public void run() { if(isDone()) return; super.run(); if(cancelled) return; done=false; // run again switch(type) { case dynamic: long next_interval=TimeUnit.NANOSECONDS.convert(((TimeScheduler.Task)runnable).nextInterval(), TimeUnit.MILLISECONDS); if(next_interval <= 0) { if(log.isTraceEnabled()) log.trace("task will not get rescheduled as interval is " + next_interval); done=true; return; } creation_time=System.nanoTime(); delay=next_interval; break; case fixed_rate: delay=initial_delay + cnt++ * period; break; case fixed_delay: creation_time=System.nanoTime(); delay=period; break; } add(this); // schedule this task again } }
public void run() { if(isDone()) return; super.run(); if(cancelled) return; done=false; // run again switch(type) { case dynamic: long next_interval=TimeUnit.NANOSECONDS.convert(((TimeScheduler.Task)runnable).nextInterval(), TimeUnit.MILLISECONDS); if(next_interval <= 0) { if(log.isTraceEnabled()) log.trace("task will not get rescheduled as interval is " + next_interval); done=true; return; } creation_time=System.nanoTime(); delay=next_interval; break; case fixed_rate: delay=initial_delay + cnt++ * period; break; case fixed_delay: creation_time=System.nanoTime(); delay=period; break; } add(this); // schedule this task again } }
public void execute(Runnable task) { submitToPool(task instanceof TimeScheduler.Task? new RecurringTask(task, TaskType.dynamic, 0, ((TimeScheduler.Task)task).nextInterval(), TimeUnit.MILLISECONDS) : new Task(task)); // we'll execute the task directly }
protected long nextInterval() { if(task instanceof Task) return ((Task)task).nextInterval(); return 0; } }
/** * Schedule a task for execution at varying intervals. After execution, the task will get rescheduled after * {@link org.apache.activemq.artemis.shaded.org.jgroups.util.TimeScheduler.Task#nextInterval()} milliseconds. The task is never done until * nextInterval() returns a value <= 0 or the task is cancelled.<p/> * Note that the task is rescheduled relative to the last time is actually executed. This is similar to * {@link #scheduleWithFixedDelay(Runnable,long,long,java.util.concurrent.TimeUnit)}. * @param work the task to execute */ public Future<?> scheduleWithDynamicInterval(TimeScheduler.Task work) { return scheduleRecurring(work, TaskType.dynamic, work.nextInterval(), 0, TimeUnit.MILLISECONDS); }
public void doSchedule() { long next_interval=task.nextInterval(); if(next_interval <= 0) { if(log.isTraceEnabled()) log.trace("task will not get rescheduled as interval is " + next_interval); } else { future=schedule(this, next_interval, TimeUnit.MILLISECONDS); if(cancelled) future.cancel(true); } }
/** * Schedule a task for execution at varying intervals. After execution, the task will get rescheduled after * {@link org.apache.activemq.artemis.shaded.org.jgroups.util.TimeScheduler.Task#nextInterval()} milliseconds. The task is never done until * nextInterval() returns a value <= 0 or the task is cancelled.<p/> * Note that the task is rescheduled relative to the last time is actually executed. This is similar to * {@link #scheduleWithFixedDelay(Runnable,long,long,java.util.concurrent.TimeUnit)}. * @param work the task to execute */ public Future<?> scheduleWithDynamicInterval(TimeScheduler.Task work) { return scheduleRecurring(work, TaskType.dynamic, work.nextInterval(), 0, TimeUnit.MILLISECONDS); }
protected long nextInterval() { if(task instanceof Task) return ((Task)task).nextInterval(); return 0; } }
protected long nextInterval() { if(task instanceof Task) return ((Task)task).nextInterval(); return 0; } }
/** * Schedule a task for execution at varying intervals. After execution, the task will get rescheduled after * {@link org.apache.activemq.artemis.shaded.org.jgroups.util.TimeScheduler.Task#nextInterval()} milliseconds. The task is never done until * nextInterval() returns a value <= 0 or the task is cancelled.<p/> * Note that the task is rescheduled relative to the last time is actually executed. This is similar to * {@link #scheduleWithFixedDelay(Runnable,long,long,java.util.concurrent.TimeUnit)}. * @param work the task to execute */ public Future<?> scheduleWithDynamicInterval(TimeScheduler.Task work) { return scheduleRecurring(work, TaskType.dynamic, work.nextInterval(), 0, TimeUnit.MILLISECONDS); }
public void execute(Runnable task) { submitToPool(task instanceof TimeScheduler.Task? new RecurringTask(task, TaskType.dynamic, 0, ((TimeScheduler.Task)task).nextInterval(), TimeUnit.MILLISECONDS) : new Task(task)); // we'll execute the task directly }
protected long nextInterval() { if(task instanceof Task) return ((Task)task).nextInterval(); return 0; } }
protected long nextInterval() { if(task instanceof Task) return ((Task)task).nextInterval(); return 0; } }
protected long nextInterval() { if(task instanceof Task) return ((Task)task).nextInterval(); return 0; } }
public void doSchedule() { long next_interval=task.nextInterval(); if(next_interval <= 0) { if(log.isTraceEnabled()) log.trace("task will not get rescheduled as interval is " + next_interval); } else { future=schedule(this, next_interval, TimeUnit.MILLISECONDS); if(cancelled) future.cancel(true); } }
public void execute(Runnable task) { submitToPool(task instanceof TimeScheduler.Task? new RecurringTask(task, TaskType.dynamic, 0, ((TimeScheduler.Task)task).nextInterval(), TimeUnit.MILLISECONDS) : new Task(task)); // we'll execute the task directly }
public void doSchedule() { long next_interval=task.nextInterval(); if(next_interval <= 0) { if(log.isTraceEnabled()) log.trace("task will not get rescheduled as interval is " + next_interval); } else { future=schedule(this, next_interval, TimeUnit.MILLISECONDS); if(cancelled) future.cancel(true); } }