Remove IDisposable usage and using declarations

This commit is contained in:
Marek Lemańczyk committed 2025-10-13 21:55:16 +02:00
1 parent 305a489d6c
commit 0b43880959
26 files changed
+136 -113

No files matched your search

@@ -18,13 +18,14 @@ public class GpuPrimeLimiterTests
var startedSecond = new TaskCompletionSource<bool>();
var sw = new Stopwatch();
using var first = GpuPrimeWorkLimiter.Acquire();
var first = GpuPrimeWorkLimiter.Acquire();
sw.Start();
var secondTask = Task.Run(() =>
{
using var second = GpuPrimeWorkLimiter.Acquire();
var second = GpuPrimeWorkLimiter.Acquire();
startedSecond.TrySetResult(true);
second.Dispose();
});
// Give secondTask a moment to attempt acquire (it should block).
@@ -34,23 +34,19 @@ public class NttMontgomeryTests
// Device execution
GpuContextPool.GpuContextLease context = GpuContextPool.Rent();
try
{
var accelerator = context.Accelerator;
using var buffer = accelerator.Allocate1D<GpuUInt128>(gpu.Length);
buffer.View.CopyFromCPU(ref gpu[0], gpu.Length);
NttGpuMath.SquareDevice(accelerator, buffer.View, modulus, primitiveRoot);
buffer.View.CopyToCPU(ref gpu[0], gpu.Length);
var accelerator = context.Accelerator;
var buffer = accelerator.Allocate1D<GpuUInt128>(gpu.Length);
buffer.View.CopyFromCPU(ref gpu[0], gpu.Length);
NttGpuMath.SquareDevice(accelerator, buffer.View, modulus, primitiveRoot);
buffer.View.CopyToCPU(ref gpu[0], gpu.Length);
for (int i = 0; i < cpu.Length; i++)
{
gpu[i].Should().Be(cpu[i]);
}
}
finally
for (int i = 0; i < cpu.Length; i++)
{
context.Dispose();
gpu[i].Should().Be(cpu[i]);
}
buffer.Dispose();
context.Dispose();
}
[Fact]