Examples of IExecutionUnit


Examples of com.aicontest.visualizer.js.tasks.IExecutionUnit

  public IExecutionUnit poll() {
    final ReentrantLock lock = this.lock;
    lock.lock();
    try {
      IExecutionUnit eu = immediate.peek();
      if (eu == null) {
        DelayedExecutionUnit deu = delayed.peek();
        if (deu == null || deu.getDelay(TimeUnit.NANOSECONDS) > 0) {
          return null;
        } else {
          IExecutionUnit x = delayed.poll();
          assert x != null;
          if (delayed.size() != 0)
            available.signalAll();
          return x;
        }
      } else {
        IExecutionUnit x = immediate.poll();
        assert x != null;
        if (immediate.size() != 0)
          available.signalAll();
        return x;
      }
View Full Code Here

Examples of com.aicontest.visualizer.js.tasks.IExecutionUnit

  public IExecutionUnit take() throws InterruptedException {
    final ReentrantLock lock = this.lock;
    lock.lockInterruptibly();
    try {
      for (;;) {
        IExecutionUnit eu = immediate.peek();
        if (eu != null) {
          IExecutionUnit x = immediate.poll();
          assert x != null;
          if (immediate.size() != 0)
            available.signalAll();
          return x;
        }
        DelayedExecutionUnit deu = delayed.peek();
        if (deu != null) {
          long delay = deu.getDelay(TimeUnit.NANOSECONDS);
          if (delay > 0) {
            available.awaitNanos(delay);
          } else {
            IExecutionUnit x = delayed.poll();
            assert x != null;
            if (delayed.size() != 0)
              available.signalAll(); // wake up other takers
            return x;
          }
View Full Code Here

Examples of com.aicontest.visualizer.js.tasks.IExecutionUnit

    long nanos = unit.toNanos(timeout);
    final ReentrantLock lock = this.lock;
    lock.lockInterruptibly();
    try {
      for (;;) {
        IExecutionUnit eu = immediate.peek();
        if (eu != null) {
          IExecutionUnit x = immediate.poll();
          assert x != null;
          if (immediate.size() != 0)
            available.signalAll();
          return x;
        }
        DelayedExecutionUnit deu = delayed.peek();
        if (deu == null) {
          if (nanos <= 0)
            return null;
          else
            nanos = available.awaitNanos(nanos);
        } else {
          long delay = deu.getDelay(TimeUnit.NANOSECONDS);
          if (delay > 0) {
            if (nanos <= 0)
              return null;
            if (delay > nanos)
              delay = nanos;
            long timeLeft = available.awaitNanos(delay);
            nanos -= delay - timeLeft;
          } else {
            IExecutionUnit x = delayed.poll();
            assert x != null;
            if (delayed.size() != 0)
              available.signalAll();
            return x;
          }
View Full Code Here

Examples of com.aicontest.visualizer.js.tasks.IExecutionUnit

  public IExecutionUnit peek() {
    final ReentrantLock lock = this.lock;
    lock.lock();
    try {
      IExecutionUnit eu = immediate.peek();
      if (eu != null) {
        return eu;
      }
      return delayed.peek();
    } finally {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.