java.util.ArrayDeque.poll()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(5.1k)|赞(0)|评价(0)|浏览(206)

本文整理了Java中java.util.ArrayDeque.poll()方法的一些代码示例,展示了ArrayDeque.poll()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ArrayDeque.poll()方法的具体详情如下:
包路径:java.util.ArrayDeque
类名称:ArrayDeque
方法名:poll

ArrayDeque.poll介绍

[英]Retrieves and removes the head of the queue represented by this deque (in other words, the first element of this deque), or returns null if this deque is empty.

This method is equivalent to #pollFirst.
[中]检索并删除此deque表示的队列头(换句话说,此deque的第一个元素),如果此deque为空,则返回null。
此方法相当于#pollFirst。

代码示例

代码示例来源:origin: eclipse-vertx/vert.x

/**
 * Read the most recent element synchronously.
 * <p/>
 * No handler will be called.
 *
 * @return the most recent element or {@code null} if no element was in the buffer
 */
public E read() {
 synchronized (this) {
  return pending.poll();
 }
}

代码示例来源:origin: apache/flink

@Override
@Nullable
public BufferOrEvent getNext() {
  return queuedBuffers.poll();
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void onComplete() {
  final ArrayDeque<UnicastSubject<T>> ws = windows;
  while (!ws.isEmpty()) {
    ws.poll().onComplete();
  }
  downstream.onComplete();
}

代码示例来源:origin: ReactiveX/RxJava

@Override
  public void onComplete() {
    while (!buffers.isEmpty()) {
      downstream.onNext(buffers.poll());
    }
    downstream.onComplete();
  }
}

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public void onSettingsAckRead(ChannelHandlerContext ctx) {
 Handler<Void> handler;
 synchronized (this) {
  handler = updateSettingsHandlers.poll();
 }
 if (handler != null) {
  // No need to run on a particular context it shall be done by the handler instead
  context.executeFromIO(handler);
 }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void onError(Throwable t) {
  final ArrayDeque<UnicastSubject<T>> ws = windows;
  while (!ws.isEmpty()) {
    ws.poll().onError(t);
  }
  downstream.onError(t);
}

代码示例来源:origin: ReactiveX/RxJava

void disposeAll() {
  InnerQueuedObserver<R> inner = current;
  if (inner != null) {
    inner.dispose();
  }
  for (;;) {
    inner = observers.poll();
    if (inner == null) {
      return;
    }
    inner.dispose();
  }
}

代码示例来源:origin: eclipse-vertx/vert.x

@Override
public void onPingAckRead(ChannelHandlerContext ctx, long data) throws Http2Exception {
 Handler<AsyncResult<Buffer>> handler = pongHandlers.poll();
 if (handler != null) {
  context.executeFromIO(v -> {
   Buffer buff = Buffer.buffer().appendLong(data);
   handler.handle(Future.succeededFuture(buff));
  });
 }
}

代码示例来源:origin: apache/flink

@Override
public AsyncResult poll() throws InterruptedException {
  lock.lockInterruptibly();
  try {
    while (queue.isEmpty() || !queue.peek().isDone()) {
      headIsCompleted.await();
    }
    notFull.signalAll();
    LOG.debug("Polled head element from ordered stream element queue. New filling degree " +
      "({}/{}).", queue.size() - 1, capacity);
    return queue.poll();
  } finally {
    lock.unlock();
  }
}

代码示例来源:origin: netty/netty

/**
 * Remove the first {@link ByteBuf} from the queue.
 * @param aggregatePromise used to aggregate the promises and listeners for the returned buffer.
 * @return the first {@link ByteBuf} from the queue.
 */
public final ByteBuf removeFirst(ChannelPromise aggregatePromise) {
  Object entry = bufAndListenerPairs.poll();
  if (entry == null) {
    return null;
  }
  assert entry instanceof ByteBuf;
  ByteBuf result = (ByteBuf) entry;
  decrementReadableBytes(result.readableBytes());
  entry = bufAndListenerPairs.peek();
  if (entry instanceof ChannelFutureListener) {
    aggregatePromise.addListener((ChannelFutureListener) entry);
    bufAndListenerPairs.poll();
  }
  return result;
}

代码示例来源:origin: redisson/redisson

@Override
  public void onComplete() {
    while (!buffers.isEmpty()) {
      actual.onNext(buffers.poll());
    }
    actual.onComplete();
  }
}

代码示例来源:origin: redisson/redisson

@Override
public void onComplete() {
  final ArrayDeque<UnicastSubject<T>> ws = windows;
  while (!ws.isEmpty()) {
    ws.poll().onComplete();
  }
  actual.onComplete();
}

代码示例来源:origin: redisson/redisson

@Override
public void onError(Throwable t) {
  final ArrayDeque<UnicastSubject<T>> ws = windows;
  while (!ws.isEmpty()) {
    ws.poll().onError(t);
  }
  actual.onError(t);
}

代码示例来源:origin: redisson/redisson

void disposeAll() {
  InnerQueuedObserver<R> inner = current;
  if (inner != null) {
    inner.dispose();
  }
  for (;;) {
    inner = observers.poll();
    if (inner == null) {
      return;
    }
    inner.dispose();
  }
}

代码示例来源:origin: ReactiveX/RxJava

@Override
public void onNext(T t) {
  final ArrayDeque<UnicastSubject<T>> ws = windows;
  long i = index;
  long s = skip;
  if (i % s == 0 && !cancelled) {
    wip.getAndIncrement();
    UnicastSubject<T> w = UnicastSubject.create(capacityHint, this);
    ws.offer(w);
    downstream.onNext(w);
  }
  long c = firstEmission + 1;
  for (UnicastSubject<T> w : ws) {
    w.onNext(t);
  }
  if (c >= count) {
    ws.poll().onComplete();
    if (ws.isEmpty() && cancelled) {
      this.upstream.dispose();
      return;
    }
    firstEmission = c - s;
  } else {
    firstEmission = c;
  }
  index = i + 1;
}

代码示例来源:origin: apache/flink

@Override
public HashMap<KafkaTopicPartition, Long> snapshotCurrentState() {
  checkState(!stateSnapshotsToReturn.isEmpty());
  return stateSnapshotsToReturn.poll();
}

代码示例来源:origin: apache/flink

@Override
public void close() {
  BufferOrEvent boe;
  while ((boe = currentBuffers.poll()) != null) {
    if (boe.isBuffer()) {
      boe.getBuffer().recycleBuffer();
    }
  }
}

代码示例来源:origin: apache/flink

@Override
public void cleanup() {
  BufferOrEvent boe;
  while ((boe = queuedBuffers.poll()) != null) {
    if (boe.isBuffer()) {
      boe.getBuffer().recycleBuffer();
    }
  }
}

代码示例来源:origin: ReactiveX/RxJava

bs.poll();

代码示例来源:origin: ReactiveX/RxJava

produced = p - skip;
Processor<T, T> w = windows.poll();
if (w != null) {
  w.onComplete();

相关文章