public long convert(long d, TimeUnit u) { return u.toNanos(d); } int excessNanos(long d, long m) { return (int)(d - (m*C2)); }
public long convert(long d, TimeUnit u) { return u.toNanos(d); } int excessNanos(long d, long m) { return (int)(d - (m*C2)); }
public long convert(long d, TimeUnit u) { return u.toNanos(d); } int excessNanos(long d, long m) { return (int)(d - (m*C2)); }
public Object invokeAny(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return doInvokeAny(tasks, true, unit.toNanos(timeout)); }
public Object invokeAny(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return doInvokeAny(tasks, true, unit.toNanos(timeout)); }
public Object invokeAny(Collection tasks, long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { return doInvokeAny(tasks, true, unit.toNanos(timeout)); }
/** * @throws CancellationException {@inheritDoc} */ public synchronized Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { waitFor(unit.toNanos(timeout)); return getResult(); }
/** * @throws CancellationException {@inheritDoc} */ public synchronized Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { waitFor(unit.toNanos(timeout)); return getResult(); }
/** * @throws CancellationException {@inheritDoc} */ public synchronized Object get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException { waitFor(unit.toNanos(timeout)); return getResult(); }
/** * @throws RejectedExecutionException {@inheritDoc} * @throws NullPointerException {@inheritDoc} */ public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { if (command == null || unit == null) throw new NullPointerException(); if (delay < 0) delay = 0; long triggerTime = now() + unit.toNanos(delay); RunnableScheduledFuture t = decorateTask(command, new ScheduledFutureTask(command, null, triggerTime)); delayedExecute(t); return t; }
/** * @throws RejectedExecutionException {@inheritDoc} * @throws NullPointerException {@inheritDoc} */ public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) { if (callable == null || unit == null) throw new NullPointerException(); if (delay < 0) delay = 0; long triggerTime = now() + unit.toNanos(delay); RunnableScheduledFuture t = decorateTask(callable, new ScheduledFutureTask(callable, triggerTime)); delayedExecute(t); return t; }
/** * @throws RejectedExecutionException {@inheritDoc} * @throws NullPointerException {@inheritDoc} */ public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) { if (callable == null || unit == null) throw new NullPointerException(); if (delay < 0) delay = 0; long triggerTime = now() + unit.toNanos(delay); RunnableScheduledFuture t = decorateTask(callable, new ScheduledFutureTask(callable, triggerTime)); delayedExecute(t); return t; }
/** * @throws RejectedExecutionException {@inheritDoc} * @throws NullPointerException {@inheritDoc} */ public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { if (command == null || unit == null) throw new NullPointerException(); if (delay < 0) delay = 0; long triggerTime = now() + unit.toNanos(delay); RunnableScheduledFuture t = decorateTask(command, new ScheduledFutureTask(command, null, triggerTime)); delayedExecute(t); return t; }
/** * @throws RejectedExecutionException {@inheritDoc} * @throws NullPointerException {@inheritDoc} */ public ScheduledFuture schedule(Callable callable, long delay, TimeUnit unit) { if (callable == null || unit == null) throw new NullPointerException(); if (delay < 0) delay = 0; long triggerTime = now() + unit.toNanos(delay); RunnableScheduledFuture t = decorateTask(callable, new ScheduledFutureTask(callable, triggerTime)); delayedExecute(t); return t; }
/** * @throws RejectedExecutionException {@inheritDoc} * @throws NullPointerException {@inheritDoc} */ public ScheduledFuture schedule(Runnable command, long delay, TimeUnit unit) { if (command == null || unit == null) throw new NullPointerException(); if (delay < 0) delay = 0; long triggerTime = now() + unit.toNanos(delay); RunnableScheduledFuture t = decorateTask(command, new ScheduledFutureTask(command, null, triggerTime)); delayedExecute(t); return t; }
public boolean await(long timeout, TimeUnit unit) throws InterruptedException { int holdCount = lock.getHoldCount(); if (holdCount == 0) { throw new IllegalMonitorStateException(); } if (Thread.interrupted()) throw new InterruptedException(); long nanos = unit.toNanos(timeout); WaitQueue.WaitNode n = new WaitQueue.WaitNode(); wq.insert(n); boolean success = false; for (int i=holdCount; i>0; i--) lock.unlock(); try { success = n.doTimedWait(sync, nanos); } finally { for (int i=holdCount; i>0; i--) lock.lock(); } return success; }
public Object pollLast(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); long deadline = Utils.nanoTime() + nanos; lock.lockInterruptibly(); try { for (;;) { Object x = unlinkLast(); if (x != null) return x; if (nanos <= 0) return null; notEmpty.await(nanos, TimeUnit.NANOSECONDS); nanos = deadline - Utils.nanoTime(); } } finally { lock.unlock(); } }
public Object pollFirst(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); long deadline = Utils.nanoTime() + nanos; lock.lockInterruptibly(); try { for (;;) { Object x = unlinkFirst(); if (x != null) return x; if (nanos <= 0) return null; notEmpty.await(nanos, TimeUnit.NANOSECONDS); nanos = deadline - Utils.nanoTime(); } } finally { lock.unlock(); } }
public Object pollLast(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); long deadline = Utils.nanoTime() + nanos; lock.lockInterruptibly(); try { for (;;) { Object x = unlinkLast(); if (x != null) return x; if (nanos <= 0) return null; notEmpty.await(nanos, TimeUnit.NANOSECONDS); nanos = deadline - Utils.nanoTime(); } } finally { lock.unlock(); } }
public Object pollLast(long timeout, TimeUnit unit) throws InterruptedException { long nanos = unit.toNanos(timeout); long deadline = Utils.nanoTime() + nanos; lock.lockInterruptibly(); try { for (;;) { Object x = unlinkLast(); if (x != null) return x; if (nanos <= 0) return null; notEmpty.await(nanos, TimeUnit.NANOSECONDS); nanos = deadline - Utils.nanoTime(); } } finally { lock.unlock(); } }