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

x33g5p2x  于2022-01-16 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(122)

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

BlockingQueue.contains介绍

[英]Returns true if this queue contains the specified element. More formally, returns true if and only if this queue contains at least one element e such that o.equals(e).
[中]如果此队列包含指定的元素,则返回true。更正式地说,当且仅当此队列包含至少一个元素e,使得o.equals(e)时,返回true。

代码示例

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

@Override
public boolean contains(Object element) {
 return underlyingQueue.contains(element);
}

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

processor.run();
Assert.assertTrue("Did not process the first write request",
    processedRequests.contains(firstCommittedReq));
for (Request r : allReads) {
  Assert.assertTrue("Processed read request",
      !processedRequests.contains(r));
    processedRequests.containsAll(allReads));
Assert.assertTrue("Did not process the second write request",
    processedRequests.contains(secondCommittedReq));
for (Request r : waitingCommittedRequests) {
  Assert.assertTrue("Processed additional committed request",
      !processedRequests.contains(r));

代码示例来源:origin: yanzhenjie/NoHttp

private void removeRequest() {
    mCancelerManager.removeCancel(mRequest);
    if (mQueue.contains(mWork)) {
      mQueue.remove(mWork);
    }
  }
}

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

Assert.assertTrue(processedRequests.contains(otherSessionCommittedReq));

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

@VisibleForTesting
boolean isChunkInPool(int chunkId) {
 Chunk c = getChunk(chunkId);
 if (c==null) {
  return false;
 }
 // chunks that are from pool will return true chunk reference not null
 if (dataChunksPool != null && dataChunksPool.reclaimedChunks.contains(c)) {
  return true;
 } else if (indexChunksPool != null && indexChunksPool.reclaimedChunks.contains(c)) {
  return true;
 }
 return false;
}

代码示例来源:origin: yanzhenjie/NoHttp

@Override
  public void onFinish(final int what) {
    if (mQueue.contains(mWork)) {
      mQueue.remove(mWork);
    }
    HandlerDelivery.getInstance().post(new Runnable() {
      @Override
      public void run() {
        mCallback.onFinish(what);
      }
    });
  }
}

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

try {
  for (final FileInfo file : listing) {
    if (!queue.contains(file) && !processing.contains(file)) {
      if (!queue.offer(file)) {
        break;

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

try {
  for (Path file : listedFiles) {
    if (!filePathQueue.contains(file) && !processing.contains(file)) {
      if (!filePathQueue.offer(file)) {
        break;

代码示例来源:origin: jankotek/mapdb

final int size = Math.min(q.remainingCapacity(), SIZE);
final Object[] elts = new Object[size];
assertFalse(q.contains(makeElement(99)));
assertFalse(q.remove(makeElement(99)));
checkEmpty(q);
for (int i = 1; i < size; i += 2) {
  for (int pass = 0; pass < 2; pass++) {
    assertEquals((pass == 0), q.contains(elts[i]));
    assertEquals((pass == 0), q.remove(elts[i]));
    assertFalse(q.contains(elts[i]));
    assertTrue(q.contains(elts[i - 1]));
    if (i < size - 1)
      assertTrue(q.contains(elts[i + 1]));
  assertTrue(q.contains(elts[0]));
for (int i = size - 2; i >= 0; i -= 2) {
  assertTrue(q.contains(elts[i]));
  assertFalse(q.contains(elts[i + 1]));
  assertTrue(q.remove(elts[i]));
  assertFalse(q.contains(elts[i]));
  assertFalse(q.remove(elts[i + 1]));
  assertFalse(q.contains(elts[i + 1]));

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

try {
  for (Path file : listedFiles) {
    if (!filePathQueue.contains(file) && !processing.contains(file)) {
      if (!filePathQueue.offer(file)) {
        break;

代码示例来源:origin: org.elasticsearch/elasticsearch

@Override
public boolean contains(Object o) {
  return queue.contains(o);
}

代码示例来源:origin: i2p/i2p.i2p

/**
 * Returns <code>true</code> if a given job is waiting or running;
 * <code>false</code> if the job is finished or doesn't exist in the queue.
 *
 * @deprecated unused
 */
@Deprecated
public boolean isJobActive(Job job) {
  synchronized (_jobLock) {
    if (_readyJobs.contains(job) || _timedJobs.contains(job))
      return true;
  }
  for (JobQueueRunner runner: _queueRunners.values())
    if (runner.getCurrentJob() == job)
      return true;
  return false;
}

代码示例来源:origin: apache/servicecomb-saga

public void handle(MessageSender messageSender) {
 final Runnable runnable = new PushBackReconnectRunnable(
   messageSender,
   senders,
   pendingTasks,
   grpcRetryContext.getReconnectedSenders()
 );
 synchronized (pendingTasks) {
  if (!pendingTasks.contains(runnable)) {
   pendingTasks.offer(runnable);
  }
 }
}

代码示例来源:origin: spring-projects/spring-kafka

if (this.removeConsumerProducer == null) { // dedicated consumer producers are not cached
  synchronized (this) {
    if (!this.cache.contains(this)
        && !this.cache.offer(this)) {
      if (unit == null) {

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Forces a validation of all idle connections if {@link PoolProperties#testWhileIdle} is set.
 */
public void testAllIdle() {
  try {
    if (idle.size()==0) return;
    Iterator<PooledConnection> unlocked = idle.iterator();
    while (unlocked.hasNext()) {
      PooledConnection con = unlocked.next();
      try {
        con.lock();
        //the con been taken out, we can't clean it up
        if (busy.contains(con))
          continue;
        if (!con.validate(PooledConnection.VALIDATE_IDLE)) {
          idle.remove(con);
          release(con);
        }
      } finally {
        con.unlock();
      }
    } //while
  } catch (ConcurrentModificationException e) {
    log.debug("testAllIdle failed." ,e);
  } catch (Exception e) {
    log.warn("testAllIdle failed, it will be retried.",e);
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

con.lock();
if (busy.contains(con))
  continue;
long time = con.getTimestamp();

代码示例来源:origin: camunda/camunda-bpm-platform

if (idle.contains(con))
  continue;
long time = con.getTimestamp();

代码示例来源:origin: spring-projects/spring-integration

assertTrue(locked.contains("done"));
pool.shutdownNow();

代码示例来源:origin: i2p/i2p.i2p

if (_readyJobs.contains(job))
  alreadyExists = true;
numReady = _readyJobs.size();

代码示例来源:origin: OpenNMS/opennms

/** {@inheritDoc} */
@Override
public final ScheduledFuture<?> updateNode(int nodeId) {
  AdapterOperation op = new AdapterOperation(Integer.valueOf(nodeId), AdapterOperationType.UPDATE, 
                        createScheduleForNode(nodeId, AdapterOperationType.UPDATE));
  
  synchronized (m_executorService) {
    if (!m_executorService.getQueue().contains(op)) {
      return op.schedule(m_executorService);
    }
  }
  
  return null;
}

相关文章