public BytesBoundedLinkedQueue(long capacity) { delegate = new ConcurrentLinkedQueue<>(); this.capacity = capacity; }
public StageExecution( String stageName, String part, Configuration config, Collection<Step<?>> pipeline, int orderingGuarantees ) { this.stageName = stageName; this.part = part; this.config = config; this.pipeline = pipeline; this.orderingGuarantees = orderingGuarantees; this.shouldRecycle = (orderingGuarantees & Step.RECYCLE_BATCHES) != 0; this.recycled = shouldRecycle ? new ConcurrentLinkedQueue<>() : null; }
public void put(Node node, ClientRequest request) { // the lock protects the put from a concurrent removal of the queue for the node synchronized (unsent) { ConcurrentLinkedQueue<ClientRequest> requests = unsent.get(node); if (requests == null) { requests = new ConcurrentLinkedQueue<>(); unsent.put(node, requests); } requests.add(request); } }
@Override public Queue<String> create(String[] elements) { return new ConcurrentLinkedQueue<>(MinimalCollection.of(elements)); } })
/** Creates an empty {@code ConcurrentLinkedQueue}. */ @GwtIncompatible // ConcurrentLinkedQueue public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue() { return new ConcurrentLinkedQueue<E>(); }
CachedWorkerPool(long keepAliveTime, TimeUnit unit, ThreadFactory threadFactory) { this.keepAliveTime = unit != null ? unit.toNanos(keepAliveTime) : 0L; this.expiringWorkerQueue = new ConcurrentLinkedQueue<ThreadWorker>(); this.allWorkers = new CompositeDisposable(); this.threadFactory = threadFactory; ScheduledExecutorService evictor = null; Future<?> task = null; if (unit != null) { evictor = Executors.newScheduledThreadPool(1, EVICTOR_THREAD_FACTORY); task = evictor.scheduleWithFixedDelay(this, this.keepAliveTime, this.keepAliveTime, TimeUnit.NANOSECONDS); } evictorService = evictor; evictorTask = task; }
/** * Creates a {@code ConcurrentLinkedQueue} containing the elements of the specified iterable, in * the order they are returned by the iterable's iterator. */ @GwtIncompatible // ConcurrentLinkedQueue public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue( Iterable<? extends E> elements) { if (elements instanceof Collection) { return new ConcurrentLinkedQueue<E>(Collections2.cast(elements)); } ConcurrentLinkedQueue<E> queue = new ConcurrentLinkedQueue<E>(); Iterables.addAll(queue, elements); return queue; }
/** Creates an empty {@code ConcurrentLinkedQueue}. */ @GwtIncompatible // ConcurrentLinkedQueue public static <E> ConcurrentLinkedQueue<E> newConcurrentLinkedQueue() { return new ConcurrentLinkedQueue<E>(); }
public RedissonMap(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K, V> options) { super(codec, commandExecutor, name); this.redisson = redisson; this.options = options; if (options != null && options.getWriteMode() == WriteMode.WRITE_BEHIND) { writeBehindTasks = new ConcurrentLinkedQueue<Runnable>(); } else { writeBehindTasks = null; } }
public RedissonMap(Codec codec, CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K, V> options) { super(codec, commandExecutor, name); this.redisson = redisson; this.options = options; if (options != null && options.getWriteMode() == WriteMode.WRITE_BEHIND) { writeBehindTasks = new ConcurrentLinkedQueue<Runnable>(); } else { writeBehindTasks = null; } }
public RedissonMap(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K, V> options) { super(commandExecutor, name); this.redisson = redisson; this.options = options; if (options != null && options.getWriteMode() == WriteMode.WRITE_BEHIND) { writeBehindTasks = new ConcurrentLinkedQueue<Runnable>(); } else { writeBehindTasks = null; } }
public RedissonMap(CommandAsyncExecutor commandExecutor, String name, RedissonClient redisson, MapOptions<K, V> options) { super(commandExecutor, name); this.redisson = redisson; this.options = options; if (options != null && options.getWriteMode() == WriteMode.WRITE_BEHIND) { writeBehindTasks = new ConcurrentLinkedQueue<Runnable>(); } else { writeBehindTasks = null; } }
@SafeVarargs private static <E> Queue<E> queue( E... items ) { Queue<E> queue = new ConcurrentLinkedQueue<>(); for ( E item : items ) { queue.offer( item ); } return queue; }
@Override public void accept(final GroupedFlowable<K, V> f) { result.put(f.getKey(), new ConcurrentLinkedQueue<V>()); f.subscribe(new Consumer<V>() { @Override public void accept(V v) { result.get(f.getKey()).add(v); } }); } });
@Override public void accept(final GroupedObservable<K, V> o) { result.put(o.getKey(), new ConcurrentLinkedQueue<V>()); o.subscribe(new Consumer<V>() { @Override public void accept(V v) { result.get(o.getKey()).add(v); } }); } });
public EphemeralIdGenerator( IdType idType, IdTypeConfiguration idTypeConfiguration ) { this.idType = idType; this.freeList = idType != null && idTypeConfiguration.allowAggressiveReuse() ? new ConcurrentLinkedQueue<>() : null; }
@Override @SuppressWarnings({ "unchecked", "rawtypes" }) protected void subscribeActual(Subscriber<? super GroupedFlowable<K, V>> s) { final Map<Object, GroupedUnicast<K, V>> groups; final Queue<GroupedUnicast<K, V>> evictedGroups; try { if (mapFactory == null) { evictedGroups = null; groups = new ConcurrentHashMap<Object, GroupedUnicast<K, V>>(); } else { evictedGroups = new ConcurrentLinkedQueue<GroupedUnicast<K, V>>(); Consumer<Object> evictionAction = (Consumer) new EvictionAction<K, V>(evictedGroups); groups = (Map) mapFactory.apply(evictionAction); } } catch (Exception e) { Exceptions.throwIfFatal(e); s.onSubscribe(EmptyComponent.INSTANCE); s.onError(e); return; } GroupBySubscriber<T, K, V> subscriber = new GroupBySubscriber<T, K, V>(s, keySelector, valueSelector, bufferSize, delayError, groups, evictedGroups); source.subscribe(subscriber); }
Segment( LocalCache<K, V> map, int initialCapacity, long maxSegmentWeight, StatsCounter statsCounter) { this.map = map; this.maxSegmentWeight = maxSegmentWeight; this.statsCounter = checkNotNull(statsCounter); initTable(newEntryArray(initialCapacity)); keyReferenceQueue = map.usesKeyReferences() ? new ReferenceQueue<K>() : null; valueReferenceQueue = map.usesValueReferences() ? new ReferenceQueue<V>() : null; recencyQueue = map.usesAccessQueue() ? new ConcurrentLinkedQueue<ReferenceEntry<K, V>>() : LocalCache.<ReferenceEntry<K, V>>discardingQueue(); writeQueue = map.usesWriteQueue() ? new WriteQueue<K, V>() : LocalCache.<ReferenceEntry<K, V>>discardingQueue(); accessQueue = map.usesAccessQueue() ? new AccessQueue<K, V>() : LocalCache.<ReferenceEntry<K, V>>discardingQueue(); }
AbstractCacheSet(ConcurrentMap<?, ?> map) { this.map = map; }
private void processRecords(OneInputStreamTaskTestHarness<String, String> testHarness) throws Exception { ConcurrentLinkedQueue<Object> expectedOutput = new ConcurrentLinkedQueue<>(); testHarness.processElement(new StreamRecord<>("10"), 0, 0); testHarness.processElement(new StreamRecord<>("20"), 0, 0); testHarness.processElement(new StreamRecord<>("30"), 0, 0); testHarness.waitForInputProcessing(); expectedOutput.add(new StreamRecord<>("10")); expectedOutput.add(new StreamRecord<>("20")); expectedOutput.add(new StreamRecord<>("30")); TestHarnessUtil.assertOutputEquals("Output was not correct.", expectedOutput, testHarness.getOutput()); }