@Override public void dispose() { if (terminated) { return; } terminated = true; final Queue<ExecutorTrackedRunnable> q = queue; ExecutorTrackedRunnable r; while ((r = q.poll()) != null && !q.isEmpty()) { r.dispose(); } }
@Override public Disposable schedule(Runnable task) { Objects.requireNonNull(task, "task"); if (terminated) { throw Exceptions.failWithRejected(); } ExecutorTrackedRunnable r = new ExecutorTrackedRunnable(task, this, false); synchronized (this) { if (terminated) { throw Exceptions.failWithRejected(); } queue.offer(r); } if (WIP.getAndIncrement(this) == 0) { try { executor.execute(this); } catch (Throwable ex) { r.dispose(); Schedulers.handleError(ex); throw Exceptions.failWithRejected(ex); } } return r; }
@Override public void run() { if (!get()) { try { task.run(); } catch (Throwable ex) { Schedulers.handleError(ex); } finally { if (callRemoveOnFinish) { dispose(); } else { lazySet(true); } } } }
@Override public Disposable schedule(Runnable task) { Objects.requireNonNull(task, "task"); if (terminated) { throw Exceptions.failWithRejected(); } ExecutorTrackedRunnable r = new ExecutorTrackedRunnable(task, this, false); synchronized (this) { if (terminated) { throw Exceptions.failWithRejected(); } queue.offer(r); } if (WIP.getAndIncrement(this) == 0) { try { executor.execute(this); } catch (Throwable ex) { r.dispose(); Schedulers.handleError(ex); throw Exceptions.failWithRejected(ex); } } return r; }
@Override public void run() { if (!get()) { try { task.run(); } catch (Throwable ex) { Schedulers.handleError(ex); } finally { if (callRemoveOnFinish) { dispose(); } else { lazySet(true); } } } }
@Override public void dispose() { if (terminated) { return; } terminated = true; final Queue<ExecutorTrackedRunnable> q = queue; ExecutorTrackedRunnable r; while ((r = q.poll()) != null && !q.isEmpty()) { r.dispose(); } }