Package org.jboss.errai.bus.server.async

Examples of org.jboss.errai.bus.server.async.TimedTask


  public AsyncTask scheduleRepeating(final Runnable runnable, final TimeUnit unit, final long initial, final long interval) {
    checkLoad();
    mutex.lock();
    try {
      TimedTask task;
      scheduledTasks.offer(task = new RepeatingTimedTask(runnable, unit.toMillis(initial), unit.toMillis(interval)));

      return task;
    }
    finally {
View Full Code Here


    }
  }

  private long runAllDue() throws InterruptedException {
    long nextRunTime = 0;
    TimedTask task;

    while ((task = scheduledTasks.poll(60, java.util.concurrent.TimeUnit.SECONDS)) != null) {
      if (!task.isDue(currentTimeMillis())) {
        parkUntil(task.nextRuntime());
      }

      /**
       * Sechedule the task for execution.
       */
      if (!queue.offer(task, 5, java.util.concurrent.TimeUnit.SECONDS)) {
        saturationPolicy.dealWith(task);
      }

      if (task.calculateNextRuntime()) {
        scheduledTasks.offer(task);
      }
    }

    return nextRunTime;
View Full Code Here

  public AsyncTask schedule(final Runnable runnable, TimeUnit unit, long interval) {
    checkLoad();
    mutex.lock();
    try {
      TimedTask task;
      scheduledTasks.offer(task = new DelayedTask(runnable, unit.toMillis(interval)));

      return task;
    }
    finally {
View Full Code Here

  public AsyncTask scheduleRepeating(final Runnable runnable, final TimeUnit unit, final long initial, final long interval) {
    checkLoad();
    mutex.lock();
    try {
      TimedTask task;
      scheduledTasks.offer(task = new RepeatingTimedTask(runnable, unit.toMillis(initial), unit.toMillis(interval)));

      return task;
    }
    finally {
View Full Code Here

    }
  }

  private long runAllDue() throws InterruptedException {
    long nextRunTime = 0;
    TimedTask task;

    while ((task = scheduledTasks.poll(60, java.util.concurrent.TimeUnit.SECONDS)) != null) {
      if (!task.isDue(currentTimeMillis())) {
        parkUntil(task.nextRuntime());
      }

      /**
       * Sechedule the task for execution.
       */
      if (!queue.offer(task, 5, java.util.concurrent.TimeUnit.SECONDS)) {
        saturationPolicy.dealWith(task);
      }

      if (task.calculateNextRuntime()) {
        scheduledTasks.offer(task);
      }
    }

    return nextRunTime;
View Full Code Here

                        break;
                }
            }
        });

        houseKeeper.addTask(new TimedTask() {
            {
                this.period = (1000 * 10);
            }

            public void run() {
View Full Code Here

        if (svc.getBus() instanceof ServerMessageBusImpl) {
            ServerMessageBusImpl busImpl = (ServerMessageBusImpl) svc.getBus();
            /**
             * Add a housekeeper task to the bus housekeeper to timeout long-running tasks.
             */
            busImpl.getScheduler().addTask(new TimedTask() {
                {
                    period = 1000;
                }
                public void run() {
                    for (Worker w : workerPool) {
View Full Code Here

     * processed
     */
    public void scheduleActivation() {
        synchronized (activationLock) {
            bus.getScheduler().addTask(
                    task = new TimedTask() {
                        {
                            period = -1; // only fire once.
                            nextRuntime = getEndOfWindow();
                        }

View Full Code Here

     * processed
     */
    public void scheduleActivation() {
        synchronized (activationLock) {
            bus.getScheduler().addTask(
                    task = new TimedTask() {
                        {
                            period = -1; // only fire once.
                            nextRuntime = getEndOfWindow();
                        }

View Full Code Here

            return;
        }

        synchronized (this) {
            log.debug("executing scheduler");
            TimedTask task;
            for (Iterator<TimedTask> iter = tasks.iterator(); iter.hasNext();) {
                if ((task = iter.next()).runIfDue(n = currentTimeMillis())) {
                    if (task.nextRuntime() == -1) {
                        // if the next runtime is -1, that means this event
                        // is never scheduled to run again, so we remove it.
                        iter.remove();
                    } else {
                        // set the nextRuntime to the nextRuntim of this event
                        nextRunTime = task.nextRuntime();
                    }
                } else if (task.nextRuntime() == -1) {
                    // this event is not scheduled to run.
                    iter.remove();
                } else if (nextRunTime == 0 || task.nextRuntime() < nextRunTime) {
                    // this event occurs before the current nextRuntime,
                    // so we update nextRuntime.
                    nextRunTime = task.nextRuntime();
                } else if (n > task.nextRuntime()) {
                    // Since the scheduled events are in the order of soonest to
                    // latest, we now know that all further events are in the future
                    // and we can therefore stop iterating.
                    return;
                }
View Full Code Here

TOP

Related Classes of org.jboss.errai.bus.server.async.TimedTask

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.