@Override public void succeeded() { if (iterator instanceof Callback) ((Callback) iterator).succeeded(); }
@Override public void run() { long idleLeft = checkIdleTimeout(); if (idleLeft >= 0) scheduleIdleTimeout(idleLeft > 0 ? idleLeft : getIdleTimeout()); } };
@Override public boolean isNonBlocking() { return callback.isNonBlocking(); } }
private void scheduleIdleTimeout(long delay) { Scheduler.Future newTimeout = null; if (isOpen() && delay > 0 && scheduler != null) newTimeout = scheduler.schedule(idleTask, delay, TimeUnit.MILLISECONDS); Scheduler.Future oldTimeout = timeout.getAndSet(newTimeout); if (oldTimeout != null) oldTimeout.cancel(); }
@Override protected void destroy() { scheduler.stop(); } }
@Override public void failed(Throwable x) { promise.failed(x); } }
/** * @return whether this callback has failed */ public boolean isFailed() { try (Locker.Lock lock = _locker.lock()) { return _state == State.FAILED; } }
/** * The fixed sleep time. * * @param sleepTime The sleep time. * @param timeUnit The time unit. * @param <V> The return value type. * @return The wait strategy action. */ public static <V> Action1<TaskContext<V>> fixedWait(long sleepTime, TimeUnit timeUnit) { return ctx -> ThreadUtils.sleep(sleepTime, timeUnit); }
/** * Construct a leak detector. It helps you to track the resource leak. * * @param initialDelay The time to delay first execution * @param delay The delay between the termination of one * execution and the commencement of the next * @param unit The time unit of the initialDelay and delay parameters * @param noLeakCallback If not any resources leak, the detector will execute this action. */ public LeakDetector(long initialDelay, long delay, TimeUnit unit, Action0 noLeakCallback) { this(Schedulers.computation(), initialDelay, delay, unit, noLeakCallback); }
@Override public void failed(Throwable x) { completeExceptionally(x); } }
public Promise<W> unwrap() { Promise<W> result = promise; while (true) { if (result instanceof Wrapper) result = ((Wrapper<W>) result).unwrap(); else break; } return result; } }
private void scheduleIdleTimeout(long delay) { Scheduler.Future newTimeout = null; if (isOpen() && delay > 0 && scheduler != null) newTimeout = scheduler.schedule(idleTask, delay, TimeUnit.MILLISECONDS); Scheduler.Future oldTimeout = timeout.getAndSet(newTimeout); if (oldTimeout != null) oldTimeout.cancel(); }
@Override public void succeeded() { if (iterator instanceof Callback) ((Callback) iterator).succeeded(); }
@Override public void run() { long idleLeft = checkIdleTimeout(); if (idleLeft >= 0) scheduleIdleTimeout(idleLeft > 0 ? idleLeft : getIdleTimeout()); } };
/** * @return whether this callback has succeeded */ public boolean isSucceeded() { try (Locker.Lock lock = _locker.lock()) { return _state == State.SUCCEEDED; } }
private void scheduleIdleTimeout(long delay) { Scheduler.Future newTimeout = null; if (isOpen() && delay > 0 && scheduler != null) newTimeout = scheduler.schedule(idleTask, delay, TimeUnit.MILLISECONDS); Scheduler.Future oldTimeout = timeout.getAndSet(newTimeout); if (oldTimeout != null) oldTimeout.cancel(); }
/** * @return whether this callback has failed */ public boolean isFailed() { try (Locker.Lock lock = _locker.lock()) { return _state == State.FAILED; } }
/** * @return whether this callback has succeeded */ public boolean isSucceeded() { try (Locker.Lock lock = _locker.lock()) { return _state == State.SUCCEEDED; } }