fixed code formatter.

minor bug fixes to a few systems as well.
This commit is contained in:
Stan44 2025-05-11 22:47:43 -05:00
parent 657e19f48f
commit 01d2cbf4b3
25 changed files with 914 additions and 912 deletions

View File

@ -27,19 +27,19 @@ namespace AdvChkSys
/// <summary>
/// Creates a new WorldConstraints object.
/// </summary>
public static WorldConstraints CreateDefaultConstraints() => new WorldConstraints();
public static WorldConstraints CreateDefaultConstraints() => new();
/// <summary>
/// Creates a new 2D chunk manager with optional constraints.
/// </summary>
public static ChunkManager2D<byte> Create2DManager(WorldConstraints? constraints = null) =>
new ChunkManager2D<byte>(constraints);
new(constraints);
/// <summary>
/// Creates a new 3D chunk manager with optional constraints.
/// </summary>
public static ChunkManager3D<byte> Create3DManager(WorldConstraints? constraints = null) =>
new ChunkManager3D<byte>(constraints);
new(constraints);
/// <summary>
/// Gets a detailed report of the current memory usage by the chunk system.
@ -73,13 +73,13 @@ namespace AdvChkSys
/// Creates a spatial index for 2D chunks.
/// </summary>
public static SpatialChunkIndex<Chunk2D<T>> CreateSpatialIndex2D<T>() =>
new SpatialChunkIndex<Chunk2D<T>>();
new();
/// <summary>
/// Creates a spatial index for 3D chunks.
/// </summary>
public static SpatialChunkIndex<Chunk3D<T>> CreateSpatialIndex3D<T>() =>
new SpatialChunkIndex<Chunk3D<T>>();
new();
/// <summary>
/// Configures the threading system for high throughput.

View File

@ -51,8 +51,10 @@ namespace AdvChkSys.Diagnostics
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
var memStatus = new MemoryHelper.MEMORYSTATUSEX();
memStatus.dwLength = (uint)Marshal.SizeOf(typeof(MemoryHelper.MEMORYSTATUSEX));
var memStatus = new MemoryHelper.MEMORYSTATUSEX
{
dwLength = (uint)Marshal.SizeOf(typeof(MemoryHelper.MEMORYSTATUSEX))
};
if (MemoryHelper.GlobalMemoryStatusEx(ref memStatus))
{
return memStatus.ullTotalPhys;

View File

@ -20,7 +20,7 @@ namespace AdvChkSys.Manager
private readonly WorldConstraints? _constraints;
private readonly int _capacity;
private readonly Dictionary<(int, int), Task<Chunk2D<T>>> _loadingChunks = new();
private readonly object _lock = new object();
private readonly object _lock = new();
/// <summary>
/// Delegate for custom air check logic

View File

@ -13,9 +13,9 @@ namespace AdvChkSys.Resources
public static class ChunkResourceManager
{
// Example: Track allocated chunks (for diagnostics, pooling, or resource limits)
private static readonly ConcurrentDictionary<IChunk, DateTime> _allocatedChunks = new ConcurrentDictionary<IChunk, DateTime>();
private static readonly ConcurrentDictionary<IChunk, DateTime> _allocatedChunks = new();
private static int _allocatedChunkCount;
private static readonly object _lock = new object();
private static readonly object _lock = new();
private static readonly HashSet<IChunk> _activeChunks = new();
/// <summary>

View File

@ -221,8 +221,8 @@ namespace AdvChkSys.Threading
// Cancel all pending operations
while (queue.Count > 0)
{
var operation = queue.Dequeue();
operation.Completion.TrySetCanceled();
var (Operation, Completion) = queue.Dequeue();
Completion.TrySetCanceled();
}
return count;

View File

@ -16,7 +16,7 @@ namespace AdvChkSys.Threading
private static bool _currentThreadIsProcessingItems;
// The list of tasks to be executed
private readonly LinkedList<Task> _tasks = new LinkedList<Task>();
private readonly LinkedList<Task> _tasks = new();
// The maximum concurrency level allowed by this scheduler.
private int _maximumConcurrencyLevel;

View File

@ -115,8 +115,8 @@ namespace AdvChkSys.Util
{
lock (_lock)
{
foreach (var node in _lruList)
yield return node.value;
foreach (var (key, value) in _lruList)
yield return value;
}
}
}