< Summary

Information
Class: GridForge.Grids.Pools
Assembly: GridForge
File(s): /home/runner/work/GridForge/GridForge/src/GridForge/Grids/Support/Pools.cs
Line coverage
100%
Covered lines: 40
Uncovered lines: 0
Coverable lines: 40
Total lines: 85
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.cctor()100%11100%
ClearPools()100%11100%

File(s)

/home/runner/work/GridForge/GridForge/src/GridForge/Grids/Support/Pools.cs

#LineLine coverage
 1//=======================================================================
 2// Pools.cs
 3//=======================================================================
 4// MIT License, Copyright (c) 2024–present David Oravsky (mrdav30)
 5// See LICENSE file in the project root for full license information.
 6//=======================================================================
 7
 8using GridForge.Grids.Storage;
 9using GridForge.Spatial;
 10using SwiftCollections;
 11using SwiftCollections.Pool;
 12
 13namespace GridForge.Grids;
 14
 15internal static class Pools
 16{
 17    #region Grid Pooling
 18
 19    /// <summary>
 20    /// Object pool for reusing <see cref="VoxelGrid"/> instances.
 21    /// </summary>
 122    public static readonly SwiftObjectPool<VoxelGrid> GridPool = new(
 123        createFunc: () => new VoxelGrid(),
 124        actionOnRelease: grid => grid.Reset()
 125    );
 26
 27    /// <summary>
 28    /// Object pool for reusing <see cref="Voxel"/> instances.
 29    /// </summary>
 130    public static readonly SwiftObjectPool<Voxel> VoxelPool = new(
 131        createFunc: () => new Voxel(),
 132        actionOnRelease: voxel => voxel.Reset()
 133    );
 34
 135    public static readonly SwiftObjectPool<SwiftSparseMap<ScanCell>> ScanCellMapPool = new(
 136        createFunc: () => new SwiftSparseMap<ScanCell>(),
 137        actionOnRelease: map => map.Clear()
 138    );
 39
 140    public static readonly SwiftObjectPool<SwiftSparseMap<SparseVoxelBlock>> SparseVoxelBlockMapPool = new(
 141        createFunc: () => new SwiftSparseMap<SparseVoxelBlock>(),
 142        actionOnRelease: map => map.Clear()
 143    );
 44
 145    public static readonly SwiftObjectPool<SparseVoxelBlock> SparseVoxelBlockPool = new(
 146        createFunc: () => new SparseVoxelBlock(),
 147        actionOnRelease: block => block.Clear()
 148    );
 49
 150    public static readonly SwiftDictionaryPool<int, int> SparseVoxelBlockCapacityPool = new();
 51
 52    /// <summary>
 53    /// Object pool for reusing <see cref="ScanCell"/> instances.
 54    /// </summary>
 155    public static readonly SwiftObjectPool<ScanCell> ScanCellPool = new(
 156        createFunc: () => new ScanCell(),
 157        actionOnRelease: cell => cell.Reset()
 158    );
 59
 60    #endregion
 61
 62    #region Node Pooling
 63
 164    public static readonly SwiftDictionaryPool<WorldVoxelIndex, SwiftBucket<IVoxelOccupant>> VoxelOccupantDictionaryPool
 65
 166    public static readonly SwiftObjectPool<SwiftBucket<IVoxelOccupant>> VoxelOccupantBucketPool = new(
 167        createFunc: () => new SwiftBucket<IVoxelOccupant>(),
 168        actionOnRelease: bucket => bucket.Clear()
 169    );
 70
 71    #endregion
 72
 73    public static void ClearPools()
 74    {
 275        GridPool.Clear();
 276        VoxelPool.Clear();
 277        ScanCellMapPool.Clear();
 278        SparseVoxelBlockMapPool.Clear();
 279        SparseVoxelBlockPool.Clear();
 280        SparseVoxelBlockCapacityPool.Clear();
 281        ScanCellPool.Clear();
 282        VoxelOccupantDictionaryPool.Clear();
 283        VoxelOccupantBucketPool.Clear();
 284    }
 85}

Methods/Properties

.cctor()
ClearPools()