118 references to LockStates
System.Threading (118)
System\Threading\ReaderWriterLock.cs (118)
85if (Interlocked.CompareExchange(ref _state, LockStates.Reader, 0) == 0) 92Debug.Assert((_state & LockStates.ReadersMask) != 0); 117if (knownState < LockStates.ReadersMask || 119(knownState & LockStates.ReaderSignaled) != 0 && 120(knownState & LockStates.Writer) == 0 && 125(knownState & LockStates.ReadersMask) + 126((knownState & LockStates.WaitingReadersMask) >> LockStates.WaitingReadersShift) 127) <= LockStates.ReadersMask - 2 132currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.Reader, knownState); 144if ((knownState & LockStates.ReadersMask) == LockStates.ReadersMask || 145(knownState & LockStates.WaitingReadersMask) == LockStates.WaitingReadersMask || 146(knownState & LockStates.CachingEvents) == LockStates.ReaderSignaled) 150if ((knownState & LockStates.ReadersMask) == LockStates.ReadersMask || 151(knownState & LockStates.WaitingReadersMask) == LockStates.WaitingReadersMask) 167if ((knownState & LockStates.CachingEvents) == LockStates.CachingEvents) 186currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.WaitingReader, knownState); 192int modifyState = -LockStates.WaitingReader; 207Debug.Assert((_state & LockStates.ReaderSignaled) != 0); 208Debug.Assert((_state & LockStates.ReadersMask) < LockStates.ReadersMask); 209modifyState += LockStates.Reader; 225if ((knownState & LockStates.ReaderSignaled) != 0 && 226(knownState & LockStates.WaitingReadersMask) == LockStates.WaitingReader) 237Debug.Assert((_state & LockStates.ReadersMask) < LockStates.ReadersMask); 241Interlocked.Add(ref _state, LockStates.Reader - LockStates.ReaderSignaled); 258Debug.Assert((knownState & LockStates.ReaderSignaled) != 0); 259Debug.Assert((knownState & LockStates.ReadersMask) < LockStates.ReadersMask); 260if ((knownState & LockStates.WaitingReadersMask) == LockStates.WaitingReader) 264Interlocked.Add(ref _state, -LockStates.ReaderSignaled); 272Debug.Assert((_state & LockStates.Writer) == 0); 273Debug.Assert((_state & LockStates.ReadersMask) != 0); 287if (Interlocked.CompareExchange(ref _state, LockStates.Writer, 0) == 0) 289Debug.Assert((_state & LockStates.ReadersMask) == 0); 310if (knownState == 0 || knownState == LockStates.CachingEvents) 313currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.Writer, knownState); 323if ((knownState & LockStates.WaitingWritersMask) == LockStates.WaitingWritersMask) 337if ((knownState & LockStates.CachingEvents) == LockStates.CachingEvents) 356currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.WaitingWriter, knownState); 362int modifyState = -LockStates.WaitingWriter; 373Debug.Assert((_state & LockStates.WriterSignaled) != 0); 374modifyState += LockStates.Writer - LockStates.WriterSignaled; 383(knownState & LockStates.WriterSignaled) != 0 && 384(knownState & LockStates.WaitingWritersMask) == LockStates.WaitingWriter) 395if ((knownState & LockStates.WriterSignaled) == 0 || 396(knownState & LockStates.WaitingWritersMask) != 0) 406modifyState = LockStates.Writer - LockStates.WriterSignaled; 408Debug.Assert((knownState & LockStates.WriterSignaled) != 0); 409Debug.Assert((knownState & LockStates.Writer) == 0); 430Debug.Assert((_state & LockStates.Writer) != 0); 431Debug.Assert((_state & LockStates.ReadersMask) == 0); 458Debug.Assert((_state & LockStates.Writer) == 0); 459Debug.Assert((_state & LockStates.ReadersMask) != 0); 480int modifyState = -LockStates.Reader; 482if ((knownState & (LockStates.ReadersMask | LockStates.ReaderSignaled)) == LockStates.Reader) 485if ((knownState & LockStates.WaitingWritersMask) != 0) 497modifyState += LockStates.WriterSignaled; 499else if ((knownState & LockStates.WaitingReadersMask) != 0) 522modifyState += LockStates.ReaderSignaled; 524else if (knownState == LockStates.Reader && (_readerEvent != null || _writerEvent != null)) 527modifyState += LockStates.CachingEvents; 531Debug.Assert((knownState & LockStates.Writer) == 0); 532Debug.Assert((knownState & LockStates.ReadersMask) != 0); 540if ((knownState & LockStates.WaitingWritersMask) != 0) 542Debug.Assert((_state & LockStates.WriterSignaled) != 0); 547else if ((knownState & LockStates.WaitingReadersMask) != 0) 549Debug.Assert((_state & LockStates.ReaderSignaled) != 0); 570Debug.Assert((_state & LockStates.ReadersMask) == 0); 571Debug.Assert((_state & LockStates.Writer) != 0); 592int modifyState = -LockStates.Writer; 594if ((knownState & LockStates.WaitingReadersMask) != 0) 617modifyState += LockStates.ReaderSignaled; 619else if ((knownState & LockStates.WaitingWritersMask) != 0) 631modifyState += LockStates.WriterSignaled; 633else if (knownState == LockStates.Writer && (_readerEvent != null || _writerEvent != null)) 636modifyState += LockStates.CachingEvents; 639Debug.Assert((knownState & LockStates.ReadersMask) == 0); 640Debug.Assert((knownState & LockStates.Writer) != 0); 645if ((knownState & LockStates.WaitingReadersMask) != 0) 647Debug.Assert((_state & LockStates.ReaderSignaled) != 0); 652else if ((knownState & LockStates.WaitingWritersMask) != 0) 654Debug.Assert((_state & LockStates.WriterSignaled) != 0); 694Debug.Assert((_state & LockStates.ReadersMask) != 0); 702int knownState = Interlocked.CompareExchange(ref _state, LockStates.Writer, LockStates.Reader); 703if (knownState == LockStates.Reader) 783int modifyState = LockStates.Reader - LockStates.Writer; 784if ((knownState & LockStates.WaitingReadersMask) != 0) 807modifyState += LockStates.ReaderSignaled; 810Debug.Assert((knownState & LockStates.ReadersMask) == 0); 815if ((knownState & LockStates.WaitingReadersMask) != 0) 817Debug.Assert((_state & LockStates.ReaderSignaled) != 0); 897Debug.Assert((_state & LockStates.ReadersMask) != 0); 941if (Interlocked.CompareExchange(ref _state, LockStates.Writer, 0) == 0) 957if (knownState < LockStates.ReadersMask && 958Interlocked.CompareExchange(ref _state, knownState + LockStates.Reader, knownState) == knownState) 1090Debug.Assert((_state & LockStates.CachingEvents) == LockStates.CachingEvents); 1099Interlocked.Add(ref _state, -LockStates.CachingEvents);