release semaphore only if requied

This commit is contained in:
Pilzinsel64
2025-01-28 07:37:43 +01:00
parent 2414f2f7c5
commit c02763ae9a

View File

@@ -100,13 +100,14 @@ public class ApiServer(string apiUrl) : IApiServer
{
if (MaxConcurentConnections == int.MaxValue)
return; // Unlimited in this case
semaphore ??= new(MaxConcurentConnections);
semaphore ??= new(MaxConcurentConnections, MaxConcurentConnections);
semaphore.Wait();
}
protected virtual void FreeSlot()
{
semaphore?.Release();
if (semaphore != null && semaphore.CurrentCount < MaxConcurentConnections)
semaphore.Release();
}
public virtual void RegisterHandler<T>(T instance) where T : class