Java Code Examples for java.util.concurrent.ConcurrentLinkedDeque#pollFirst()
The following examples show how to use
java.util.concurrent.ConcurrentLinkedDeque#pollFirst() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SimpleLifoPool.java From reactor-pool with Apache License 2.0 | 5 votes |
@Override Borrower<POOLABLE> pendingPoll() { ConcurrentLinkedDeque<Borrower<POOLABLE>> q = this.pending; Borrower<POOLABLE> b = q.pollFirst(); if (b != null) PENDING_COUNT.decrementAndGet(this); return b; }
Example 2
Source File: ConcurrentSizeBoundedQueue.java From buffer-slayer with Apache License 2.0 | 5 votes |
private static List<MessagePromise<?>> removeAll(ConcurrentLinkedDeque<MessagePromise<?>> deque) { final List<MessagePromise<?>> result = new LinkedList<>(); MessagePromise<?> promise; while ((promise = deque.pollFirst()) != null) { result.add(promise); } return result; }
Example 3
Source File: RdmaChannel.java From SparkRDMA with Apache License 2.0 | 4 votes |
private void rdmaPostWRList(LinkedList<IbvSendWR> sendWRList) throws IOException { if (isError() || isStopped.get()) { throw new IOException("QP is in error state, can't post new requests"); } ConcurrentLinkedDeque<SVCPostSend> stack; SVCPostSend svcPostSendObject; int numWrElements = sendWRList.size(); // Special case for 0 sgeElements when rdmaSendWithImm if (sendWRList.size() == 1 && sendWRList.getFirst().getNum_sge() == 0) { numWrElements = NOOP_RESERVED_INDEX; } stack = svcPostSendCache.computeIfAbsent(numWrElements, numElements -> new ConcurrentLinkedDeque<>()); // To avoid buffer allocations in disni update cached SVCPostSendObject if (sendWRList.getFirst().getOpcode() == IbvSendWR.IbvWrOcode.IBV_WR_RDMA_READ.ordinal() && (svcPostSendObject = stack.pollFirst()) != null) { int i = 0; for (IbvSendWR sendWr: sendWRList) { SVCPostSend.SendWRMod sendWrMod = svcPostSendObject.getWrMod(i); sendWrMod.setWr_id(sendWr.getWr_id()); sendWrMod.setSend_flags(sendWr.getSend_flags()); // Setting up RDMA attributes sendWrMod.getRdmaMod().setRemote_addr(sendWr.getRdma().getRemote_addr()); sendWrMod.getRdmaMod().setRkey(sendWr.getRdma().getRkey()); sendWrMod.getRdmaMod().setReserved(sendWr.getRdma().getReserved()); if (sendWr.getNum_sge() == 1) { IbvSge sge = sendWr.getSge(0); sendWrMod.getSgeMod(0).setLkey(sge.getLkey()); sendWrMod.getSgeMod(0).setAddr(sge.getAddr()); sendWrMod.getSgeMod(0).setLength(sge.getLength()); } i++; } } else { svcPostSendObject = qp.postSend(sendWRList, null); } svcPostSendObject.execute(); // Cache SVCPostSend objects only for RDMA Read requests if (sendWRList.getFirst().getOpcode() == IbvSendWR.IbvWrOcode.IBV_WR_RDMA_READ.ordinal()) { stack.add(svcPostSendObject); } else { svcPostSendObject.free(); } }