@Override public AsyncResult peekBlockingly() throws InterruptedException { lock.lockInterruptibly(); try { while (completedQueue.isEmpty()) { hasCompletedEntries.await(); } LOG.debug("Peeked head element from unordered stream element queue with filling degree " + "({}/{}).", numberEntries, capacity); return completedQueue.peek(); } finally { lock.unlock(); } }
@Override public AsyncResult peekBlockingly() throws InterruptedException { lock.lockInterruptibly(); try { while (queue.isEmpty() || !queue.peek().isDone()) { headIsCompleted.await(); } LOG.debug("Peeked head element from ordered stream element queue with filling degree " + "({}/{}).", queue.size(), capacity); return queue.peek(); } finally { lock.unlock(); } }
public String getNdc() { ArrayDeque<Entry> stack = ndcStack.get(); return stack == null || stack.isEmpty() ? null : stack.peek().merged; }
public String peekNdc() { ArrayDeque<Entry> stack = ndcStack.get(); return stack == null || stack.isEmpty() ? "" : stack.peek().current; }
@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(); } }
/** * Check if the completed {@link StreamElementQueueEntry} is the current head. If this is the * case, then notify the consumer thread about a new consumable entry. * * @param streamElementQueueEntry which has been completed * @throws InterruptedException if the current thread is interrupted */ private void onCompleteHandler(StreamElementQueueEntry<?> streamElementQueueEntry) throws InterruptedException { lock.lockInterruptibly(); try { if (!queue.isEmpty() && queue.peek().isDone()) { LOG.debug("Signal ordered stream element queue has completed head element."); headIsCompleted.signalAll(); } } finally { lock.unlock(); } } }
/** * 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; }
private void processAtomEnded(long atomEndPosition) throws ParserException { while (!containerAtoms.isEmpty() && containerAtoms.peek().endPosition == atomEndPosition) { onContainerAtomRead(containerAtoms.pop()); } enterReadingAtomHeaderState(); }
public void pushNdc(String message) { ArrayDeque<Entry> stack = ndcStack.get(); if (stack == null) { stack = new ArrayDeque<Entry>(); ndcStack.set(stack); } stack.push(stack.isEmpty() ? new Entry(message) : new Entry(stack.peek(), message)); }
/** * 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; }
private void processAtomEnded(long atomEndPosition) throws ParserException { while (!containerAtoms.isEmpty() && containerAtoms.peek().endPosition == atomEndPosition) { Atom.ContainerAtom containerAtom = containerAtoms.pop(); if (containerAtom.type == Atom.TYPE_moov) { // We've reached the end of the moov atom. Process it and prepare to read samples. processMoovAtom(containerAtom); containerAtoms.clear(); parserState = STATE_READING_SAMPLE; } else if (!containerAtoms.isEmpty()) { containerAtoms.peek().add(containerAtom); } } if (parserState != STATE_READING_SAMPLE) { enterReadingAtomHeaderState(); } }
private void onContainerAtomRead(ContainerAtom container) throws ParserException { if (container.type == Atom.TYPE_moov) { onMoovContainerAtomRead(container); } else if (container.type == Atom.TYPE_moof) { onMoofContainerAtomRead(container); } else if (!containerAtoms.isEmpty()) { containerAtoms.peek().add(container); } }
C b = bs.peek();
/** * 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; }
private void onLeafAtomRead(LeafAtom leaf, long inputPosition) throws ParserException { if (!containerAtoms.isEmpty()) { containerAtoms.peek().add(leaf); } else if (leaf.type == Atom.TYPE_sidx) { Pair<Long, ChunkIndex> result = parseSidx(leaf.data, inputPosition); segmentIndexEarliestPresentationTimeUs = result.first; extractorOutput.seekMap(result.second); haveOutputSeekMap = true; } else if (leaf.type == Atom.TYPE_emsg) { onEmsgLeafAtomRead(leaf.data); } }
C b = bs.peek();
@Override public void exitIdentifier(RuleLangParser.IdentifierContext ctx) { // unquote identifier if necessary final String identifierName = unquote(ctx.Identifier().getText(), '`'); if (!isIdIsFieldAccess.peek() && !definedVars.contains(identifierName)) { parseContext.addError(new UndeclaredVariable(ctx)); } final Expression expr; String type; // if the identifier is also a declared variable name prefer the variable if (isIdIsFieldAccess.peek() && !definedVars.contains(identifierName)) { expr = new FieldRefExpression(ctx.getStart(), identifierName, parseContext.getDefinedVar(identifierName)); type = "FIELDREF"; } else { expr = new VarRefExpression(ctx.getStart(), identifierName, parseContext.getDefinedVar(identifierName)); type = "VARREF"; } log.trace("{}: ctx {} => {}", type, ctx, expr); exprs.put(ctx, expr); }
/** * Processes the atom payload. If {@link #atomData} is null and the size is at or above the * threshold {@link #RELOAD_MINIMUM_SEEK_DISTANCE}, {@code true} is returned and the caller should * restart loading at the position in {@code positionHolder}. Otherwise, the atom is read/skipped. */ private boolean readAtomPayload(ExtractorInput input, PositionHolder positionHolder) throws IOException, InterruptedException { long atomPayloadSize = atomSize - atomHeaderBytesRead; long atomEndPosition = input.getPosition() + atomPayloadSize; boolean seekRequired = false; if (atomData != null) { input.readFully(atomData.data, atomHeaderBytesRead, (int) atomPayloadSize); if (atomType == Atom.TYPE_ftyp) { isQuickTime = processFtypAtom(atomData); } else if (!containerAtoms.isEmpty()) { containerAtoms.peek().add(new Atom.LeafAtom(atomType, atomData)); } } else { // We don't need the data. Skip or seek, depending on how large the atom is. if (atomPayloadSize < RELOAD_MINIMUM_SEEK_DISTANCE) { input.skipFully((int) atomPayloadSize); } else { positionHolder.position = input.getPosition() + atomPayloadSize; seekRequired = true; } } processAtomEnded(atomEndPosition); return seekRequired && parserState != STATE_READING_SAMPLE; }
private TerminalAutoCompleteMatches traverseArguments(TerminalCommand command, TerminalAutoCompleteMatches matches, ArrayDeque<String> inputArguments) { if (command.getArguments() != null) { for (TerminalCommand argument : command.getArguments()) { if (!inputArguments.isEmpty()) { String inputArgument = inputArguments.peek(); if (isPartialMatch(argument, inputArgument)) { if (isExactMatch(argument, inputArgument) && argument.hasArguments()) { matches.extendBaseCommand(argument); inputArguments.removeFirst(); return traverseArguments(argument, matches, inputArguments); } matches.addMatch(argument); } } else { matches.addMatch(argument); } } } return matches; }
endPosition = containerAtoms.peek().endPosition;