public bool TryEnterRead(out IDisposable engagement) { engagement = null; if (!CanRead()) { return(false); } engagement = DisposableAkin.Create(DoneRead); return(true); }
public IDisposable EnterWrite() { if (_currentReadingCount.Value > 0) { if (WaitUpgrade()) { return(DisposableAkin.Create(DoneUpgrade)); } throw new InvalidOperationException(); } WaitCanWrite(); return(DisposableAkin.Create(DoneWrite)); }
public bool TryEnterWrite(out IDisposable engagement) { engagement = null; if (_currentReadingCount.Value > 0) { if (CanUpgrade()) { engagement = DisposableAkin.Create(DoneUpgrade); return(true); } return(false); } if (!CanWrite()) { return(false); } engagement = DisposableAkin.Create(DoneWrite); return(true); }
public IDisposable EnterRead() { WaitCanRead(); return(DisposableAkin.Create(DoneRead)); }
public IDisposable EnterWrite() { WaitCanWrite(); return(DisposableAkin.Create(DoneWrite)); }
public IDisposable TryEnter(out bool didEnter) { didEnter = Enter(Id); return(didEnter ? DisposableAkin.Create(() => Leave(Id)) : NoOpDisposable.Instance); }