List of usage examples for com.google.common.collect Queues newConcurrentLinkedQueue
public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue()
From source file:com.mac.holdempoker.socket.SocketManager.java
public SocketManager() { connections = new MapMaker().makeMap(); cache = Queues.newConcurrentLinkedQueue(); }
From source file:co.cask.tigon.sql.flowlet.GDATRecordQueue.java
/** * Constructor */ public GDATRecordQueue() { dataQueue = Queues.newConcurrentLinkedQueue(); pendingRecords = Lists.newArrayList(); }
From source file:me.tfeng.toolbox.dust.JsEnginePool.java
@Override public void onStart() throws Throwable { ConcurrentLinkedQueue engines = Queues.newConcurrentLinkedQueue(); for (int i = 0; i < size; i++) { engines.offer(createEngine());/*from w ww . j a v a2 s. c o m*/ } this.engines = engines; }
From source file:org.glowroot.plugin.jdbc.PreparedStatementMirror.java
public void addBatch() { // synchronization isn't an issue here as this method is called only by the monitored thread if (batchedParameters == null) { batchedParameters = Queues.newConcurrentLinkedQueue(); }/*w ww.ja va2 s .co m*/ batchedParameters.add(parameters); parametersCopied = true; }
From source file:org.apache.streams.rss.provider.RssLinkProvider.java
@Override public StreamsResultSet readCurrent() { Queue<StreamsDatum> result = Queues.newConcurrentLinkedQueue(); synchronized (this.entries) { if (this.entries.isEmpty() && this.doneProviding.get()) { this.keepRunning.set(false); }//from w w w.j a v a 2s. co m while (!this.entries.isEmpty()) { ObjectNode node = this.entries.poll(); try { while (!result.offer(new StreamsDatum(node.get("uri").asText()))) { Thread.yield(); } } catch (Exception e) { LOGGER.error("Problem offering up new StreamsDatum: {}", node.asText()); } } } LOGGER.debug("** ReadCurrent return {} streams datums", result.size()); return new StreamsResultSet(result); }
From source file:org.gradle.internal.operations.DefaultBuildOperationQueue.java
public void waitForCompletion() throws MultipleBuildOperationFailures { waitingForCompletion = true;//from w w w . j a va 2 s . co m CountDownLatch finished = new CountDownLatch(operations.size()); Queue<Throwable> failures = Queues.newConcurrentLinkedQueue(); for (ListenableFuture operation : operations) { Futures.addCallback(operation, new CompletionCallback(finished, failures)); } try { finished.await(); } catch (InterruptedException e) { throw UncheckedException.throwAsUncheckedException(e); } // all operations are complete, check for errors if (!failures.isEmpty()) { throw new MultipleBuildOperationFailures(getFailureMessage(failures), failures, logLocation); } }
From source file:org.robotninjas.riemann.client.ClientPipelineFactory.java
public ClientPipelineFactory() { this.proimiseQueueSupplier = new Supplier<BlockingQueue<ReturnableMessage>>() { @Override/* w ww . ja v a2s . co m*/ public BlockingQueue<ReturnableMessage> get() { return Queues.newArrayBlockingQueue(1000); } }; this.sendBufferSupplier = new Supplier<Queue<MessageEvent>>() { @Override public Queue<MessageEvent> get() { return Queues.newConcurrentLinkedQueue(); } }; }
From source file:org.teraslogy.simpleliquids.block.entity.LiquidEntitySystem.java
@Override public void initialise() { super.initialise(); waterPositions = Queues.newConcurrentLinkedQueue(); water = blockManager.getBlock("core:water"); air = blockManager.getBlock(BlockManager.AIR_ID); }
From source file:com.yahoo.pulsar.client.impl.ConsumerBase.java
protected ConsumerBase(PulsarClientImpl client, String topic, String subscription, ConsumerConfiguration conf, int receiverQueueSize, ExecutorService listenerExecutor, CompletableFuture<Consumer> subscribeFuture) { super(client, topic); this.maxReceiverQueueSize = receiverQueueSize; this.subscription = subscription; this.conf = conf; this.consumerName = conf.getConsumerName() == null ? DigestUtils.sha1Hex(UUID.randomUUID().toString()).substring(0, 5) : conf.getConsumerName();// www. j a v a 2 s. c o m this.subscribeFuture = subscribeFuture; this.listener = conf.getMessageListener(); if (receiverQueueSize <= 1) { this.incomingMessages = Queues.newArrayBlockingQueue(1); } else { this.incomingMessages = new GrowableArrayBlockingQueue<>(); } this.listenerExecutor = listenerExecutor; this.pendingReceives = Queues.newConcurrentLinkedQueue(); }
From source file:org.inspirenxe.timewarp.util.Storage.java
/** * Loads the configuration file./* w w w. j a va 2s.c om*/ * @return {@link Storage} for chaining. */ public Storage load() { defaultNodes.entrySet().stream().filter(entry -> entry.getValue() != null).forEach(entry -> { final CommentedConfigurationNode node = getChildNode(entry.getKey()); if (node.getValue() == null) { getChildNode(entry.getKey()).setValue(entry.getValue()); } }); final Queue<CommentedConfigurationNode> queue = Queues.newConcurrentLinkedQueue(); queue.add(rootNode); while (!queue.isEmpty()) { final CommentedConfigurationNode node = queue.remove(); if (node.hasMapChildren()) { for (Map.Entry<Object, ? extends CommentedConfigurationNode> entry : node.getChildrenMap() .entrySet()) { queue.add(entry.getValue()); } } } save(); try { loader.load(); } catch (IOException e) { logger.error("Unable to load configuration!", e); } return this; }