/** * Removes all of the elements from this deque. */ public void clear() { while (pollFirst() != null) ; }
public E poll() { return pollFirst(); } public E remove() { return removeFirst(); }
private Batch pollBatchFromEmitQueue() { Batch result = buffersToEmit.pollFirst(); if (result == null) { return null; } approximateBuffersToEmitCount.decrementAndGet(); approximateEventsToEmitCount.addAndGet(-result.eventCount.get()); return result; }
/** {@inheritDoc} */ @Override public long takeRecycledPage() throws IgniteCheckedException { Long pageId = deque.pollFirst(); return pageId == null ? 0L : pageId; }
/** * @throws NoSuchElementException {@inheritDoc} */ public E removeFirst() { return screenNullResult(pollFirst()); }
ActorEntry<T> tryPop() { while (true) { final ActorEntry<T> actorEntry = activations.pollFirst(); if (actorEntry == null) { return null; } // ignore deactivated entries if (!actorEntry.isDeactivated()) { return actorEntry; } } }
private void limitBuffersToEmitSize() { if (approximateBuffersToEmitCount.get() >= config.getBatchQueueSizeLimit()) { Batch droppedBatch = buffersToEmit.pollFirst(); if (droppedBatch != null) { batchFinalized(); approximateBuffersToEmitCount.decrementAndGet(); approximateEventsToEmitCount.addAndGet(-droppedBatch.eventCount.get()); droppedBuffers.incrementAndGet(); log.error( "buffersToEmit queue size reached the limit [%d], dropping the oldest buffer to emit", config.getBatchQueueSizeLimit() ); } } }
/** * Process all the responses for this connection * @return true if all the calls were processed or that someone else is doing it. false if there * * is still some work to do. In this case, we expect the caller to delay us. * @throws IOException */ private boolean processAllResponses(final SimpleServerRpcConnection connection) throws IOException { // We want only one writer on the channel for a connection at a time. connection.responseWriteLock.lock(); try { for (int i = 0; i < 20; i++) { // protection if some handlers manage to need all the responder RpcResponse resp = connection.responseQueue.pollFirst(); if (resp == null) { return true; } if (!processResponse(connection, resp)) { connection.responseQueue.addFirst(resp); return false; } } } finally { connection.responseWriteLock.unlock(); } return connection.responseQueue.isEmpty(); }
@Override public void doStop() throws Exception { if (_lease!=null) _lease.close(); while(true) { ReservedThread thread = _stack.pollFirst(); if (thread == null) break; _size.decrementAndGet(); thread.stop(); } super.doStop(); }
/** * @param task The task to run * @return True iff a reserved thread was available and has been assigned the task to run. */ @Override public boolean tryExecute(Runnable task) { if (LOG.isDebugEnabled()) LOG.debug("{} tryExecute {}",this ,task); if (task==null) return false; ReservedThread thread = _stack.pollFirst(); if (thread==null) { if (task!=STOP) startReservedThread(); return false; } int size = _size.decrementAndGet(); thread.offer(task); if (size==0 && task!=STOP) startReservedThread(); return true; }
/** * Removes all of the elements from this deque. */ public void clear() { while (pollFirst() != null) ; }
/** * Removes all of the elements from this deque. */ public void clear() { while (pollFirst() != null) ; }
/** * Removes all of the elements from this deque. */ public void clear() { while (pollFirst() != null) ; }
/** * Removes all of the elements from this deque. */ public void clear() { while (pollFirst() != null) ; }
void handlePong() { CompletableFuture<Boolean> pongFuture = pongQueue.pollFirst(); if (pongFuture != null) { pongFuture.complete(Boolean.TRUE); } }
/** * @throws NoSuchElementException {@inheritDoc} */ public E removeFirst() { return screenNullResult(pollFirst()); }
/** * @throws NoSuchElementException {@inheritDoc} */ public E removeFirst() { return screenNullResult(pollFirst()); }
@Override public void record(final Event event) { _events.push(event); final int events = _eventsCount.incrementAndGet(); if (events > _bufferSize) { _events.pollFirst(); } }
/** * @throws NoSuchElementException {@inheritDoc} */ public E removeFirst() { return screenNullResult(pollFirst()); }