internal static void Release(ref AsyncSemaphoreSlimWrapper asyncSemaphoreSlimWrapper) { asyncSemaphoreSlimWrapper.DecreaseRef(); if (asyncSemaphoreSlimWrapper.RefCount <= 0) { Lockers.TryRemove(asyncSemaphoreSlimWrapper.Key, out var removed); } }
internal static AsyncSemaphoreSlimWrapper GetOrCreate(string key) { AsyncSemaphoreSlimWrapper asyncSemaphoreSlimWrapper; if (Lockers.TryGetValue(key, out asyncSemaphoreSlimWrapper)) { asyncSemaphoreSlimWrapper.IncreaseRef(); } else { asyncSemaphoreSlimWrapper = new AsyncSemaphoreSlimWrapper(key, new SemaphoreSlim(1, 1)); Lockers.TryAdd(key, asyncSemaphoreSlimWrapper); } return(asyncSemaphoreSlimWrapper); }