コード例 #1
0
 public void CanAllocateFromEmptyList(AllocationMode allocationMode)
 {
     using (var list = new AtomicFreeList <AtomicNode>(allocationMode))
     {
         var node = list.Acquire();
         Assert.AreNotEqual(IntPtr.Zero, (IntPtr)node);
         list.Release(node);
     }
 }
コード例 #2
0
    public void EphemeralList_DoesNotReuseAllocations()
    {
        using (var list = new AtomicFreeList <AtomicNode>(AllocationMode.Ephemeral))
        {
            var node = list.Acquire();
            list.Release(node);

            // Prevent the underlying allocator from just handing us back the same pointer
            var dummy = Utility.AllocateUnsafe <AtomicNode>(1, Allocator.TempJob);

            var secondNode = list.Acquire();
            Assert.AreNotEqual((IntPtr)node, (IntPtr)secondNode);
            list.Release(secondNode);
            Utility.FreeUnsafe(dummy, Allocator.TempJob);
        }
    }