void cancelResource() { Cancellation c = cancel; if (c != CANCELLED) { c = CANCEL.getAndSet(this, CANCELLED); if (c != null && c != CANCELLED) { requested = 0L; c.dispose(); } } }
@Override protected void doNext(final T value) { int index; for (; ; ) { index = this.index + 1; if (INDEX.compareAndSet(this, index - 1, index)) { break; } } if (index == 1) { timespanRegistration = timer.schedule(flushTask, timespan, TimeUnit.MILLISECONDS); if (first) { firstCallback(value); } } nextCallback(value); if (this.index % batchSize == 0) { this.index = 0; if (timespanRegistration != null) { timespanRegistration.dispose(); timespanRegistration = null; } flushCallback(value); } }
@Override public void setCancellation(Cancellation c) { if (!CANCEL.compareAndSet(this, null, c)) { if (cancel != CANCELLED && c != null) { c.dispose(); } } }