fixed code formatter.
minor bug fixes to a few systems as well.
This commit is contained in:
parent
657e19f48f
commit
01d2cbf4b3
@ -27,19 +27,19 @@ namespace AdvChkSys
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new WorldConstraints object.
|
/// Creates a new WorldConstraints object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static WorldConstraints CreateDefaultConstraints() => new WorldConstraints();
|
public static WorldConstraints CreateDefaultConstraints() => new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new 2D chunk manager with optional constraints.
|
/// Creates a new 2D chunk manager with optional constraints.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ChunkManager2D<byte> Create2DManager(WorldConstraints? constraints = null) =>
|
public static ChunkManager2D<byte> Create2DManager(WorldConstraints? constraints = null) =>
|
||||||
new ChunkManager2D<byte>(constraints);
|
new(constraints);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a new 3D chunk manager with optional constraints.
|
/// Creates a new 3D chunk manager with optional constraints.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static ChunkManager3D<byte> Create3DManager(WorldConstraints? constraints = null) =>
|
public static ChunkManager3D<byte> Create3DManager(WorldConstraints? constraints = null) =>
|
||||||
new ChunkManager3D<byte>(constraints);
|
new(constraints);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a detailed report of the current memory usage by the chunk system.
|
/// 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.
|
/// Creates a spatial index for 2D chunks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static SpatialChunkIndex<Chunk2D<T>> CreateSpatialIndex2D<T>() =>
|
public static SpatialChunkIndex<Chunk2D<T>> CreateSpatialIndex2D<T>() =>
|
||||||
new SpatialChunkIndex<Chunk2D<T>>();
|
new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates a spatial index for 3D chunks.
|
/// Creates a spatial index for 3D chunks.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static SpatialChunkIndex<Chunk3D<T>> CreateSpatialIndex3D<T>() =>
|
public static SpatialChunkIndex<Chunk3D<T>> CreateSpatialIndex3D<T>() =>
|
||||||
new SpatialChunkIndex<Chunk3D<T>>();
|
new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Configures the threading system for high throughput.
|
/// Configures the threading system for high throughput.
|
||||||
|
|||||||
@ -51,8 +51,10 @@ namespace AdvChkSys.Diagnostics
|
|||||||
{
|
{
|
||||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||||
{
|
{
|
||||||
var memStatus = new MemoryHelper.MEMORYSTATUSEX();
|
var memStatus = new MemoryHelper.MEMORYSTATUSEX
|
||||||
memStatus.dwLength = (uint)Marshal.SizeOf(typeof(MemoryHelper.MEMORYSTATUSEX));
|
{
|
||||||
|
dwLength = (uint)Marshal.SizeOf(typeof(MemoryHelper.MEMORYSTATUSEX))
|
||||||
|
};
|
||||||
if (MemoryHelper.GlobalMemoryStatusEx(ref memStatus))
|
if (MemoryHelper.GlobalMemoryStatusEx(ref memStatus))
|
||||||
{
|
{
|
||||||
return memStatus.ullTotalPhys;
|
return memStatus.ullTotalPhys;
|
||||||
|
|||||||
@ -20,7 +20,7 @@ namespace AdvChkSys.Manager
|
|||||||
private readonly WorldConstraints? _constraints;
|
private readonly WorldConstraints? _constraints;
|
||||||
private readonly int _capacity;
|
private readonly int _capacity;
|
||||||
private readonly Dictionary<(int, int), Task<Chunk2D<T>>> _loadingChunks = new();
|
private readonly Dictionary<(int, int), Task<Chunk2D<T>>> _loadingChunks = new();
|
||||||
private readonly object _lock = new object();
|
private readonly object _lock = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Delegate for custom air check logic
|
/// Delegate for custom air check logic
|
||||||
|
|||||||
@ -13,9 +13,9 @@ namespace AdvChkSys.Resources
|
|||||||
public static class ChunkResourceManager
|
public static class ChunkResourceManager
|
||||||
{
|
{
|
||||||
// Example: Track allocated chunks (for diagnostics, pooling, or resource limits)
|
// 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 int _allocatedChunkCount;
|
||||||
private static readonly object _lock = new object();
|
private static readonly object _lock = new();
|
||||||
private static readonly HashSet<IChunk> _activeChunks = new();
|
private static readonly HashSet<IChunk> _activeChunks = new();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -221,8 +221,8 @@ namespace AdvChkSys.Threading
|
|||||||
// Cancel all pending operations
|
// Cancel all pending operations
|
||||||
while (queue.Count > 0)
|
while (queue.Count > 0)
|
||||||
{
|
{
|
||||||
var operation = queue.Dequeue();
|
var (Operation, Completion) = queue.Dequeue();
|
||||||
operation.Completion.TrySetCanceled();
|
Completion.TrySetCanceled();
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
|
|||||||
@ -16,7 +16,7 @@ namespace AdvChkSys.Threading
|
|||||||
private static bool _currentThreadIsProcessingItems;
|
private static bool _currentThreadIsProcessingItems;
|
||||||
|
|
||||||
// The list of tasks to be executed
|
// 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.
|
// The maximum concurrency level allowed by this scheduler.
|
||||||
private int _maximumConcurrencyLevel;
|
private int _maximumConcurrencyLevel;
|
||||||
|
|||||||
@ -115,8 +115,8 @@ namespace AdvChkSys.Util
|
|||||||
{
|
{
|
||||||
lock (_lock)
|
lock (_lock)
|
||||||
{
|
{
|
||||||
foreach (var node in _lruList)
|
foreach (var (key, value) in _lruList)
|
||||||
yield return node.value;
|
yield return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user