/** * Inserts the specified element at the front of this deque. * * @param e the element to add * @return <tt>true</tt> (as specified by {@link Deque#offerFirst}) * @throws NullPointerException if the specified element is null */ public boolean offerFirst(E e) { addFirst(e); return true; }
/** * Pushes an element onto the stack represented by this deque. In other * words, inserts the element at the front of this deque. * * <p>This method is equivalent to {@link #addFirst}. * * @param e the element to push * @throws NullPointerException if the specified element is null */ public void push(E e) { addFirst(e); }
/** {@inheritDoc} */ @Override public void addFirst(E e) { boolean contains, first = false; if ((contains = items.contains(e)) && !(first = getFirst().equals(e))) remove(e); if (!contains) items.add(e); if (!first) super.addFirst(e); }
private void pushToStack(ExpandingFetchSource fetchSource) { log.trace( "Pushing fetch source to stack : " + fetchSource ); propertyPathStack.push( fetchSource.getPropertyPath() ); fetchSourceStack.addFirst( fetchSource ); }
private void pushToCollectionStack(CollectionReference collectionReference) { log.trace( "Pushing collection reference to stack : " + collectionReference ); propertyPathStack.push( collectionReference.getPropertyPath() ); collectionReferenceStack.addFirst( collectionReference ); }
childPartition.addFirst(value); partitionValues.add(childPartition);
public void push(PropertyPath path) { pathStack.addFirst( path ); MDC.put( MDC_KEY, extractFullPath( path ) ); }
private void sendAllValid(final ChannelHandlerContext ctx, final PerChannel perChannel, final long now) { // write operations need synchronization synchronized (perChannel) { ToSend newToSend = perChannel.messagesQueue.pollFirst(); for (; newToSend != null; newToSend = perChannel.messagesQueue.pollFirst()) { if (newToSend.relativeTimeAction <= now) { long size = newToSend.size; trafficCounter.bytesRealWriteFlowControl(size); perChannel.queueSize -= size; queuesSize.addAndGet(-size); ctx.write(newToSend.toSend, newToSend.promise); perChannel.lastWriteTimestamp = now; } else { perChannel.messagesQueue.addFirst(newToSend); break; } } if (perChannel.messagesQueue.isEmpty()) { releaseWriteSuspended(ctx); } } ctx.flush(); } }
private void sendAllValid(final ChannelHandlerContext ctx, final PerChannel perChannel, final long now) { // write operations need synchronization synchronized (perChannel) { ToSend newToSend = perChannel.messagesQueue.pollFirst(); for (; newToSend != null; newToSend = perChannel.messagesQueue.pollFirst()) { if (newToSend.relativeTimeAction <= now) { long size = newToSend.size; trafficCounter.bytesRealWriteFlowControl(size); perChannel.channelTrafficCounter.bytesRealWriteFlowControl(size); perChannel.queueSize -= size; queuesSize.addAndGet(-size); ctx.write(newToSend.toSend, newToSend.promise); perChannel.lastWriteTimestamp = now; } else { perChannel.messagesQueue.addFirst(newToSend); break; } } if (perChannel.messagesQueue.isEmpty()) { releaseWriteSuspended(ctx); } } ctx.flush(); }
private void sendAllValid(final ChannelHandlerContext ctx, final long now) { // write order control synchronized (this) { ToSend newToSend = messagesQueue.pollFirst(); for (; newToSend != null; newToSend = messagesQueue.pollFirst()) { if (newToSend.relativeTimeAction <= now) { long size = calculateSize(newToSend.toSend); trafficCounter.bytesRealWriteFlowControl(size); queueSize -= size; ctx.write(newToSend.toSend, newToSend.promise); } else { messagesQueue.addFirst(newToSend); break; } } if (messagesQueue.isEmpty()) { releaseWriteSuspended(ctx); } } ctx.flush(); }
@Override public Stream<T> apply(Stream<T> stream) { final Iterator<? extends T> iterator = stream.iterator(); final ArrayDeque<T> deque = new ArrayDeque<T>(); while (iterator.hasNext()) { deque.addFirst(iterator.next()); } return Stream.of(deque.iterator()); } }
/** * @see io.netty.channel.ChannelInboundHandlerAdapter#userEventTriggered(io.netty.channel.ChannelHandlerContext, Object) */ @Override public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception { if (evt == EnableAutoRead.INSTANCE) { channel.config().setAutoRead(true); } else if (evt instanceof Reset) { reset(); } else if (evt instanceof PingBeforeActivate) { PingBeforeActivate pba = (PingBeforeActivate) evt; stack.addFirst(pba.getCommand()); ctx.writeAndFlush(pba.getCommand()); return; } super.userEventTriggered(ctx, evt); }
/** * Returns the {@link Tracer#nextSpan()} or null if {@link #CURRENT_TRACER} and tracing isn't * available. */ @Nullable public Span next() { Tracer tracer = tracer(); if (tracer == null) return null; Span next = tracer.nextSpan(); Object[] spanAndScope = {next, tracer.withSpanInScope(next)}; getCurrentSpanInScopeStack().addFirst(spanAndScope); return next; }
/** * Returns the {@link Tracer#nextSpan(TraceContextOrSamplingFlags)} or null if {@link * #CURRENT_TRACER} and tracing isn't available. */ @Nullable public Span next(TraceContextOrSamplingFlags extracted) { Tracer tracer = tracer(); if (tracer == null) return null; Span next = tracer.nextSpan(extracted); Object[] spanAndScope = {next, tracer.withSpanInScope(next)}; getCurrentSpanInScopeStack().addFirst(spanAndScope); return next; }
if (entryBuffer.readableBytes() > bytes) { bufAndListenerPairs.addFirst(entryBuffer); if (bytes > 0) {
public void putFirstOverflow(Integer eventCount) { if ((queue.peekFirst() == null) || queue.getFirst().intValue() > 0) { queue.addFirst(new MutableInteger(-eventCount)); } else { queue.getFirst().add(-eventCount); } overflowCounter += eventCount; }
public void putFirstPrimary(Integer eventCount) { if ((queue.peekFirst() == null) || queue.getFirst().intValue() < 0) { queue.addFirst(new MutableInteger(eventCount)); } else { queue.getFirst().add(eventCount); } }