Skip to content

Commit ea6e9d5

Browse files
committed
Remove thread safety test from ConcurrentBumpAllocatorTests since Reset is not thread safe
The ThreadSafety_ConcurrentResetAndAlloc_NoCorruption test, which verified concurrent allocation and reset behavior, has been removed. The rest of the test suite remains unchanged.
1 parent 370337c commit ea6e9d5

1 file changed

Lines changed: 0 additions & 64 deletions

File tree

Hexa.NET.Utilities.Tests/ConcurrentBumpAllocatorTests.cs

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -358,70 +358,6 @@ public void ThreadSafety_ConcurrentAllocationsWithDifferentSizes_NoMemoryOverlap
358358
allocator.Dispose();
359359
}
360360

361-
[Test]
362-
public void ThreadSafety_ConcurrentResetAndAlloc_NoCorruption()
363-
{
364-
// Arrange
365-
var allocator = new ConcurrentBumpAllocator();
366-
const int duration = 1000; // milliseconds
367-
var cts = new CancellationTokenSource();
368-
var exceptions = new List<Exception>();
369-
370-
// Act - One thread continuously allocates, another resets periodically
371-
var allocTask = Task.Run(() =>
372-
{
373-
try
374-
{
375-
while (!cts.Token.IsCancellationRequested)
376-
{
377-
void* ptr = allocator.Alloc(64);
378-
if (ptr != null)
379-
{
380-
// Write some data
381-
*(int*)ptr = 0x12345678;
382-
}
383-
}
384-
}
385-
catch (Exception ex)
386-
{
387-
lock (exceptions)
388-
{
389-
exceptions.Add(ex);
390-
}
391-
}
392-
});
393-
394-
var resetTask = Task.Run(() =>
395-
{
396-
try
397-
{
398-
while (!cts.Token.IsCancellationRequested)
399-
{
400-
Thread.Sleep(10);
401-
allocator.Reset();
402-
}
403-
}
404-
catch (Exception ex)
405-
{
406-
lock (exceptions)
407-
{
408-
exceptions.Add(ex);
409-
}
410-
}
411-
});
412-
413-
Thread.Sleep(duration);
414-
cts.Cancel();
415-
Task.WaitAll(allocTask, resetTask);
416-
417-
// Assert - No exceptions should occur
418-
Assert.That(exceptions, Is.Empty,
419-
$"Exceptions occurred: {string.Join(", ", exceptions.Select(e => e.Message))}");
420-
421-
// Cleanup
422-
allocator.Dispose();
423-
}
424-
425361
[Test]
426362
public void Alloc_SmallAllocations_FitsInSinglePage()
427363
{

0 commit comments

Comments
 (0)