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


Java ConcurrentLinkedQueue类代码示例

本文整理汇总了Java中java.util.concurrent.ConcurrentLinkedQueue的典型用法代码示例。如果您正苦于以下问题:Java ConcurrentLinkedQueue类的具体用法?Java ConcurrentLinkedQueue怎么用?Java ConcurrentLinkedQueue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CachedWorkerPool

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
CachedWorkerPool(long keepAliveTime, TimeUnit unit) {
    this.keepAliveTime = unit != null ? unit.toNanos(keepAliveTime) : 0;
    this.expiringWorkerQueue = new ConcurrentLinkedQueue();
    this.allWorkers = new CompositeSubscription();
    ScheduledExecutorService evictor = null;
    Future<?> task = null;
    if (unit != null) {
        evictor = Executors.newScheduledThreadPool(1, CachedThreadScheduler.EVICTOR_THREAD_FACTORY);
        NewThreadWorker.tryEnableCancelPolicy(evictor);
        task = evictor.scheduleWithFixedDelay(new Runnable() {
            public void run() {
                CachedWorkerPool.this.evictExpiredWorkers();
            }
        }, this.keepAliveTime, this.keepAliveTime, TimeUnit.NANOSECONDS);
    }
    this.evictorService = evictor;
    this.evictorTask = task;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:19,代码来源:CachedThreadScheduler.java

示例2: putAllCollections

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
static void putAllCollections(Map<Class<?>, IntFunction<?>> map, Map<Class<?>, Function<?, ?>> unmodMap)
{
    safePut(map, ArrayList.class, ArrayList::new);
    safePut(map, HashSet.class, LinkedHashSet::new);
    safePut(map, Properties.class, x -> new Properties());
    safePut(map, Hashtable.class, Hashtable::new);

    safePut(map, Collection.class, ArrayList::new);
    safePut(map, Set.class, LinkedHashSet::new);
    safePut(map, List.class, ArrayList::new);
    safePut(map, SortedSet.class, x -> new TreeSet<>());
    safePut(map, Queue.class, x -> new ConcurrentLinkedQueue<>());
    safePut(map, Deque.class, x -> new ConcurrentLinkedDeque<>());
    safePut(map, BlockingQueue.class, x -> new LinkedBlockingQueue<>());
    safePut(map, BlockingDeque.class, x -> new LinkedBlockingDeque<>());


    safePut(map, HashMap.class, LinkedHashMap::new);
    safePut(map, LinkedHashMap.class, LinkedHashMap::new);
    safePut(map, ConcurrentHashMap.class, ConcurrentHashMap::new);

    safePut(map, Map.class, LinkedHashMap::new);
    safePut(map, ConcurrentMap.class, x -> new ConcurrentSkipListMap<>());
    safePut(map, ConcurrentNavigableMap.class, x -> new ConcurrentSkipListMap<>());
    safePut(map, SortedMap.class, i -> new TreeMap<>());
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:27,代码来源:YamlCollectionCreator.java

示例3: apply

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
@Override
public Collection<Diff> apply(Object before, Object after, String description) {
    Collection<Diff> diffs = new ConcurrentLinkedQueue<>();
    if (before == null && after == null) {
        diffs.add(new Diff.Builder().hasNotChanged().setFieldDescription(description).build());
    } else if (before == null) {
        diffs.add(new Diff.Builder().isAdded().setAfterValue(after).setFieldDescription(description).build());
    } else if (after == null) {
        diffs.add(new Diff.Builder().isDeleted().setBeforeValue(before).setFieldDescription(description).build());
    } else {
        if (before.equals(after)) {
            diffs.add(new Diff.Builder().hasNotChanged().setBeforeValue(before).setAfterValue(after).setFieldDescription(description).build());
        } else {
            diffs.add(new Diff.Builder().isUpdated().setBeforeValue(before).setAfterValue(after).setFieldDescription(description).build());
        }
    }
    return diffs;
}
 
开发者ID:PareshNavalakha,项目名称:object-diff,代码行数:19,代码来源:ObjectDiffCalculator.java

示例4: ImapClient

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
public ImapClient(ImapClientConfiguration configuration,
                  Channel channel,
                  SslContext sslContext,
                  EventExecutorGroup promiseExecutor,
                  String clientName) {
  this.logger = LogUtils.loggerWithName(ImapClient.class, clientName);
  this.configuration = configuration;
  this.channel = channel;
  this.sslContext = sslContext;
  this.promiseExecutor = promiseExecutor;
  this.clientState = new ImapClientState(clientName, promiseExecutor);
  this.codec = new ImapCodec(clientState);
  this.pendingWriteQueue = new ConcurrentLinkedQueue<>();
  this.connectionShutdown = new AtomicBoolean(false);
  this.connectionClosed = new AtomicBoolean(false);
  this.capabilities = new AtomicReference<>(null);

  configureChannel();
}
 
开发者ID:HubSpot,项目名称:NioImapClient,代码行数:20,代码来源:ImapClient.java

示例5: concurrentQueues

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
Collection<Queue<Boolean>> concurrentQueues() {
    List<Queue<Boolean>> queues = new ArrayList<Queue<Boolean>>();
    queues.add(new ConcurrentLinkedDeque<Boolean>());
    queues.add(new ConcurrentLinkedQueue<Boolean>());
    queues.add(new ArrayBlockingQueue<Boolean>(count, false));
    queues.add(new ArrayBlockingQueue<Boolean>(count, true));
    queues.add(new LinkedBlockingQueue<Boolean>());
    queues.add(new LinkedBlockingDeque<Boolean>());
    queues.add(new LinkedTransferQueue<Boolean>());

    // Following additional implementations are available from:
    // http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
    // queues.add(new SynchronizedLinkedListQueue<Boolean>());

    // Avoid "first fast, second slow" benchmark effect.
    Collections.shuffle(queues);
    return queues;
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:19,代码来源:RemovePollRace.java

示例6: parse

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
/**
 * Parses all document present in the referenced file path
 *
 * @param stringsQueue to parse
 * @return list with all documents with it's content in untokenized/unstemmed raw keywords
 */
public List<Document> parse(ConcurrentLinkedQueue<String> stringsQueue) {

    //compile our corpus regex so we can apply it on our parsing process
    Pattern id_content = Pattern.compile(CORPUS_REGEX_DOCUMENT);

    //parsing process
    return stringsQueue.parallelStream()
            .filter(line -> !line.isEmpty()) // line is not empty
            .map(id_content::matcher)// regex it
            .filter(Matcher::find) // did we regex anything? if so create document
            .map(match ->
            {
                //get the corpusID for this new file that we processing
                int corpusID = corpusCount.getAndIncrement();

                //map the corpusID to its corresponding filepath
                corpusIDToPath.computeIfAbsent(corpusID, v -> new ImmutablePair<>(match.group(4), Integer.parseInt(match.group(1))));
                return new Document(
                        corpusID, //first match is doc id and used to create our own doc id
                        Arrays.asList(match.group(5).split(" ")).parallelStream() // split document content in words
                                .collect(Collectors.toList())); // and put them in a list
            })
            .collect(Collectors.toList()); //collect all parsed lines
}
 
开发者ID:luminoso,项目名称:information-retrieval,代码行数:31,代码来源:CorpusReader.java

示例7: concurrentQueues

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
Collection<Queue<Boolean>> concurrentQueues() {
    List<Queue<Boolean>> queues = new ArrayList<>();
    queues.add(new ConcurrentLinkedDeque<Boolean>());
    queues.add(new ConcurrentLinkedQueue<Boolean>());
    queues.add(new ArrayBlockingQueue<Boolean>(count, false));
    queues.add(new ArrayBlockingQueue<Boolean>(count, true));
    queues.add(new LinkedBlockingQueue<Boolean>());
    queues.add(new LinkedBlockingDeque<Boolean>());
    queues.add(new LinkedTransferQueue<Boolean>());

    // Following additional implementations are available from:
    // http://gee.cs.oswego.edu/dl/concurrency-interest/index.html
    // queues.add(new SynchronizedLinkedListQueue<Boolean>());

    // Avoid "first fast, second slow" benchmark effect.
    Collections.shuffle(queues);
    return queues;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:RemovePollRace.java

示例8: start

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
@SuppressWarnings("InfiniteLoopStatement")
public void start() {
    for (Map.Entry<Address, Addressee> entry : addresseeMap.entrySet()) {
        new Thread(() -> {
            while (true) {

                ConcurrentLinkedQueue<Message> queue = messagesMap.get(entry.getKey());
                while (!queue.isEmpty()) {
                    Message message = queue.poll();
                    message.exec(entry.getValue());
                }
                try {
                    Thread.sleep(MessageSystem.DEFAULT_STEP_TIME);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        }).start();
    }
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_06,代码行数:21,代码来源:MessageSystem.java

示例9: PerfInserterBase

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
public PerfInserterBase(Configuration conf, TableName tableName, String loadDataDir,
    int processId, int threadNum, String statFilePath, ConcurrentLinkedQueue<String> reportQueue,
    AbstractWorkload workload) throws IOException {
  this.tableName = tableName;
  this.processId = processId;
  this.threadNum = threadNum;
  this.loadDataDir = loadDataDir;
  this.statFilePath = statFilePath;
  this.reportQueue = reportQueue;
  this.conf = conf;
  loaders = new RunnableDataLoader[threadNum];
  inserters = new RunnablePerfInserter[threadNum];
  threadFinishMark = new boolean[threadNum];
  threadLatency = new double[threadNum];
  globalBoxNumber = new int[ResultParser.LatencyBoxPivots.length];
  for (int i = 0; i < globalBoxNumber.length; ++i) {
    globalBoxNumber[i] = 0;
  }
  this.workload = workload;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:21,代码来源:PerfInserterBase.java

示例10: HTTPBuilder

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
/** Constructor that sets up the connection */
public HTTPBuilder(HTTPSession session) {
  try {
    boot = new Bootstrap();
    boot.group(session.workGroup)
      .channel(HTTPChannel.class)
      .handler(new HTTPInitializer(session.uri.scheme(), this));

    // Channel setup
    onConnectBell = new Bell<Void>();
    setUri(session.uri);
    setupWithTest();

    // Tap bells queue setup
    tapBellQueue = new ConcurrentLinkedQueue<Bell<Void>>();
  } catch (HTTPException e) {
    System.err.println(e.getMessage());
  }
}
 
开发者ID:didclab,项目名称:onedatashare,代码行数:20,代码来源:HTTPBuilder.java

示例11: remove

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
public Object remove(K key) {
	for (ConcurrentLinkedQueue<K> bucket : _buckets) {
		if (contains(key,bucket)) {
			return bucket.remove(key);
		}
	}
	return null;
}
 
开发者ID:langxianwei,项目名称:iot-plat,代码行数:9,代码来源:RotatingList.java

示例12: testAddAllSelf

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
/**
 * addAll(this) throws IllegalArgumentException
 */
public void testAddAllSelf() {
    ConcurrentLinkedQueue q = populatedQueue(SIZE);
    try {
        q.addAll(q);
        shouldThrow();
    } catch (IllegalArgumentException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ConcurrentLinkedQueueTest.java

示例13: testAddAll1

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
/**
 * addAll(null) throws NullPointerException
 */
public void testAddAll1() {
    ConcurrentLinkedQueue q = new ConcurrentLinkedQueue();
    try {
        q.addAll(null);
        shouldThrow();
    } catch (NullPointerException success) {}
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:ConcurrentLinkedQueueTest.java

示例14: testSize

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
/**
 * size changes when elements added and removed
 */
public void testSize() {
    ConcurrentLinkedQueue q = populatedQueue(SIZE);
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(SIZE - i, q.size());
        q.remove();
    }
    for (int i = 0; i < SIZE; ++i) {
        assertEquals(i, q.size());
        q.add(new Integer(i));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:15,代码来源:ConcurrentLinkedQueueTest.java

示例15: testClear

import java.util.concurrent.ConcurrentLinkedQueue; //导入依赖的package包/类
/**
 * clear removes all elements
 */
public void testClear() {
    ConcurrentLinkedQueue q = populatedQueue(SIZE);
    q.clear();
    assertTrue(q.isEmpty());
    assertEquals(0, q.size());
    q.add(one);
    assertFalse(q.isEmpty());
    q.clear();
    assertTrue(q.isEmpty());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:ConcurrentLinkedQueueTest.java


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