java.util.concurrent.LinkedBlockingDeque.addFirst()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(186)

本文整理了Java中java.util.concurrent.LinkedBlockingDeque.addFirst()方法的一些代码示例,展示了LinkedBlockingDeque.addFirst()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。LinkedBlockingDeque.addFirst()方法的具体详情如下:
包路径:java.util.concurrent.LinkedBlockingDeque
类名称:LinkedBlockingDeque
方法名:addFirst

LinkedBlockingDeque.addFirst介绍

暂无

代码示例

代码示例来源:origin: robovm/robovm

/**
 * @throws IllegalStateException {@inheritDoc}
 * @throws NullPointerException  {@inheritDoc}
 */
public void push(E e) {
  addFirst(e);
}

代码示例来源:origin: apache/zookeeper

private void addBack(Packet head) {
  if (head != null && head != WakeupPacket.getInstance()) {
    outgoingQueue.addFirst(head);
  }
}

代码示例来源:origin: jersey/jersey

@Override
public int read() throws IOException {
  if (end) {
    return -1;
  }
  try {
    InputStream take = isList.take();
    if (checkEndOfInput(take)) {
      return -1;
    }
    int read = take.read();
    if (take.available() > 0) {
      isList.addFirst(take);
    }
    return read;
  } catch (InterruptedException e) {
    throw new IOException("Interrupted.", e);
  }
}

代码示例来源:origin: jersey/jersey

@Override
public int read(byte[] b, int off, int len) throws IOException {
  if (end) {
    return -1;
  }
  InputStream take;
  try {
    take = isList.take();
    if (checkEndOfInput(take)) {
      return -1;
    }
    int read = take.read(b, off, len);
    if (take.available() > 0) {
      isList.addFirst(take);
    }
    return read;
  } catch (InterruptedException e) {
    throw new IOException("Interrupted.", e);
  }
}

代码示例来源:origin: linkedin/cruise-control

/**
 * Shutdown the metric fetcher manager.
 */
public void shutdown() {
 LOG.info("Shutting down anomaly detector.");
 _shutdown = true;
 _anomalies.addFirst(SHUTDOWN_ANOMALY);
 _detectorScheduler.shutdown();
 try {
  _detectorScheduler.awaitTermination(_anomalyDetectionIntervalMs, TimeUnit.MILLISECONDS);
  if (!_detectorScheduler.isTerminated()) {
   LOG.warn("The sampling scheduler failed to shutdown in " + _anomalyDetectionIntervalMs + " ms.");
  }
 } catch (InterruptedException e) {
  LOG.warn("Interrupted while waiting for anomaly detector to shutdown.");
 }
 _brokerFailureDetector.shutdown();
 LOG.info("Anomaly detector shutdown completed.");
}

代码示例来源:origin: apache/zookeeper

private Packet findSendablePacket(LinkedBlockingDeque<Packet> outgoingQueue,
                 boolean tunneledAuthInProgres) {
  if (outgoingQueue.isEmpty()) {
    return null;
  }
  // If we've already starting sending the first packet, we better finish
  if (outgoingQueue.getFirst().bb != null || !tunneledAuthInProgres) {
    return outgoingQueue.getFirst();
  }
  // Since client's authentication with server is in progress,
  // send only the null-header packet queued by primeConnection().
  // This packet must be sent so that the SASL authentication process
  // can proceed, but all other packets should wait until
  // SASL authentication completes.
  Iterator<Packet> iter = outgoingQueue.iterator();
  while (iter.hasNext()) {
    Packet p = iter.next();
    if (p.requestHeader == null) {
      // We've found the priming-packet. Move it to the beginning of the queue.
      iter.remove();
      outgoingQueue.addFirst(p);
      return p;
    } else {
      // Non-priming packet: defer it until later, leaving it in the queue
      // until authentication completes.
      LOG.debug("deferring non-priming packet {} until SASL authentation completes.", p);
    }
  }
  return null;
}

代码示例来源:origin: jersey/jersey

@Override
public ByteBuf readChunk(ByteBufAllocator allocator) throws Exception {
  if (!open) {
    return null;
  }
  ByteBuffer top = queue.poll(READ_TIMEOUT, TimeUnit.MILLISECONDS);
  if (top == null) {
    // returning empty buffer instead of null causes flush (which is needed for BroadcasterTest and others..).
    return Unpooled.EMPTY_BUFFER;
  }
  if (top == VOID) {
    open = false;
    return null;
  }
  int topRemaining = top.remaining();
  ByteBuf buffer = allocator.buffer(topRemaining);
  buffer.setBytes(0, top);
  buffer.setIndex(0, topRemaining);
  if (top.remaining() > 0) {
    queue.addFirst(top);
  }
  offset += topRemaining;
  return buffer;
}

代码示例来源:origin: linkedin/cruise-control

