public Payloads(int capacity, uint maxPayloadSize) { m_PayloadSize = maxPayloadSize; m_Handles = new UnsafeAtomicFreeList(capacity, Allocator.Persistent); m_PayloadArray = new UnsafeBaselibNetworkArray(capacity * (int)maxPayloadSize); m_EndpointArray = new UnsafeBaselibNetworkArray(capacity * (int)Binding.Baselib_RegisteredNetwork_Endpoint_MaxSize); }
//[Repeat( 25 )] public void AtomicFreeList() { using (var freeList = new UnsafeAtomicFreeList(1024, Allocator.Persistent)) { var job = new FreeJob { freeList = freeList }; job.Schedule(1024 * 100, 1).Complete(); var foo = new HashSet <int>(); for (int i = 0; i < freeList.Capacity; ++i) { var idx = freeList.Pop(); Assert.IsTrue(idx < 1024 && idx >= 0); Assert.IsFalse(foo.Contains(idx)); } Assert.AreEqual(-1, freeList.Pop()); } }