internal LockReleaser(AsyncLock target) { this.target = target; }
static async ValueTask <IDisposable> LockAsyncInternal(AsyncLock self, Task waitTask) { await waitTask.ConfigureAwait(false); return(new LockReleaser(self)); }
public void Dispose() { if (target == null) return; // first null it, next Release, so even if Release throws, we don't hold the reference any more. AsyncLock tmp = target; target = null; try { tmp.semaphore.Release(); } catch (Exception) { } // just ignore the Exception }