當前位置: 首頁>>代碼示例>>Java>>正文


Java Queues.newLinkedBlockingDeque方法代碼示例

本文整理匯總了Java中com.google.common.collect.Queues.newLinkedBlockingDeque方法的典型用法代碼示例。如果您正苦於以下問題:Java Queues.newLinkedBlockingDeque方法的具體用法?Java Queues.newLinkedBlockingDeque怎麽用?Java Queues.newLinkedBlockingDeque使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.common.collect.Queues的用法示例。


在下文中一共展示了Queues.newLinkedBlockingDeque方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: PubSubClient

import com.google.common.collect.Queues; //導入方法依賴的package包/類
PubSubClient(String hostname, int port, int maxPendingMessages) throws IOException {
    this.hostname = hostname;
    this.port = port;
    this.maxPendingMessages = maxPendingMessages;
    if (maxPendingMessages <= 0) {
        this.pending = Queues.newLinkedBlockingDeque();
    } else {
        this.pending = Queues.newLinkedBlockingDeque(maxPendingMessages);
    }
    this.selector = Selector.open();
    Runtime.getRuntime().addShutdownHook(new Thread() {
        public void run() {
            close();
        }
    });
}
 
開發者ID:brownsys,項目名稱:tracing-framework,代碼行數:17,代碼來源:PubSubClient.java

示例2: testCreateQueue

import com.google.common.collect.Queues; //導入方法依賴的package包/類
/**
 * 創建隊列
 */
@Test
public void testCreateQueue() {
    List<String> strList = Lists.newArrayListWithExpectedSize(128);

    // 創建ArrayBlockingQueue
    ArrayBlockingQueue<String> blockingQueue = Queues.newArrayBlockingQueue(128);

    // 創建LinkedBlockingQueue
    LinkedBlockingQueue<String> linkedBlockingQueue1 = Queues.newLinkedBlockingQueue();
    LinkedBlockingQueue<String> linkedBlockingQueue2 = Queues.newLinkedBlockingQueue(128);
    LinkedBlockingQueue<String> linkedBlockingQueue3 = Queues.newLinkedBlockingQueue(strList);

    // 創建LinkedBlockingDeque
    LinkedBlockingDeque<String> blockingDeque1 = Queues.newLinkedBlockingDeque();
    LinkedBlockingDeque<String> blockingDeque2 = Queues.newLinkedBlockingDeque(128);
    LinkedBlockingDeque<String> blockingDeque3 = Queues.newLinkedBlockingDeque(strList);

    // 創建ArrayDeque
    ArrayDeque<String> arrayDeque1 = Queues.newArrayDeque();
    ArrayDeque<String> arrayDeque2 = Queues.newArrayDeque(strList);

    // 創建ConcurrentLinkedQueue
    ConcurrentLinkedQueue<String> concurrentLinkedQueue1 = Queues.newConcurrentLinkedQueue();
    ConcurrentLinkedQueue<String> concurrentLinkedQueue2 = Queues.newConcurrentLinkedQueue(strList);

    // 創建PriorityBlockingQueue
    PriorityBlockingQueue<String> priorityBlockingQueue1 = Queues.newPriorityBlockingQueue();
    PriorityBlockingQueue<String> priorityBlockingQueue2 = Queues.newPriorityBlockingQueue(strList);

    // 創建PriorityQueue
    PriorityQueue<Comparable> priorityQueue1 = Queues.newPriorityQueue();
    PriorityQueue<Comparable> priorityQueue2 = Queues.newPriorityQueue(strList);

    // 創建SynchronousQueue
    SynchronousQueue<String> synchronousQueue = Queues.newSynchronousQueue();
}
 
開發者ID:cbooy,項目名稱:cakes,代碼行數:40,代碼來源:QueuesDemo.java

示例3: BoundedBlockingRecordQueue

import com.google.common.collect.Queues; //導入方法依賴的package包/類
private BoundedBlockingRecordQueue(Builder<T> builder) {
  Preconditions.checkArgument(builder.capacity > 0, "Invalid queue capacity");
  Preconditions.checkArgument(builder.timeout > 0, "Invalid timeout time");

  this.capacity = builder.capacity;
  this.timeout = builder.timeout;
  this.timeoutTimeUnit = builder.timeoutTimeUnit;
  this.blockingDeque = Queues.newLinkedBlockingDeque(builder.capacity);

  this.queueStats = builder.ifCollectStats ? Optional.of(new QueueStats()) : Optional.<QueueStats>absent();
}
 
開發者ID:Hanmourang,項目名稱:Gobblin,代碼行數:12,代碼來源:BoundedBlockingRecordQueue.java

示例4: Mailman

import com.google.common.collect.Queues; //導入方法依賴的package包/類
public Mailman(final Proc process, final Long maxProcess) {
  this.process = process;
  for (long pid = 1L; pid <= maxProcess; pid++) {
    if (pid != process.getProcessId().longValue()) {
      LinkedBlockingDeque<Envelope> queue = Queues.newLinkedBlockingDeque();
      mailboxes.put(pid, queue);
    }
  }
}
 
