
While the previous fix was likely enough, there was still a razor-thin theoretical race condition remaining. This commit fixes said race condition, and simplifies some if statements across the file.
13 lines
No EOL
340 B
C#
13 lines
No EOL
340 B
C#
namespace Iceshrimp.Backend.Core.Helpers;
|
|
|
|
public class SemaphorePlus(int maxCount) : SemaphoreSlim(maxCount, maxCount)
|
|
{
|
|
private readonly int _maxCount = maxCount;
|
|
public int ActiveCount => _maxCount - CurrentCount;
|
|
|
|
public async Task WaitAndReleaseAsync(CancellationToken token)
|
|
{
|
|
await WaitAsync(token);
|
|
Release();
|
|
}
|
|
} |