本文整理匯總了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();
}
});
}
示例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();
}
示例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();
}
示例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);
}
}
}
示例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;
}
示例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();
}
示例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();
}
示例8: Spooler
import com.google.common.collect.Queues; //導入方法依賴的package包/類
public Spooler(String name) {
setDaemon(true);
setName(name);
spoolingQueue = Queues.newLinkedBlockingDeque();
}
示例9: FilterChain
import com.google.common.collect.Queues; //導入方法依賴的package包/類
FilterChain(Iterable<F> chain) {
this.chain = Queues.newLinkedBlockingDeque(chain);
}
示例10: Pipeline
import com.google.common.collect.Queues; //導入方法依賴的package包/類
Pipeline(int size) {
this.deque = Queues.newLinkedBlockingDeque(size);
}
示例11: setup
import com.google.common.collect.Queues; //導入方法依賴的package包/類
public void setup() {
modifiedChunks = Maps.newConcurrentMap();
compressionQueue = Queues.newLinkedBlockingDeque();
setupThreads();
}
示例12: DecodingEndpointReader
import com.google.common.collect.Queues; //導入方法依賴的package包/類
protected DecodingEndpointReader() {
super(Queues.<ByteBuf>newLinkedBlockingDeque());
}
示例13: EndpointWriter
import com.google.common.collect.Queues; //導入方法依賴的package包/類
protected EndpointWriter() {
super(Queues.<EndpointWrite<? extends I,I>>newLinkedBlockingDeque());
}
示例14: EndpointReader
import com.google.common.collect.Queues; //導入方法依賴的package包/類
protected EndpointReader() {
super(Queues.<O>newLinkedBlockingDeque());
}