From 759614de5475140b53936995c8844a8259d2022e Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Sun, 28 Dec 2025 00:14:23 +0100 Subject: [PATCH] Fixed invalid index return when EnvironmentConfig.RollingAccelerators is 1. --- PerfectNumbers.Core/Gpu/AcceleratorPool.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PerfectNumbers.Core/Gpu/AcceleratorPool.cs b/PerfectNumbers.Core/Gpu/AcceleratorPool.cs index a7649e8..574bb41 100644 --- a/PerfectNumbers.Core/Gpu/AcceleratorPool.cs +++ b/PerfectNumbers.Core/Gpu/AcceleratorPool.cs @@ -16,8 +16,8 @@ namespace PerfectNumbers.Core.Gpu public int Rent() { _ = Interlocked.CompareExchange(ref _index, Capacity, 0); - var index = Interlocked.Increment(ref _index); - if (index >= Capacity) + var index = Interlocked.Increment(ref _index) - 1; + if (index + 1 >= Capacity) { index -= Capacity; }