feat(memory): refactor allocation and add new queue
Refactored memory management by removing safety checks and introducing `MemoryHandle` for centralized tracking. Simplified allocation logic across allocators and enhanced `Dispose` methods for better resource cleanup. Added `UnsafeChunkedQueue<T>`, a lock-free, dynamically resizing queue with chunk-based memory management, supporting parallel producers and consumers. Updated unit tests to validate new queue functionality and ensure compatibility with refactored memory logic. Incremented assembly version to 1.6.12. BREAKING CHANGE: Removed `#if MHP_ENABLE_SAFETY_CHECKS` blocks, altering memory validation behavior.
This commit is contained in:
@@ -63,11 +63,9 @@ public class TestAllocationManager
|
||||
var ptr1 = new MemoryBlock(1024, 8, scope.AllocationHandle);
|
||||
|
||||
Assert.IsTrue(ptr1.IsCreated);
|
||||
Assert.AreEqual(1024u, ((VirtualStack*)scope.AllocationHandle.State)->Allocated);
|
||||
|
||||
ptr1.Dispose();
|
||||
scope.Dispose();
|
||||
Assert.AreEqual(0u, ((VirtualStack*)scope.AllocationHandle.State)->Allocated);
|
||||
});
|
||||
|
||||
thread.Start();
|
||||
@@ -76,10 +74,10 @@ public class TestAllocationManager
|
||||
var ptr2 = new MemoryBlock(1024, 8, scope.AllocationHandle);
|
||||
|
||||
Assert.IsTrue(ptr2.IsCreated);
|
||||
Assert.AreEqual(1024u, ((VirtualStack*)scope.AllocationHandle.State)->Allocated);
|
||||
|
||||
ptr2.Dispose();
|
||||
scope.Dispose();
|
||||
Assert.AreEqual(0u, ((VirtualStack*)scope.AllocationHandle.State)->Allocated);
|
||||
|
||||
thread.Join();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user