List of usage examples for com.google.common.collect Queues newLinkedBlockingQueue
public static <E> LinkedBlockingQueue<E> newLinkedBlockingQueue()
From source file:com.zaradai.distributor.messaging.AbstractPendingConnection.java
protected BlockingQueue<Message> createPendingQueue() { return Queues.newLinkedBlockingQueue(); }
From source file:com.zaradai.kunzite.trader.services.AbstractQueueBridge.java
protected BlockingQueue<Object> createQueue() { return Queues.newLinkedBlockingQueue(); }
From source file:org.apache.streams.local.test.providers.NumericMessageProvider.java
@Override public StreamsResultSet readCurrent() { int batchSize = 0; Queue<StreamsDatum> batch = Queues.newLinkedBlockingQueue(); try {//w ww. j av a2 s .c o m while (!this.data.isEmpty() && batchSize < DEFAULT_BATCH_SIZE) { batch.add(this.data.take()); ++batchSize; } } catch (InterruptedException ie) { Thread.currentThread().interrupt(); } // System.out.println("******************\n**\tBatchSize="+batch.size()+"\n******************"); this.complete = batch.isEmpty() && this.data.isEmpty(); return new StreamsResultSet(batch); }
From source file:net.bither.logging.AsyncAppender.java
private AsyncAppender(Appender<ILoggingEvent> delegate) { this.delegate = delegate; this.queue = Queues.newLinkedBlockingQueue(); this.batch = Lists.newArrayListWithCapacity(BATCH_SIZE); this.dispatcher = THREAD_FACTORY.newThread(this); setContext(delegate.getContext());//from w w w. j a v a2 s .c om }
From source file:org.apache.gobblin.runtime.job_monitor.MockKafkaStream.java
public MockKafkaStream(int numStreams) { this.queues = Lists.newArrayList(); this.mockStreams = Lists.newArrayList(); this.offsets = Lists.newArrayList(); for (int i = 0; i < numStreams; i++) { BlockingQueue<FetchedDataChunk> queue = Queues.newLinkedBlockingQueue(); this.queues.add(queue); this.mockStreams.add(createMockStream(queue)); this.offsets.add(new AtomicLong(0)); }//from ww w . jav a 2 s .c o m this.nextStream = new AtomicLong(-1); }
From source file:gobblin.runtime.WorkUnitManager.java
public WorkUnitManager(TaskExecutor taskExecutor, TaskStateTracker taskStateTracker) { // We need a blocking queue to support the producer-consumer model // for managing the submission and execution of work units, and we // need a priority queue to support priority-based execution of // work units. this.workUnitQueue = Queues.newLinkedBlockingQueue(); this.executorService = Executors.newSingleThreadExecutor(ExecutorsUtils.newThreadFactory(Optional.of(LOG))); this.workUnitHandler = new WorkUnitHandler(this.workUnitQueue, taskExecutor, taskStateTracker); }
From source file:org.apache.gobblin.util.limiter.MockRequester.java
public MockRequester(LimiterServerResource limiterServer, long latencyMillis, int requestHandlerThreads) { this.limiterServer = limiterServer; this.latencyMillis = latencyMillis; this.requestHandlerThreads = requestHandlerThreads; this.requestAndCallbackQueue = Queues.newLinkedBlockingQueue(); }
From source file:org.terasology.componentSystem.worldSimulation.GrowthSimulator.java
@Override public void initialise() { world = CoreRegistry.get(WorldProvider.class); air = BlockManager.getInstance().getAir(); grass = BlockManager.getInstance().getBlock("engine:grass"); dirt = BlockManager.getInstance().getBlock("engine:dirt"); blockQueue = Queues.newLinkedBlockingQueue(); running.set(true);/*www . ja v a 2 s. co m*/ executor = Executors.newFixedThreadPool(1); executor.execute(new Runnable() { @Override public void run() { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); while (running.get()) { try { Vector3i blockPos = blockQueue.take(); if (world.isBlockActive(blockPos)) { if (simulate(blockPos)) { Thread.sleep(5000); } } } catch (InterruptedException e) { logger.debug("Thread Interrupted", e); } } } }); }
From source file:org.terasology.world.growth.GrowthSimulator.java
@Override public void initialise() { air = BlockManager.getAir();//from w ww .j a v a 2 s . com grass = blockManager.getBlock("engine:grass"); dirt = blockManager.getBlock("engine:dirt"); blockQueue = Queues.newLinkedBlockingQueue(); running.set(true); executor = Executors.newFixedThreadPool(1); executor.execute(new Runnable() { @Override public void run() { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); while (running.get()) { try { Vector3i blockPos = blockQueue.take(); try (ThreadActivity ignored = ThreadMonitor.startThreadActivity("Simulate")) { if (world.isBlockRelevant(blockPos)) { if (simulate(blockPos)) { Thread.sleep(5000); } } } } catch (InterruptedException e) { ThreadMonitor.addError(e); logger.debug("Thread Interrupted", e); } } } }); }
From source file:com.facebook.nifty.client.TNiftyClientChannelTransport.java
public TNiftyClientChannelTransport(Class<? extends TServiceClient> clientClass, NiftyClientChannel channel) { this.clientClass = clientClass; this.channel = channel; this.methodNameToOneWay = newHashMap(); this.requestBufferTransport = new TChannelBufferOutputTransport(); this.responseBufferTransport = new TChannelBufferInputTransport(ChannelBuffers.buffer(0)); this.queuedResponses = Queues.newLinkedBlockingQueue(); }