feat(memory): transition to AllocationHandle API
Replaced the deprecated Allocator API with the new AllocationHandle API across the codebase. Updated constructors, methods, and tests to use AllocationHandle for memory management. Marked Allocator-based methods as [Obsolete] and provided alternatives. Added OwnershipTransferAnalyzer to detect ownership transfer issues and introduced OwnershipTransferAttribute for marking parameters. Enhanced DefensiveCopyAnalyzer with additional checks for readonly and ValueType instances. Refactored internal memory management in AllocationManager and updated benchmarks, utilities, and documentation to reflect the changes. BREAKING CHANGE: Deprecated Allocator API in favor of AllocationHandle. Updated constructors and methods to use AllocationHandle. Users must migrate to the new API.
This commit is contained in:
@@ -11,7 +11,7 @@ public class TestUnsafeArray
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_arr = new UnsafeArray<int>(16, Allocator.Persistent);
|
||||
_arr = new UnsafeArray<int>(16, AllocationHandle.Persistent);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -12,8 +12,8 @@ public class TestUnsafeBitSet
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_set1 = new UnsafeBitSet(16, Allocator.Persistent, AllocationOption.Clear);
|
||||
_set2 = new UnsafeBitSet(16, Allocator.Persistent, AllocationOption.Clear);
|
||||
_set1 = new UnsafeBitSet(16, AllocationHandle.Persistent, AllocationOption.Clear);
|
||||
_set2 = new UnsafeBitSet(16, AllocationHandle.Persistent, AllocationOption.Clear);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -15,7 +15,7 @@ public class TestUnsafeChunkedQueue
|
||||
[TestMethod]
|
||||
public void BasicEnqueueDequeueTest()
|
||||
{
|
||||
using var queue = new UnsafeChunkedQueue<int>(32, Allocator.Persistent);
|
||||
using var queue = new UnsafeChunkedQueue<int>(32, AllocationHandle.Persistent);
|
||||
|
||||
Assert.IsTrue(queue.IsCreated);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class TestUnsafeChunkedQueue
|
||||
public void ChunkExpansionTest()
|
||||
{
|
||||
// Force chunk expansions by enqueuing more than the chunk capacity
|
||||
using var queue = new UnsafeChunkedQueue<int>(16, Allocator.Persistent);
|
||||
using var queue = new UnsafeChunkedQueue<int>(16, AllocationHandle.Persistent);
|
||||
|
||||
var totalItems = 100;
|
||||
|
||||
@@ -57,7 +57,7 @@ public class TestUnsafeChunkedQueue
|
||||
public void ConcurrentEnqueueDequeueTest()
|
||||
{
|
||||
// Multi-threaded stress test to verify lock-free safety and chunk caching
|
||||
using var queue = new UnsafeChunkedQueue<int>(64, Allocator.Persistent);
|
||||
using var queue = new UnsafeChunkedQueue<int>(64, AllocationHandle.Persistent);
|
||||
var totalElements = 100_000;
|
||||
|
||||
var enqueueTask = Task.Run(() =>
|
||||
|
||||
@@ -11,7 +11,7 @@ public class TestUnsafeHashMap
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_map = new UnsafeHashMap<int, int>(4, Allocator.Persistent);
|
||||
_map = new UnsafeHashMap<int, int>(4, AllocationHandle.Persistent);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -11,7 +11,7 @@ public class TestUnsafeHashSet
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_set = new UnsafeHashSet<int>(4, Allocator.Persistent);
|
||||
_set = new UnsafeHashSet<int>(4, AllocationHandle.Persistent);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -11,7 +11,7 @@ public class TestUnsafeList
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_list = new UnsafeList<int>(4, Allocator.Persistent);
|
||||
_list = new UnsafeList<int>(4, AllocationHandle.Persistent);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -11,7 +11,7 @@ public class TestUnsafeMultiHashMap
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_multiHashMap = new UnsafeMultiHashMap<int, int>(4, Allocator.Persistent);
|
||||
_multiHashMap = new UnsafeMultiHashMap<int, int>(4, AllocationHandle.Persistent);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -10,7 +10,7 @@ public class TestUnsafeQueue
|
||||
[TestInitialize]
|
||||
public void Setup()
|
||||
{
|
||||
_queue = new UnsafeQueue<int>(4, LowLevel.Buffer.Allocator.Persistent);
|
||||
_queue = new UnsafeQueue<int>(4, LowLevel.Buffer.AllocationHandle.Persistent);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -11,7 +11,7 @@ public class TestUnsafeSlotMap
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_slotMap = new UnsafeSlotMap<int>(16, Allocator.Persistent);
|
||||
_slotMap = new UnsafeSlotMap<int>(16, AllocationHandle.Persistent);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -11,7 +11,7 @@ public class TestUnsafeSparseSet
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_sparseSet = new UnsafeSparseSet<int>(16, Allocator.Persistent);
|
||||
_sparseSet = new UnsafeSparseSet<int>(16, AllocationHandle.Persistent);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
@@ -11,7 +11,7 @@ public class TestUnsafeStack
|
||||
[TestInitialize]
|
||||
public void Initialize()
|
||||
{
|
||||
_stack = new UnsafeStack<int>(16, Allocator.Persistent);
|
||||
_stack = new UnsafeStack<int>(16, AllocationHandle.Persistent);
|
||||
}
|
||||
|
||||
[TestCleanup]
|
||||
|
||||
Reference in New Issue
Block a user