Skip to content

Commit b3e4e3d

Browse files
cleanup a bit
1 parent 048e94e commit b3e4e3d

7 files changed

Lines changed: 37 additions & 28 deletions

File tree

MemoryManager.Core/CompactionStyle.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ namespace MemoryManager.Core
1010
{
1111
public enum CompactionStyle
1212
{
13-
Full, // The current "Nuclear Reset" (Default for SlowLane)
14-
GoodEnough, // Stops the moment a target gap is opened
15-
None // Defragments strictly via free-list coalescing
13+
Full, // The current "Nuclear Reset" (Default for SlowLane)
14+
GoodEnough, // Stops the moment a target gap is opened
15+
None // Defragments strictly via free-list coalescing
1616
}
17-
}
17+
}

MemoryManager.Core/IMemoryAllocator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* PROGRAMMER: Peter Geinitz (Wayfarer)
88
*/
99

10-
using System.Diagnostics;
10+
// ReSharper disable UnusedMemberInSuper.Global
1111

1212
namespace MemoryManager.Core
1313
{

MemoryManager.Lanes/SlabLane.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
* PROGRAMMER: Peter Geinitz (Wayfarer)
77
*/
88

9+
// ReSharper disable MemberCanBePrivate.Global
10+
911
using ExtendedSystemObjects;
1012
using MemoryManager.Core;
1113
using System.Runtime.CompilerServices;
@@ -127,6 +129,9 @@ public unsafe SlabLane(int size, SlowLane slowLane, int maxEntries = 1024, Memor
127129
/// <summary>
128130
/// Gets the native raw heap memory handle.
129131
/// </summary>
132+
/// <value>
133+
/// The buffer.
134+
/// </value>
130135
public nint Buffer { get; private set; }
131136

132137
/// <inheritdoc />

MemoryManager.Tests/MemoryArenaInlineTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ public void MemoryArena_GenerationalRedirection_WorksCorrectly()
6060
Assert.AreEqual(3.14f, result.Y, 0.001f);
6161
}
6262

63+
/// <summary>
64+
/// Memories the arena zombie handle throws exception.
65+
/// </summary>
6366
[TestMethod]
6467
public void MemoryArena_ZombieHandle_ThrowsException()
6568
{

MemoryManager.Types/ArenaList.cs

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
* PROGRAMMER: Peter Geinitz (Wayfarer)
88
*/
99

10+
// ReSharper disable UnusedMember.Global
11+
1012
using MemoryManager.Core;
1113
using System.Runtime.CompilerServices;
1214

@@ -57,16 +59,12 @@ public sealed class ArenaList<T> : IDisposable where T : unmanaged
5759
/// <summary>
5860
/// Initializes a new instance of the <see cref="ArenaList{T}" /> class.
5961
/// </summary>
60-
<<<<<<< HEAD
6162
/// <param name="arena">The arena.</param>
6263
/// <param name="initialCapacity">The initial capacity.</param>
6364
/// <param name="priority">The priority.</param>
6465
/// <param name="hints">The hints.</param>
65-
public ArenaList(IMemoryAllocator arena, int initialCapacity = 8, AllocationPriority priority = AllocationPriority.Normal, AllocationHints hints = AllocationHints.None)
66-
=======
6766
public ArenaList(MemoryArena arena, int initialCapacity = 8,
6867
AllocationPriority priority = AllocationPriority.Normal, AllocationHints hints = AllocationHints.None)
69-
>>>>>>> f41cf23e1c66b3d2e4e393356f32f92443e0ab03
7068
{
7169
if (initialCapacity <= 0) initialCapacity = 8;
7270

@@ -109,12 +107,9 @@ public void Add(T item)
109107
public ref T Get(int index)
110108
{
111109
if (index < 0 || index >= Count)
112-
<<<<<<< HEAD
113-
throw new IndexOutOfRangeException($"Index {index} is outside active boundaries.");
114-
=======
115110
throw new IndexOutOfRangeException(
116111
$"Index {index} is outside the active boundaries of the ArenaList (Count: {Count}).");
117-
>>>>>>> f41cf23e1c66b3d2e4e393356f32f92443e0ab03
112+
118113

119114
var span = _arena.GetSpan<T>(_handle, _capacity);
120115
return ref span[index];
@@ -126,14 +121,13 @@ public ref T Get(int index)
126121
public void Clear() => Count = 0;
127122

128123
/// <summary>
129-
/// Ases the span.
124+
/// Converts the active portion of the internal buffer to a <see cref="Span{T}"/> for zero-allocation access.
130125
/// </summary>
131126
/// <returns></returns>
132127
[MethodImpl(MethodImplOptions.AggressiveInlining)]
133128
public Span<T> AsSpan()
134129
{
135-
if (Count == 0) return Span<T>.Empty;
136-
return _arena.GetSpan<T>(_handle, _capacity).Slice(0, Count);
130+
return Count == 0 ? Span<T>.Empty : _arena.GetSpan<T>(_handle, _capacity).Slice(0, Count);
137131
}
138132

139133
/// <summary>
@@ -162,16 +156,16 @@ private void Grow()
162156
_capacity = newCapacity;
163157
}
164158

159+
/// <inheritdoc />
165160
/// <summary>
166161
/// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
167162
/// </summary>
168163
public void Dispose()
169164
{
170-
if (!_handle.IsInvalid)
171-
{
172-
_arena.Free(_handle);
173-
_handle = default;
174-
}
165+
if (_handle.IsInvalid) return;
166+
167+
_arena.Free(_handle);
168+
_handle = default;
175169
}
176170
}
177171
}

MemoryManager.Types/ArenaQueue.cs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@
77
* PROGRAMMER: Peter Geinitz (Wayfarer)
88
*/
99

10+
// ReSharper disable ConvertToAutoPropertyWithPrivateSetter
11+
// ReSharper disable UnusedType.Global
12+
1013
using MemoryManager.Core;
1114
using System.Runtime.CompilerServices;
1215

16+
1317
namespace MemoryManager.Types
1418
{
19+
/// <inheritdoc />
1520
/// <summary>
1621
/// A high-performance, zero-allocation circular queue (Ring Buffer) for unmanaged types,
1722
/// backed by an <see cref="IMemoryAllocator"/>.
@@ -76,7 +81,8 @@ public sealed class ArenaQueue<T> : IDisposable where T : unmanaged
7681
/// <param name="initialCapacity">The initial capacity.</param>
7782
/// <param name="priority">The priority.</param>
7883
/// <param name="hints">The hints.</param>
79-
public ArenaQueue(IMemoryAllocator arena, int initialCapacity = 8, AllocationPriority priority = AllocationPriority.Normal, AllocationHints hints = AllocationHints.None)
84+
public ArenaQueue(IMemoryAllocator arena, int initialCapacity = 8,
85+
AllocationPriority priority = AllocationPriority.Normal, AllocationHints hints = AllocationHints.None)
8086
{
8187
if (initialCapacity <= 0) initialCapacity = 8;
8288

@@ -191,16 +197,16 @@ private void Grow()
191197
_capacity = newCapacity;
192198
}
193199

200+
/// <inheritdoc />
194201
/// <summary>
195202
/// Cleans up unmanaged boundaries back to native runtime engines safely.
196203
/// </summary>
197204
public void Dispose()
198205
{
199-
if (!_handle.IsInvalid)
200-
{
201-
_arena.Free(_handle);
202-
_handle = default;
203-
}
206+
if (_handle.IsInvalid) return;
207+
208+
_arena.Free(_handle);
209+
_handle = default;
204210
}
205211
}
206212
}

MemoryManager/MemoryArenaExtensions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ public static void BulkSet<T>(this IMemoryAllocator arena, MemoryHandle handle,
141141
/// <param name="count">The number of elements of type T to include in the span view.</param>
142142
/// <returns>A span tracking the underlying raw native block coordinates.</returns>
143143
[MethodImpl(MethodImplOptions.AggressiveInlining)]
144-
public static unsafe Span<T> GetSpan<T>(this IMemoryAllocator allocator, MemoryHandle handle, int count) where T : unmanaged
144+
public static unsafe Span<T> GetSpan<T>(this IMemoryAllocator allocator, MemoryHandle handle, int count)
145+
where T : unmanaged
145146
{
146147
if (handle.IsInvalid || count <= 0) return Span<T>.Empty;
147148

0 commit comments

Comments
 (0)