Beispiel #1
0
 /// <summary>
 /// Gets the event for a given sequence in the ring buffer.
 /// </summary>
 /// <param name="sequence">sequence for the event</param>
 /// <remarks>
 /// This method should be used for publishing events to the ring buffer:
 /// <code>
 /// long sequence = ringBuffer.Next();
 /// try
 /// {
 ///     var eventToPublish = ringBuffer[sequence];
 ///     // Configure the event
 /// }
 /// finally
 /// {
 ///     ringBuffer.Publish(sequence);
 /// }
 /// </code>
 ///
 /// This method can also be used for event processing but in most cases the processing is performed
 /// in the provided <see cref="IEventProcessor"/> types or in the event pollers.
 /// </remarks>
 public T this[long sequence]
 {
     [MethodImpl(MethodImplOptions.AggressiveInlining)]
     get
     {
         return(InternalUtil.Read <T>(_entries, _bufferPadRef + (int)(sequence & _indexMask)));
     }
 }
Beispiel #2
0
    public void ShouldReadObjectFromArray()
    {
        var array = Enumerable.Range(0, 2000).Select(x => new StubEvent(x)).ToArray();

        for (var i = 0; i < array.Length; i++)
        {
            var evt = InternalUtil.Read <StubEvent>(array, i);

            Assert.AreEqual(new StubEvent(i), evt);
        }
    }
 public int ReadOneIL()
 {
     return(InternalUtil.Read <Event>(_array, Index).Value);
 }
Beispiel #4
0
 public Event ReadOneIL()
 {
     return(InternalUtil.Read <Event>(_array, NextSequence()));
 }