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

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

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

LinkedBlockingDeque.clear介绍

[英]Atomically removes all of the elements from this deque. The deque will be empty after this call returns.
[中]以原子方式删除此数据块中的所有元素。此调用返回后,deque将为空。

代码示例

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

@Override
public void operationComplete(ChannelFuture f) throws Exception {
  // forcibly closed connection.
  open = false;
  queue.clear();
  close();
  removeCloseListener();
}

代码示例来源:origin: prestodb/presto

@Override
public synchronized void close()
{
  if (!closed.compareAndSet(false, true)) {
    return;
  }
  for (HttpPageBufferClient client : allClients.values()) {
    closeQuietly(client);
  }
  pageBuffer.clear();
  systemMemoryContext.setBytes(0);
  bufferRetainedSizeInBytes = 0;
  if (pageBuffer.peekLast() != NO_MORE_PAGES) {
    checkState(pageBuffer.add(NO_MORE_PAGES), "Could not add no more pages marker");
  }
  notifyBlockedCallers();
}

代码示例来源:origin: alibaba/nacos

@Override
public void run() {
  List list = Arrays.asList(healthCheckResults.toArray());
  healthCheckResults.clear();

代码示例来源: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: jersey/jersey

@Override
public void channelRead(final ChannelHandlerContext ctx, Object msg) {
  if (msg instanceof HttpRequest) {
    final HttpRequest req = (HttpRequest) msg;
    if (HttpUtil.is100ContinueExpected(req)) {
      ctx.write(new DefaultFullHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.CONTINUE));
    }
    isList.clear(); // clearing the content - possible leftover from previous request processing.
    final ContainerRequest requestContext = createContainerRequest(ctx, req);
    requestContext.setWriter(new NettyResponseWriter(ctx, req, container));
    // must be like this, since there is a blocking read from Jersey
    container.getExecutorService().execute(new Runnable() {
      @Override
      public void run() {
        container.getApplicationHandler().handle(requestContext);
      }
    });
  }
  if (msg instanceof HttpContent) {
    HttpContent httpContent = (HttpContent) msg;
    ByteBuf content = httpContent.content();
    if (content.isReadable()) {
      isList.add(new ByteBufInputStream(content));
    }
    if (msg instanceof LastHttpContent) {
      isList.add(NettyInputStream.END_OF_INPUT);
    }
  }
}

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

putList.clear();
takeList.clear();

代码示例来源: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: apache/flume

putList.clear();
takeList.clear();
channelCounter.setChannelSize(queue.getSize());

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

putList.clear();
takeList.clear();
queue.completeTransaction(transactionID);
channelCounter.setChannelSize(queue.getSize());

代码示例来源:origin: winder/Universal-G-Code-Sender

/** File Stream Methods. **/
@Override
public void resetBuffersInternal() {
  if (activeCommandList != null) {
    activeCommandList.clear();
  }
}

代码示例来源:origin: winder/Universal-G-Code-Sender

@Override
public void cancelSend() {
  this.nextCommand = null;
  this.commandBuffer.clear();
  this.activeCommandList.clear();
  this.commandStream = null;
  this.sendPaused = false;
}

代码示例来源:origin: hector-client/hector

public void clear() {
 latencies.clear();
 intervalupdates.set(0);
}

代码示例来源:origin: winder/Universal-G-Code-Sender

@Override
public boolean openCommPort(ConnectionDriver connectionDriver, String name, int baud) throws Exception {
  boolean ret = super.openCommPort(connectionDriver, name, baud);
  
  if (ret) {
    this.commandBuffer.clear();
    this.activeCommandList.clear();
    this.sentBufferSize = 0;
  }
  return ret;
}

代码示例来源:origin: winder/Universal-G-Code-Sender

final public void resetBuffers() {
  if (eventQueue != null) {
    eventQueue.clear();
  }
  resetBuffersInternal();
}

代码示例来源:origin: winder/Universal-G-Code-Sender

@Override
public void closeCommPort() throws Exception {
  this.cancelSend();
  super.closeCommPort();
  
  this.sendPaused = false;
  this.commandBuffer.clear();
  this.activeCommandList.clear();
}

代码示例来源:origin: org.restcomm.fsm/squirrel-foundation

/**
 * Clean all queued events
 */
protected void cleanQueuedEvents() {
  queuedEvents.clear();
}

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

public void reset() {
  numSuccessesInWindow = 0;
  isHealthy = true;
  lastUnhealthyTimestampMillis = 0;
  healthSamples.clear();
 }
}

代码示例来源:origin: codefollower/Tomcat-Research

/**
 * Recycle the output buffer. This should be called when closing the
 * connection.
 */
public void recycle() {
  // Sub-classes may wish to do more than this.
  nextRequest();
  bufferedWrites.clear();
}

代码示例来源:origin: NightscoutFoundation/xDrip

@SuppressWarnings("WeakerAccess")
public static void injectQueueJson(String json) {
  if (json == null || json.length() == 0) return;
  final Type queueType = new TypeToken<ArrayList<Ob1Work>>() {
  }.getType();
  final List<Ob1Work> queue = JoH.defaultGsonInstance().fromJson(json, queueType);
  synchronized (commandQueue) {
    commandQueue.clear();
    commandQueue.addAll(queue);
  }
  UserError.Log.d(TAG, "Replaced queue with stream: " + json);
}

代码示例来源:origin: jamorham/xDrip-plus

public static void emptyQueue() {
  synchronized (commandQueue) {
    if (commandQueue.size() > 0) {
      UserError.Log.d(TAG, "Queue drained on wear, clearing: " + commandQueue.size() + " commands");
      commandQueue.clear();
      Inevitable.task("Save cleared G5 queue", 1000, Ob1G5StateMachine::saveQueue);
    } else {
      if (d) UserError.Log.d(TAG, "Local command queue is already empty");
    }
  }
}

相关文章

微信公众号

最新文章

更多