示例#1
0
    public void ShouldMutateValueFromArray()
    {
        var array = Enumerable.Range(0, 2000).Select(x => new StubValueEvent(x)).ToArray();

        for (var i = 0; i < array.Length; i++)
        {
            ref var evt = ref InternalUtil.ReadValue <StubValueEvent>(array, i);
            evt.TestString = evt.Value.ToString();
        }
示例#2
0
    public void ShouldReadValueAtIndexUnaligned()
    {
        var array = Enumerable.Range(0, 2000).Select(x => new UnalignedEvent(x)).ToArray();

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

            Assert.AreEqual(new UnalignedEvent(i), evt);
        }
    }
示例#3
0
    public void ShouldReadValueFromPointer()
    {
        var index = 0;

        using (var memory = UnmanagedRingBufferMemory.Allocate(2048, () => new StubUnmanagedEvent(index++)))
        {
            for (var i = 0; i < memory.EventCount; i++)
            {
                var evt = InternalUtil.ReadValue <StubUnmanagedEvent>(memory.PointerToFirstEvent, i, memory.EventSize);

                Assert.AreEqual(new StubUnmanagedEvent(i), evt);
            }
        }
    }
 public unsafe int ReadOneILUnsafe()
 {
     return(InternalUtil.ReadValue <Event>(_pointer, Index, sizeof(Event)).Value);
 }
 public int ReadOneIL()
 {
     return(InternalUtil.ReadValue <Event>(_array, Index).Value);
 }