Ejemplo n.º 1
0
        public void ShouldClaimAndGetInSeparateThread()
        {
            var events = GetEvents(0, 0);

            var expectedEvent = new StubEvent(2701);

            var       sequence = _ringBuffer.Next();
            StubEvent oldEvent = _ringBuffer[sequence];

            oldEvent.Copy(expectedEvent);
            _ringBuffer.Publish(sequence);

            Assert.AreEqual(expectedEvent, events.Result[0]);
        }
Ejemplo n.º 2
0
        public void ShouldClaimAndGetWithTimeout()
        {
            Assert.AreEqual(Sequencer.InitialCursorValue, _ringBuffer.Cursor);

            var expectedEvent = new StubEvent(2701);

            long      claimSequence = _ringBuffer.Next();
            StubEvent oldEvent      = _ringBuffer[claimSequence];

            oldEvent.Copy(expectedEvent);
            _ringBuffer.Publish(claimSequence);

            long sequence = _sequenceBarrier.WaitFor(0, TimeSpan.FromMilliseconds(5));

            Assert.AreEqual(0, sequence);

            var evt = _ringBuffer[sequence];

            Assert.AreEqual(expectedEvent, evt);

            Assert.AreEqual(0L, _ringBuffer.Cursor);
        }