コード例 #1
0
 void cancelResource() {
   Cancellation c = cancel;
   if (c != CANCELLED) {
     c = CANCEL.getAndSet(this, CANCELLED);
     if (c != null && c != CANCELLED) {
       requested = 0L;
       c.dispose();
     }
   }
 }
コード例 #2
0
ファイル: FluxBatch.java プロジェクト: reactor/reactor-core
    @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);
      }
    }
コード例 #3
0
 @Override
 public void setCancellation(Cancellation c) {
   if (!CANCEL.compareAndSet(this, null, c)) {
     if (cancel != CANCELLED && c != null) {
       c.dispose();
     }
   }
 }