コード例 #1
0
 public bool TryEnterRead(out IDisposable engagement)
 {
     engagement = null;
     if (!CanRead())
     {
         return(false);
     }
     engagement = DisposableAkin.Create(DoneRead);
     return(true);
 }
コード例 #2
0
 public IDisposable EnterWrite()
 {
     if (_currentReadingCount.Value > 0)
     {
         if (WaitUpgrade())
         {
             return(DisposableAkin.Create(DoneUpgrade));
         }
         throw new InvalidOperationException();
     }
     WaitCanWrite();
     return(DisposableAkin.Create(DoneWrite));
 }
コード例 #3
0
 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);
 }
コード例 #4
0
 public IDisposable EnterRead()
 {
     WaitCanRead();
     return(DisposableAkin.Create(DoneRead));
 }
コード例 #5
0
 public IDisposable EnterWrite()
 {
     WaitCanWrite();
     return(DisposableAkin.Create(DoneWrite));
 }
コード例 #6
0
 public IDisposable TryEnter(out bool didEnter)
 {
     didEnter = Enter(Id);
     return(didEnter ? DisposableAkin.Create(() => Leave(Id)) : NoOpDisposable.Instance);
 }