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

x33g5p2x  于2022-01-17 转载在 其他  
字(5.2k)|赞(0)|评价(0)|浏览(627)

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

Deque.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: SonarSource/sonarqube

/**
 * Retrieves and removes token from this queue.
 * 
 * @return token from this queue, or <tt>null</tt> if this queue is empty.
 */
public Token poll() {
 return tokenQueue.poll();
}

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

break;
case DROP_OLDEST:
  dq.poll();
  dq.offer(t);
  callOnOverflow = true;

代码示例来源:origin: google/guava

create().offer("foo");
create().peek();
create().poll();
create().remove();
create().add("foo");

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

/**
 * @return Pop a Handler instance if one available ready-to-go or else return null.
 */
private FastPathHandler popReadyHandler() {
 return this.fastPathHandlerStack.poll();
}

代码示例来源:origin: k9mail/k-9

private ImapConnection pollConnection() {
  synchronized (connections) {
    return connections.poll();
  }
}

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

private synchronized byte doRead() {
  // if we are here we passed all the validation, so there must be something to read
  ByteBuffer headBuffer = data.peek();
  byte b = headBuffer.get();
  if (!headBuffer.hasRemaining()) {
    // remove empty buffer
    data.poll();
  }
  return b;
}

代码示例来源:origin: btraceio/btrace

public static <V> V poll(Deque<V> queue) {
  if (queue instanceof BTraceDeque || queue.getClass().getClassLoader() == null) {
    return queue.poll();
  } else {
    throw new IllegalArgumentException();
  }
}

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

public synchronized DnsMessage pollMessage() {
 return currentMessage.poll();
}

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

/**
 * Handle connect failures, the first waiter is always failed to avoid infinite reconnection.
 */
private void connectFailed(Holder holder, Throwable cause) {
 Waiter<C> waiter;
 synchronized (this) {
  connecting--;
  waiter = waitersQueue.poll();
  weight -= initialWeight;
  holder.removed = true;
  checkProgress();
 }
 if (waiter != null) {
  waiter.handler.handle(Future.failedFuture(cause));
 }
}

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

/**
 * Closes this buffer, releasing all {@link #offer(long)} values into the {@link Consumer}.
 *
 * This class is typically not used in a scenario suitable for try-with-resource
 * and so having it implement AutoCloseable would be more annoying
 */
public synchronized void close()
{
  flush();
  while ( !chunks.isEmpty() )
  {
    chunkConsumer.accept( chunks.poll().values );
  }
}

代码示例来源:origin: google/guava

@Override
public E poll() {
 assertTrue(Thread.holdsLock(mutex));
 return delegate.poll();
}

代码示例来源:origin: CalebFenton/simplify

@Override
public ExecutionNode next() {
  ExecutionNode result = stack.poll();
  stack.addAll(result.getChildren());
  return result;
}

代码示例来源:origin: btraceio/btrace

@Override
public void visitTableSwitchInsn(int i, int i1, Label label, Label ...labels) {
  simulatedStack.poll();
  if (copyEnabled) {
    super.visitTableSwitchInsn(i, i1, label, labels);
  }
}

代码示例来源:origin: btraceio/btrace

@Override
public void visitLookupSwitchInsn(Label label, int[] ints, Label[] labels) {
  simulatedStack.poll();
  if (copyEnabled) {
    super.visitLookupSwitchInsn(label, ints, labels);
  }
}

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

/** {@inheritDoc} */
@Override public E poll() {
  E res = deque.poll();
  if (res != null)
    adder.decrement();
  return res;
}

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

@Override
public void run(SourceContext<Long> ctx) throws Exception {
  while (isRunning && !this.valuesToEmit.isEmpty()) {
    synchronized (ctx.getCheckpointLock()) {
      ctx.collect(this.valuesToEmit.poll());
    }
  }
}

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

private void addToCompletedReceives(KafkaChannel channel, Deque<NetworkReceive> stagedDeque) {
  NetworkReceive networkReceive = stagedDeque.poll();
  this.completedReceives.add(networkReceive);
  this.sensors.recordBytesReceived(channel.id(), networkReceive.size());
}

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

/**
 * Get a list of batches which have been sitting in the accumulator too long and need to be expired.
 */
public List<ProducerBatch> expiredBatches(long now) {
  List<ProducerBatch> expiredBatches = new ArrayList<>();
  for (Map.Entry<TopicPartition, Deque<ProducerBatch>> entry : this.batches.entrySet()) {
    // expire the batches in the order of sending
    Deque<ProducerBatch> deque = entry.getValue();
    synchronized (deque) {
      while (!deque.isEmpty()) {
        ProducerBatch batch = deque.getFirst();
        if (batch.hasReachedDeliveryTimeout(deliveryTimeoutMs, now)) {
          deque.poll();
          batch.abortRecordAppends();
          expiredBatches.add(batch);
        } else {
          maybeUpdateNextBatchExpiryTime(batch);
          break;
        }
      }
    }
  }
  return expiredBatches;
}

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

FakeConnection assertRequest() {
 waitUntil(() -> pendingRequests.size() > 0);
 FakeConnection request = pendingRequests.poll();
 assertNotNull(request);
 return request;
}

代码示例来源:origin: prestodb/presto

private ListenableFuture<?> loadSplits()
    throws IOException
{
  Iterator<InternalHiveSplit> splits = fileIterators.poll();
  if (splits == null) {
    HivePartitionMetadata partition = partitions.poll();
    if (partition == null) {
      return COMPLETED_FUTURE;
    }
    return loadPartition(partition);
  }
  while (splits.hasNext() && !stopped) {
    ListenableFuture<?> future = hiveSplitSource.addToQueue(splits.next());
    if (!future.isDone()) {
      fileIterators.addFirst(splits);
      return future;
    }
  }
  // No need to put the iterator back, since it's either empty or we've stopped
  return COMPLETED_FUTURE;
}

相关文章