開發者ID:mikehelmick,項目名稱:ProcTour,代碼行數:10,代碼來源:Mailman.java

示例5: index

import com.google.common.collect.Queues; //導入方法依賴的package包/類
private Set<String> index() {
	Set<String> visited = Sets.newHashSet();
	Queue<Version> toVisit = Queues.newLinkedBlockingDeque();
	toVisit.add(rootVersion);

	while (!toVisit.isEmpty()) {
		Version current = toVisit.poll();
		if (visited.add(current.getId()) && current.getChild() != null) {
			toVisit.add(current.getChild());
		}
	}

	return visited;
}
 
開發者ID:quantumdb,項目名稱:quantumdb,代碼行數:15,代碼來源:VersionIdGenerator.java

示例6: run

import com.google.common.collect.Queues; //導入方法依賴的package包/類
@Override
public void run(KafkalogConfiguration configuration, Environment environment) throws Exception {
    BlockingQueue<String> lineBuffer = Queues.newLinkedBlockingDeque(configuration.getMaxQueueLength());
    LogMessageFactory messageFactory = new LogMessageFactory(configuration.getTopic());
    Producer producer = createProducer(configuration);
    LogProducer logProducer = new LogProducer(lineBuffer, messageFactory, producer, environment.metrics());
    environment.lifecycle().manage(logProducer);

    IngestService ingestService =
            new IngestService(configuration.getPort(), configuration.getMaxLineLength(), lineBuffer, environment.metrics());
    environment.lifecycle().manage(ingestService);

    environment.jersey().disable();
}
 
開發者ID:Multifarious,項目名稱:kafkalog,代碼行數:15,代碼來源:KafkalogApplication.java

示例7: singleMessage

import com.google.common.collect.Queues; //導入方法依賴的package包/類
@Test
public void singleMessage() throws Exception {
    BlockingQueue<String> lineBuffer = Queues.newLinkedBlockingDeque();
    IngestService ingestService = new IngestService(PORT, 8192, lineBuffer, new MetricRegistry());
    ingestService.start();
    sendMessage(DUMB_TEST_MESSAGE);
    assertEquals(DUMB_TEST_MESSAGE, lineBuffer.take());
    ingestService.stop();
}
 
開發者ID:Multifarious,項目名稱:kafkalog,代碼行數:10,代碼來源:IngestServiceTest.java

示例8: Spooler

import com.google.common.collect.Queues; //導入方法依賴的package包/類
public Spooler(String name) {
  setDaemon(true);
  setName(name);
  spoolingQueue = Queues.newLinkedBlockingDeque();
}
 
開發者ID:skhalifa,項目名稱:QDrill,代碼行數:6,代碼來源:SpoolingRawBatchBuffer.java

示例9: FilterChain

import com.google.common.collect.Queues; //導入方法依賴的package包/類
FilterChain(Iterable<F> chain) {
    this.chain = Queues.newLinkedBlockingDeque(chain);
}
 
開發者ID:SpineEventEngine,項目名稱:core-java,代碼行數:4,代碼來源:FilterChain.java

示例10: Pipeline

import com.google.common.collect.Queues; //導入方法依賴的package包/類
Pipeline(int size) {
    this.deque = Queues.newLinkedBlockingDeque(size);
}
 
開發者ID:PocketServer,項目名稱:PocketServer-Ref,代碼行數:4,代碼來源:Pipeline.java

示例11: setup

import com.google.common.collect.Queues; //導入方法依賴的package包/類
public void setup() {
    modifiedChunks = Maps.newConcurrentMap();
    compressionQueue = Queues.newLinkedBlockingDeque();
    setupThreads();
}
 
開發者ID:zoneXcoding,項目名稱:Mineworld,代碼行數:6,代碼來源:ChunkStoreGZip.java

示例12: DecodingEndpointReader

import com.google.common.collect.Queues; //導入方法依賴的package包/類
protected DecodingEndpointReader() {
    super(Queues.<ByteBuf>newLinkedBlockingDeque());
}
 
開發者ID:lisaglendenning,項目名稱:zookeeper-lite,代碼行數:4,代碼來源:IntraVmCodecEndpoint.java

示例13: EndpointWriter

import com.google.common.collect.Queues; //導入方法依賴的package包/類
protected EndpointWriter() {
    super(Queues.<EndpointWrite<? extends I,I>>newLinkedBlockingDeque());
}
 
開發者ID:lisaglendenning,項目名稱:zookeeper-lite,代碼行數:4,代碼來源:IntraVmEndpoint.java

示例14: EndpointReader

import com.google.common.collect.Queues; //導入方法依賴的package包/類
protected EndpointReader() {
    super(Queues.<O>newLinkedBlockingDeque());
}
 
開發者ID:lisaglendenning,項目名稱:zookeeper-lite,代碼行數:4,代碼來源:IntraVmEndpoint.java


注:本文中的com.google.common.collect.Queues.newLinkedBlockingDeque方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。