@Override public int drainTo(Collection<? super E> c) { return delegate().drainTo(c); }
@Override public int drainTo(Collection<? super E> c, int maxElements) { return delegate().drainTo(c, maxElements); }
@Override public int drainTo(Collection<? super E> c) { return delegate().drainTo(c); }
@Override public int drainTo(Collection<? super E> c, int maxElements) { return delegate().drainTo(c, maxElements); }
private void processPendingConnections() { if (!newClients.isEmpty()) { List<NetClient> newPlayers = Lists.newArrayListWithExpectedSize(newClients.size()); newClients.drainTo(newPlayers); newPlayers.forEach(this::processNewClient); } }
private void processPendingDisconnects() { if (!disconnectedClients.isEmpty()) { List<NetClient> removedPlayers = Lists.newArrayListWithExpectedSize(disconnectedClients.size()); disconnectedClients.drainTo(removedPlayers); removedPlayers.forEach(this::processRemovedClient); } }
@Override public void release() { released = true; final List<MemoryBlock> blocks = new ArrayList<>(); for ( final BlockingQueue<MemoryBlock> cache : caches ) { cache.drainTo( blocks ); blocks.forEach( block -> UnsafeUtil.free( block.unalignedAddr, block.unalignedSize ) ); blocks.clear(); } }
@Override public int drainTo(Collection<? super E> c) { return delegate().drainTo(c); }
@Override public int drainTo(Collection<? super E> c, int maxElements) { return delegate().drainTo(c, maxElements); }
@Override public void update() { if (!reloadQueue.isEmpty()) { List<BlockTile> reloadList = Lists.newArrayListWithExpectedSize(reloadQueue.size()); reloadQueue.drainTo(reloadList); // TODO: does this need to be more efficient? could just reload individual block tile locations. buildAtlas(); } }
private void processReceivedChunks() { if (remoteWorldProvider != null) { List<Chunk> chunks = Lists.newArrayListWithExpectedSize(chunkQueue.size()); chunkQueue.drainTo(chunks); for (Chunk chunk : chunks) { remoteWorldProvider.receiveChunk(chunk); } } }
added += q.drainTo(buffer, numElements - added); if (added < numElements) { // not enough elements immediately available; will have to poll E e = q.poll(deadline - System.nanoTime(), TimeUnit.NANOSECONDS);
public void close() { checkNotHoldsLock(); List<PageReference> remainingPages = new ArrayList<>(); SettableFuture<?> notEmptyFuture; synchronized (lock) { finishing = true; buffer.drainTo(remainingPages); bufferedBytes.addAndGet(-remainingPages.stream().mapToLong(PageReference::getRetainedSizeInBytes).sum()); notEmptyFuture = this.notEmptyFuture; this.notEmptyFuture = NOT_EMPTY; } // free all the remaining pages remainingPages.forEach(PageReference::removePage); // notify readers outside of lock since this may result in a callback notEmptyFuture.set(null); // this will always fire the finished event checkState(isFinished(), "Expected buffer to be finished"); checkFinished(); }
@Override public Boolean call() { while (!stopTest.get()) { q.drainTo(new ArrayList<>(), Integer.MAX_VALUE); } return true; } }
private void processReceivedMessages() { List<NetData.NetMessage> messages = Lists.newArrayListWithExpectedSize(queuedIncomingMessage.size()); queuedIncomingMessage.drainTo(messages); for (NetData.NetMessage message : messages) { if (message.hasTime() && message.getTime() > lastReceivedTime) { lastReceivedTime = message.getTime(); } processEntityUpdates(message); processEvents(message); } }
private void deactivateBlocks() { List<TShortObjectMap<TIntList>> deactivatedBlockSets = Lists.newArrayListWithExpectedSize(deactivateBlocksQueue.size()); deactivateBlocksQueue.drainTo(deactivatedBlockSets); for (TShortObjectMap<TIntList> deactivatedBlockSet : deactivatedBlockSets) { deactivatedBlockSet.forEachEntry((id, positions) -> { if (positions.size() > 0) { blockManager.getBlock(id).getEntity().send(new BeforeDeactivateBlocks(positions, registry)); } return true; }); } }
/** * drainTo(null) throws NullPointerException */ public void testDrainToNull() { final BlockingQueue q = emptyCollection(); try { q.drainTo(null); shouldThrow(); } catch (NullPointerException success) {} }
/** * drainTo(this, n) throws IllegalArgumentException */ public void testDrainToSelfN() { final BlockingQueue q = emptyCollection(); try { q.drainTo(q, 0); shouldThrow(); } catch (IllegalArgumentException success) {} }
/** * drainTo(this) throws IllegalArgumentException */ public void testDrainToSelf() { final BlockingQueue q = emptyCollection(); try { q.drainTo(q); shouldThrow(); } catch (IllegalArgumentException success) {} }
/** * drainTo(null, n) throws NullPointerException */ public void testDrainToNullN() { final BlockingQueue q = emptyCollection(); try { q.drainTo(null, 0); shouldThrow(); } catch (NullPointerException success) {} }