private static void WaitWhileOccupied(ReadIndicator readIndicator) { while (!readIndicator.IsEmpty) { RE.Yield(); } }
internal void EnterWriteLock() { RMonitor.Enter(_lockObj); RUnordered.Write(ref _writerActive, 1); RInterlocked.MemoryBarrierProcessWide(); while (ReadInProgress()) { RE.Yield(); } _snoop.BeginWrite(); return; }
private void EnterSlow() { RMonitor.Enter(_lockObj); RUnordered.Write(ref _holdingThreadId, Environment.CurrentManagedThreadId); RInterlocked.MemoryBarrierProcessWide(); while (RUnordered.Read(ref _isHeld) == 1) { RE.Yield(); } RUnordered.Write(ref _isHeld, 1); RMonitor.Exit(_lockObj); return; }
private LockCookie EnterSlow() { RMonitor.Enter(_lockObj); var oldEntry = RUnordered.Read(ref _current); RUnordered.Write(ref _current, new LockCookie(Environment.CurrentManagedThreadId)); RInterlocked.MemoryBarrierProcessWide(); while (oldEntry != null && RUnordered.Read(ref oldEntry.Taken) == 1) { RE.Yield(); } var current = RUnordered.Read(ref _current); RUnordered.Write(ref current.Taken, 1); RMonitor.Exit(_lockObj); return(current); }