Enhance JobScheduler and related classes
Added XML documentation comments to the `JobScheduler` class and its methods. Added a new method `GetJobStatus` in the `JobScheduler` class for job status retrieval. Added a new `CollectionHandle` struct for collection management. Added a new test class `TestUnsafeSparseSet` with unit tests for `UnsafeSparseSet`. Changed the `WorkerThread` class to improve job retrieval logic with a new `FindJob` method. Changed the `DynamicArena` class by removing commented-out code to streamline memory management. Removed commented-out code in the `WorkerThread` class for improved readability. Removed the `ArenaAllocator` struct from `AllocationManager` to clean up unused code. Removed the `ParallelWriter` struct from `UnsafeSparseSet`, indicating a shift in handling sparse sets.
This commit is contained in:
@@ -51,7 +51,6 @@ public readonly unsafe struct AllocationInfo
|
||||
/// </summary>
|
||||
public static unsafe class AllocationManager
|
||||
{
|
||||
|
||||
private unsafe struct ArenaAllocator : IAllocator, IDisposable
|
||||
{
|
||||
private DynamicArena _arena;
|
||||
|
||||
@@ -49,15 +49,6 @@ public unsafe struct Arena : IDisposable
|
||||
throw new ObjectDisposedException(nameof(DynamicArena));
|
||||
}
|
||||
|
||||
//var offset = _offset + alignment - 1 & ~(alignment - 1);
|
||||
//if (offset + size > _size)
|
||||
//{
|
||||
// return null;
|
||||
//}
|
||||
|
||||
//_offset = offset + size;
|
||||
//var ptr = _buffer + offset;
|
||||
|
||||
nuint currentOffset, newOffset, alignedOffset;
|
||||
|
||||
do
|
||||
|
||||
@@ -90,22 +90,6 @@ public unsafe struct DynamicArena : IDisposable
|
||||
// Release the spinlock
|
||||
Interlocked.Exchange(ref _nodeCreationLock, 0);
|
||||
}
|
||||
|
||||
//var newNode = (ArenaNode*)Malloc(SizeOf<ArenaNode>());
|
||||
//try
|
||||
//{
|
||||
// newNode->arena = new Arena(size);
|
||||
// newNode->next = null;
|
||||
|
||||
// _current->next = newNode;
|
||||
// _current = newNode;
|
||||
// return true;
|
||||
//}
|
||||
//catch
|
||||
//{
|
||||
// Free(newNode);
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -162,9 +146,6 @@ public unsafe struct DynamicArena : IDisposable
|
||||
_current = _root;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes all arenas and frees associated memory.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (_root == null)
|
||||
|
||||
@@ -6,25 +6,6 @@ namespace Misaki.HighPerformance.LowLevel.Buffer;
|
||||
/// <summary>
|
||||
/// A lock-free, thread-safe variable-size allocator that manages memory blocks of different sizes.
|
||||
/// Optimized for high-performance scenarios with frequent allocations and deallocations.
|
||||
///
|
||||
/// Example usage:
|
||||
/// <code>
|
||||
/// // Create a free list with multiple size buckets
|
||||
/// var freeList = new FreeList();
|
||||
///
|
||||
/// // Allocate a 70-byte block
|
||||
/// var block = freeList.Allocate(70);
|
||||
/// if (block.IsValid)
|
||||
/// {
|
||||
/// // Use the memory block...
|
||||
///
|
||||
/// // Free the block when done
|
||||
/// freeList.Free(block);
|
||||
/// }
|
||||
///
|
||||
/// // Dispose when finished
|
||||
/// freeList.Dispose();
|
||||
/// </code>
|
||||
/// </summary>
|
||||
[StructLayout(LayoutKind.Explicit, Size = 256)] // Cache line aligned to prevent false sharing
|
||||
public unsafe struct FreeList : IDisposable
|
||||
@@ -476,10 +457,6 @@ public unsafe struct FreeList : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disposes the free list and frees all allocated memory.
|
||||
/// Note: This method is NOT thread-safe by design as requested.
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
if (Interlocked.CompareExchange(ref _disposed, 1, 0) == 0)
|
||||
|
||||
Reference in New Issue
Block a user