private void fixAnomaly(Anomaly anomaly) throws Exception {
  if (isFixable(anomaly)) {
   LOG.info("Fixing anomaly {}", anomaly);
   anomaly.fix();
  }
  _anomalies.clear();
  // We need to add the shutdown message in case the failure detector has shutdown.
  if (_shutdown) {
   _anomalies.addFirst(SHUTDOWN_ANOMALY);
  }
  // Explicitly detect broker failures after clear the queue.
  // We don't need to worry about the goal violation because it is run periodically.
  _brokerFailureDetector.detectBrokerFailures();
 }
}

代码示例来源:origin: apache/zookeeper

RequestHeader header = new RequestHeader(-8, OpCode.setWatches);
      Packet packet = new Packet(header, new ReplyHeader(), sw, null, null);
      outgoingQueue.addFirst(packet);
  outgoingQueue.addFirst(new Packet(new RequestHeader(-4,
      OpCode.auth), null, new AuthPacket(0, id.scheme,
      id.data), null, null));
outgoingQueue.addFirst(new Packet(null, null, conReq,
    null, null, readOnly));
clientCnxnSocket.connectionPrimed();

代码示例来源:origin: apache/flume

@Override
protected void doRollback() {
 int takes = takeList.size();
 synchronized (queueLock) {
  Preconditions.checkState(queue.remainingCapacity() >= takeList.size(),
    "Not enough space in memory channel " +
    "queue to rollback takes. This should never happen, please report");
  while (!takeList.isEmpty()) {
   queue.addFirst(takeList.removeLast());
  }
  putList.clear();
 }
 putByteCounter = 0;
 takeByteCounter = 0;
 queueStored.release(takes);
 channelCounter.setChannelSize(queue.size());
}

代码示例来源:origin: loklak/loklak_server

public static void addScheduler(final TwitterTweet t, final UserEntry u, final boolean dump, boolean priority) {
  try {
    if (priority) {
      try {
        messageQueue.addFirst(new DAO.MessageWrapper(t, u, dump));
      } catch (IllegalStateException ee) {
        // case where the queue is full
        messageQueue.put(new DAO.MessageWrapper(t, u, dump));
      }
    } else {
      messageQueue.put(new DAO.MessageWrapper(t, u, dump));
    }
  } catch (InterruptedException e) {
    DAO.severe(e);
  }
}

代码示例来源:origin: ibinti/bugvm

/**
 * @throws IllegalStateException {@inheritDoc}
 * @throws NullPointerException  {@inheritDoc}
 */
public void push(E e) {
  addFirst(e);
}

代码示例来源:origin: MobiVM/robovm

/**
 * @throws IllegalStateException {@inheritDoc}
 * @throws NullPointerException  {@inheritDoc}
 */
public void push(E e) {
  addFirst(e);
}

代码示例来源:origin: org.apache.geode/gemfire-core

/**
 * puts selector back at the end of LRU list of free selectos.
 * 
 * @param info
 */
private void release(SelectorInfo info) {
 /**Pivotal Addition **/
 info.deque.addFirst(info);
 /**End Pivotal Addition **/
}

代码示例来源:origin: org.codehaus.jsr166-mirror/jsr166

/**
 * @throws IllegalStateException {@inheritDoc}
 * @throws NullPointerException  {@inheritDoc}
 */
public void push(E e) {
  addFirst(e);
}

代码示例来源:origin: com.mobidevelop.robovm/robovm-rt

/**
 * @throws IllegalStateException {@inheritDoc}
 * @throws NullPointerException  {@inheritDoc}
 */
public void push(E e) {
  addFirst(e);
}

代码示例来源:origin: pinterest/pinlater

public synchronized void recordSample(String shardName, boolean success) {
 ImmutableMap<String, ShardState> shardHealthMap = shardHealthMapRef.get();
 ShardState shardState = shardHealthMap.get(shardName);
 if (shardState.healthSamples.remainingCapacity() == 0) {
  shardState.numSuccessesInWindow -= shardState.healthSamples.removeLast();
 }
 int successVal = success ? 1 : 0;
 shardState.numSuccessesInWindow += successVal;
 shardState.healthSamples.addFirst(successVal);
}

代码示例来源:origin: com.netflix.dyno/dyno-core

private void addNewBucket(long timestamp) {
  
  bucketCreateCount.incrementAndGet();
  
  Bucket  newBucket = new Bucket(timestamp);
  queue.removeLast();
  queue.addFirst(newBucket);
}

代码示例来源:origin: com.twitter.common/stats

@Override
 public Double doSample() {
  T sample = input.read();

  if (samples.remainingCapacity() == 0) {
   sampleSum -= samples.removeLast().doubleValue();
  }

  samples.addFirst(sample);
  sampleSum += sample.doubleValue();

  return sampleSum / samples.size();
 }
}

代码示例来源:origin: d4rken/RxShell

@Override
public void onNext(QueueCmd item) {
  if (RXSDebug.isDebug()) Timber.tag(TAG).v("onNext(%s)", item);
  if (item.exitCode < 0) {
    cmdQueue.addFirst(QueueCmd.poisonPill());
    session.cancel().subscribe();
  }
  item.resultEmitter.onSuccess(item.buildResult());
  idlePub.onNext(cmdQueue.isEmpty());
}

相关文章

微信公众号

最新文章

更多