DedicatedModeReplayer( final ErrorHandler errorHandler, final AtomicCounter errorCounter, final ManyToOneConcurrentArrayQueue<Session> closeQueue, final int maxConcurrentSessions) { super("archive-replayer", errorHandler); this.closeQueue = closeQueue; this.errorCounter = errorCounter; this.sessionsQueue = new OneToOneConcurrentArrayQueue<>(maxConcurrentSessions); }
DedicatedModeRecorder( final ErrorHandler errorHandler, final AtomicCounter errorCounter, final ManyToOneConcurrentArrayQueue<Session> closeQueue, final int maxConcurrentSessions) { super("archive-recorder", errorHandler); this.closeQueue = closeQueue; this.errorCounter = errorCounter; this.sessionsQueue = new OneToOneConcurrentArrayQueue<>(maxConcurrentSessions); }
receiverCommandQueue = new OneToOneConcurrentArrayQueue<>(CMD_QUEUE_CAPACITY); senderCommandQueue = new OneToOneConcurrentArrayQueue<>(CMD_QUEUE_CAPACITY);
.rawLogBuffersFactory(mockRawLogFactory) .systemCounters(mockSystemCounters) .receiverCommandQueue(new OneToOneConcurrentArrayQueue<>(Configuration.CMD_QUEUE_CAPACITY)) .nanoClock(() -> currentTime) .cachedNanoClock(mockCachedNanoClock)
/** * Generate QueueFactory for bounded non blocking queues. Max queue size is determined by the input parameter. * The provided WaitStrategy is used to determine behaviour of both producers and consumers when the Queue is full (producer) * or zero (consumer). {@see WaitStrategy#spinWait() , @see WaitStrategy#exponentialBackOff() , @see WaitStrategy#noWaitRetry() } * * @param queueSize Max Queue size * @param strategy Strategy to be employed by producers when Queue is full, or consumers when Queue is zero * @return bounded wait free Queue Factory backed by an Agrona OneToOneConcurrentArrayQueue */ public static <T> QueueFactory<T> singleWriterboundedNonBlockingQueue(final int queueSize, final WaitStrategy<T> strategy) { return () -> new Queue<T>( new OneToOneConcurrentArrayQueue<>( queueSize), strategy, strategy); }
/** * Connect to this Connectable (Stream that is already emitting data) * * <pre> * {@code * * ReactiveSeq.range(0,Integer.MAX_VALUE) .limit(100) .peek(v->value=v) .peek(v->latch.countDown()) .peek(System.out::println) .hotStream(exec) .connect() .limit(100) .futureOperations(ForkJoinPool.commonPool()) .forEach(System.out::println) * * } * </pre> * * * @return Stream connected to the Connectable emitting data */ public default ReactiveSeq<T> connect() { return connect(new OneToOneConcurrentArrayQueue<T>( 256)); }
volatile boolean active = false; volatile boolean completed = false; OneToOneConcurrentArrayQueue<T> data = new OneToOneConcurrentArrayQueue<T>(1024 * 10);
/** * Creates an async.Queue backed by an Agrona OneToOneConcurrentArrayQueue bounded by specified queueSize * Wait strategy used is NoWaitRetry by default for both Consumers and Producers * (both Consumers and Producers will repeatedly retry until successful). Use * withConsumerWaitStrategy & withProducerWaitStrategy methods on the returned queue to change the * wait strategy * <pre> * {@code * queue.withConsumerWaitStrategy(new DirectWaitStrategy()) * .withProducerWaitStrategy(new YieldWait()); * }</pre> * * @param queueSize * @return */ public static <T> QueueFactory<T> singleWriterboundedNonBlockingQueue(final int queueSize) { return () -> new Queue<T>( new OneToOneConcurrentArrayQueue<>( queueSize), new NoWaitRetry<>(), new NoWaitRetry<>()); } /**
@Override public void subscribeAll(Consumer<? super R> onNext, Consumer<? super Throwable> onError, Runnable onCompleteDs) { OneToOneConcurrentArrayQueue<T1> leftQ = new OneToOneConcurrentArrayQueue<T1>(1024); OneToOneConcurrentArrayQueue<T2> rightQ = new OneToOneConcurrentArrayQueue<T2>(1024);
@Override public StreamSubscription subscribe(Consumer<? super R> onNext, Consumer<? super Throwable> onError, Runnable onComplete) { OneToOneConcurrentArrayQueue<T1> leftQ = new OneToOneConcurrentArrayQueue<T1>(1024); OneToOneConcurrentArrayQueue<T2> rightQ = new OneToOneConcurrentArrayQueue<T2>(1024); StreamSubscription leftSub[] = {null}; StreamSubscription rightSub[] = {null};
DedicatedModeRecorder( final ErrorHandler errorHandler, final AtomicCounter errorCounter, final ManyToOneConcurrentArrayQueue<Session> closeQueue, final int maxConcurrentSessions) { super("archive-recorder", errorHandler); this.closeQueue = closeQueue; this.errorCounter = errorCounter; this.sessionsQueue = new OneToOneConcurrentArrayQueue<>(maxConcurrentSessions); }
DedicatedModeReplayer( final ErrorHandler errorHandler, final AtomicCounter errorCounter, final ManyToOneConcurrentArrayQueue<Session> closeQueue, final int maxConcurrentSessions) { super("archive-replayer", errorHandler); this.closeQueue = closeQueue; this.errorCounter = errorCounter; this.sessionsQueue = new OneToOneConcurrentArrayQueue<>(maxConcurrentSessions); }
/** * Generate QueueFactory for bounded non blocking queues. Max queue size is determined by the input parameter. * The provided WaitStrategy is used to determine behaviour of both producers and consumers when the Queue is full (producer) * or zero (consumer). {@see WaitStrategy#spinWait() , @see WaitStrategy#exponentialBackOff() , @see WaitStrategy#noWaitRetry() } * * @param queueSize Max Queue size * @param strategy Strategy to be employed by producers when Queue is full, or consumers when Queue is zero * @return bounded wait free Queue Factory backed by an Agrona OneToOneConcurrentArrayQueue */ public static <T> QueueFactory<T> singleWriterboundedNonBlockingQueue(final int queueSize, final WaitStrategy<T> strategy) { return () -> new Queue<T>( new OneToOneConcurrentArrayQueue<>( queueSize), strategy, strategy); }
/** * Generate QueueFactory for bounded non blocking queues. Max queue size is determined by the input parameter. * The provided WaitStrategy is used to determine behaviour of both producers and consumers when the Queue is full (producer) * or zero (consumer). {@see WaitStrategy#spinWait() , @see WaitStrategy#exponentialBackOff() , @see WaitStrategy#noWaitRetry() } * * @param queueSize Max Queue size * @param strategy Strategy to be employed by producers when Queue is full, or consumers when Queue is zero * @return bounded wait free Queue Factory backed by an Agrona OneToOneConcurrentArrayQueue */ public static <T> QueueFactory<T> singleWriterboundedNonBlockingQueue(final int queueSize, final WaitStrategy<T> strategy) { return () -> new Queue<T>( new OneToOneConcurrentArrayQueue<>( queueSize), strategy, strategy); }
/** * Connect to this HotStream (Stream that is already emitting data) * * <pre> * {@code * * ReactiveSeq.range(0,Integer.MAX_VALUE) .limit(100) .peek(v->value=v) .peek(v->latch.countDown()) .peek(System.out::println) .hotStream(exec) .connect() .limit(100) .futureOperations(ForkJoinPool.commonPool()) .forEach(System.out::println) * * } * </pre> * * * @return Stream connected to the HotStream emitting data */ public default ReactiveSeq<T> connect() { return connect(new OneToOneConcurrentArrayQueue<T>( 256)); }
/** * Creates an async.Queue backed by an Agrona OneToOneConcurrentArrayQueue bounded by specified queueSize * Wait strategy used is NoWaitRetry by default for both Consumers and Producers * (both Consumers and Producers will repeatedly retry until successful). Use * withConsumerWaitStrategy & withProducerWaitStrategy methods on the returned queue to change the * wait strategy * <pre> * {@code * queue.withConsumerWaitStrategy(new DirectWaitStrategy()) * .withProducerWaitStrategy(new YieldWait()); * }</pre> * * @param queueSize * @return */ public static <T> QueueFactory<T> singleWriterboundedNonBlockingQueue(final int queueSize) { return () -> new Queue<T>( new OneToOneConcurrentArrayQueue<>( queueSize), new NoWaitRetry<>(), new NoWaitRetry<>()); } /**
@Setup public synchronized void setup() { for (int i = 0; i < MAX_THREAD_COUNT; i++) { responseQueues[i] = new OneToOneConcurrentArrayQueue<>(RESPONSE_QUEUE_CAPACITY); } values = new int[burstLength]; for (int i = 0; i < burstLength; i++) { values[i] = -(burstLength - i); } ringBuffer = new ManyToOneRingBuffer(new UnsafeBuffer(ByteBuffer.allocateDirect(BUFFER_LENGTH))); consumerThread = new Thread(new Subscriber(ringBuffer, running, responseQueues)); consumerThread.setName("consumer"); consumerThread.start(); }
/** * Creates an async.Queue backed by an Agrona OneToOneConcurrentArrayQueue bounded by specified queueSize * Wait strategy used is NoWaitRetry by default for both Consumers and Producers * (both Consumers and Producers will repeatedly retry until successful). Use * withConsumerWaitStrategy & withProducerWaitStrategy methods on the returned queue to change the * wait strategy * <pre> * {@code * queue.withConsumerWaitStrategy(new DirectWaitStrategy()) * .withProducerWaitStrategy(new YieldWait()); * }</pre> * * @param queueSize * @return */ public static <T> QueueFactory<T> singleWriterboundedNonBlockingQueue(final int queueSize) { return () -> new Queue<T>( new OneToOneConcurrentArrayQueue<>( queueSize), new NoWaitRetry<>(), new NoWaitRetry<>()); } /**
@Setup public synchronized void setup() { for (int i = 0; i < MAX_THREAD_COUNT; i++) { responseQueues[i] = new OneToOneConcurrentArrayQueue<>(RESPONSE_QUEUE_CAPACITY); } values = new int[burstLength]; for (int i = 0; i < burstLength; i++) { values[i] = -(burstLength - i); } ctx = new MediaDriver.Context() .termBufferSparseFile(false) .threadingMode(ThreadingMode.SHARED) .sharedIdleStrategy(new BusySpinIdleStrategy()) .dirDeleteOnStart(true); mediaDriver = MediaDriver.launch(ctx); aeron = Aeron.connect(); publication = aeron.addExclusivePublication(CommonContext.IPC_CHANNEL, STREAM_ID); subscription = aeron.addSubscription(CommonContext.IPC_CHANNEL, STREAM_ID); consumerThread = new Thread(new Subscriber(subscription, running, responseQueues)); consumerThread.setName("consumer"); consumerThread.start(); }
@Setup public synchronized void setup() throws InterruptedException { for (int i = 0; i < MAX_THREAD_COUNT; i++) { responseQueues[i] = new OneToOneConcurrentArrayQueue<>(RESPONSE_QUEUE_CAPACITY); } values = new int[burstLength]; for (int i = 0; i < burstLength; i++) { values[i] = -(burstLength - i); } handler = new Handler(responseQueues); disruptor = new Disruptor<>( Message::new, Configuration.SEND_QUEUE_CAPACITY, (ThreadFactory)Thread::new, ProducerType.MULTI, new BusySpinWaitStrategy()); disruptor.handleEventsWith(handler); disruptor.start(); handler.waitForStart(); }