예제 #1
0
        public void Should_return_correct_values_for_multiclaim2()
        {
            var blockingWaitStrategy = new BlockingWaitStrategy();
            var writer = new ConcurrentRingBufferWriter(5, blockingWaitStrategy);

            var first  = writer.Claim(3);
            var second = writer.Claim(4);

            Assert.That(first, Is.EqualTo(2));
            Assert.That(second, Is.EqualTo(6));

            writer.Commit(second, 4);
            writer.Commit(first, 3);
        }
예제 #2
0
        public void Should_return_correct_values_for_multiclaim2()
        {
            var blockingWaitStrategy = new BlockingWaitStrategy();
            var writer = new ConcurrentRingBufferWriter(5, blockingWaitStrategy);

            var first = writer.Claim(3);
            var second = writer.Claim(4);

            Assert.That(first, Is.EqualTo(2));
            Assert.That(second, Is.EqualTo(6));

            writer.Commit(second, 4);
            writer.Commit(first, 3);
        }
        public ManyWritersManyReadersOneReader(uint bufferPower, int maxSequenceValue, bool delay)
        {
            _maxSequenceValue = maxSequenceValue;
            _delay            = delay;

            _buffer = new RingBuffer <int>(bufferPower);

            _waitStrategy = new BlockingWaitStrategy();

            // init
            _committer  = new ConcurrentRingBufferWriter(_buffer.Size, _waitStrategy);
            _journaler  = new RingBufferReader(_waitStrategy);
            _replicator = new RingBufferReader(_waitStrategy);
            _processor  = new RingBufferReader(_waitStrategy);

            // setup
            _committer.DependsOn(_processor);
            _journaler.DependsOn(_committer);
            _replicator.DependsOn(_committer);
            _processor.DependsOn(_journaler, _replicator);
        }