当前位置: 首页>>代码示例>>Java>>正文


Java PriorityBlockingQueue.put方法代码示例

本文整理汇总了Java中java.util.concurrent.PriorityBlockingQueue.put方法的典型用法代码示例。如果您正苦于以下问题:Java PriorityBlockingQueue.put方法的具体用法?Java PriorityBlockingQueue.put怎么用?Java PriorityBlockingQueue.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.concurrent.PriorityBlockingQueue的用法示例。


在下文中一共展示了PriorityBlockingQueue.put方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDrainToWithActivePut

import java.util.concurrent.PriorityBlockingQueue; //导入方法依赖的package包/类
/**
 * drainTo empties queue
 */
public void testDrainToWithActivePut() throws InterruptedException {
    final PriorityBlockingQueue q = populatedQueue(SIZE);
    Thread t = new Thread(new CheckedRunnable() {
        public void realRun() {
            q.put(new Integer(SIZE + 1));
        }});

    t.start();
    ArrayList l = new ArrayList();
    q.drainTo(l);
    assertTrue(l.size() >= SIZE);
    for (int i = 0; i < SIZE; ++i)
        assertEquals(l.get(i), new Integer(i));
    t.join();
    assertTrue(q.size() + l.size() >= SIZE);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:PriorityBlockingQueueTest.java

示例2: testPut

import java.util.concurrent.PriorityBlockingQueue; //导入方法依赖的package包/类
/**
 * all elements successfully put are contained
 */
public void testPut() {
    PriorityBlockingQueue q = new PriorityBlockingQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        Integer x = new Integer(i);
        q.put(x);
        assertTrue(q.contains(x));
    }
    assertEquals(SIZE, q.size());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:PriorityBlockingQueueTest.java

示例3: pullTask

import java.util.concurrent.PriorityBlockingQueue; //导入方法依赖的package包/类
public PriorityBlockingQueue<Job> pullTask(int size){
    PriorityBlockingQueue<Job> queues = new PriorityTaskContainer<>(size);
    for(int i = 0; i < size; i++){
        queues.put(poll());
    }
    return queues;
}
 
开发者ID:ShawnShoper,项目名称:x-job,代码行数:8,代码来源:PriorityTaskContainer.java

示例4: enqueueLog

import java.util.concurrent.PriorityBlockingQueue; //导入方法依赖的package包/类
@Override
public void enqueueLog(Path log) {
  String logPrefix = DefaultWALProvider.getWALPrefixFromWALName(log.getName());
  PriorityBlockingQueue<Path> queue = queues.get(logPrefix);
  if (queue == null) {
    queue = new PriorityBlockingQueue<Path>(queueSizePerGroup, new LogsComparator());
    queues.put(logPrefix, queue);
    if (this.sourceRunning) {
      // new wal group observed after source startup, start a new worker thread to track it
      // notice: it's possible that log enqueued when this.running is set but worker thread
      // still not launched, so it's necessary to check workerThreads before start the worker
      final ReplicationSourceWorkerThread worker =
          new ReplicationSourceWorkerThread(logPrefix, queue, replicationQueueInfo, this);
      ReplicationSourceWorkerThread extant = workerThreads.putIfAbsent(logPrefix, worker);
      if (extant != null) {
        LOG.debug("Someone has beat us to start a worker thread for wal group " + logPrefix);
      } else {
        LOG.debug("Starting up worker for wal group " + logPrefix);
        worker.startup();
      }
    }
  }
  queue.put(log);
  int queueSize = logQueueSize.incrementAndGet();
  this.metrics.setSizeOfLogQueue(queueSize);
  // This will log a warning for each new log that gets created above the warn threshold
  if (queue.size() > this.logQueueWarnThreshold) {
    LOG.warn("WAL group " + logPrefix + " queue size: " + queueSize
        + " exceeds value of replication.source.log.queue.warn: " + logQueueWarnThreshold);
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:32,代码来源:ReplicationSource.java


注:本文中的java.util.concurrent.PriorityBlockingQueue.put方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。