777 references to Volatile
dotnet (9)
Commands\Test\MTP\CtrlCCancellationManager.cs (1)
70if (Volatile.Read(ref _state) == StateForcing)
Commands\Test\MTP\TestApplication.cs (8)
85Volatile.Write(ref _standardOutputCollector, stdOutBuilder); 86Volatile.Write(ref _standardErrorCollector, stdErrBuilder); 145Volatile.Write(ref _standardOutputCollector, null); 146Volatile.Write(ref _standardErrorCollector, null); 423Volatile.Write(ref _protocolNegotiated, 1); 428Volatile.Read(ref _protocolNegotiated) == 0 ? null : IsProtocol_1_1_OrHigher; 433Volatile.Read(ref _standardOutputCollector)?.FlushBufferedOutputIfLiveStreamingEnabled(liveOutputStreamingState); 434Volatile.Read(ref _standardErrorCollector)?.FlushBufferedOutputIfLiveStreamingEnabled(liveOutputStreamingState);
GenerateDocumentationAndConfigFiles (14)
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
34=> Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory()); 49return Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory(arg)); 68var existingValue = Volatile.Read(ref target); 87var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory())); 105var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory(arg)));
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (2)
379Volatile.Write(ref arr[idx].Text, text); 455Volatile.Write(ref arr[idx].Text, text);
src\roslyn\src\Dependencies\Collections\RoslynImmutableInterlocked.cs (1)
622Volatile.ReadBarrier();
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
src\roslyn\src\Dependencies\Threading\CancellationSeries.cs (1)
80var priorSource = Volatile.Read(ref _cts);
ILCompiler.ReadyToRun (1)
Compiler\ReadyToRunCompilationModuleGroupBase.cs (1)
746Volatile.Write(ref _typeRefsInCompilationModuleSet, typeRefsInCompilationModuleSet);
ILCompiler.TypeSystem (10)
src\runtime\src\coreclr\tools\Common\TypeSystem\Common\Utilities\LockFreeReaderHashtable.cs (10)
194sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel); 224sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel); 243TValue sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel); 250TValue value = Volatile.Read(ref hashtable[tableIndex]); 291TValue sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel); 405TValue examineEntry = Volatile.Read(ref hashTable[tableIndex]); 534Volatile.Write(ref hashTableLocal[tableIndex], value); 546Volatile.Write(ref hashTableLocal[tableIndex], default(TValue)!); 616sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel); 640sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel);
Microsoft.AspNetCore.Cryptography.Internal (3)
UnsafeBufferUtil.cs (2)
154Volatile.Write(ref *buffer, 0); 175Volatile.Write(ref *buffer, 0);
WeakReferenceHelpers.cs (1)
16WeakReference<T>? existingWeakRef = Volatile.Read(ref weakReference);
Microsoft.AspNetCore.DataProtection (17)
KeyManagement\KeyRing.cs (3)
78IAuthenticatedEncryptor? encryptor = Volatile.Read(ref _encryptor); 83encryptor = Volatile.Read(ref _encryptor); 87Volatile.Write(ref _encryptor, encryptor);
KeyManagement\KeyRingBasedDataProtector.cs (2)
338var existingTemplate = Volatile.Read(ref _aadTemplate); 361Volatile.Write(ref _aadTemplate, newTemplate);
KeyManagement\KeyRingProvider.cs (12)
234existingCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 256existingCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 295Volatile.Write(ref _cacheableKeyRing, existingCacheableKeyRing.WithTemporaryExtendedLifetime(utcNow)); 304Volatile.Write(ref _cacheableKeyRing, newCacheableKeyRing); 337var cached = Volatile.Read(ref _cacheableKeyRing); 353existingCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 364existingCacheableKeyRing ??= Volatile.Read(ref _cacheableKeyRing); 395Volatile.Write(ref _cacheableKeyRing, newCacheableKeyRing); 458var newCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 496Volatile.Write(ref _cacheableKeyRing, newCacheableKeyRing); 501var existingCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 506Volatile.Write(ref _cacheableKeyRing, existingCacheableKeyRing.WithTemporaryExtendedLifetime(utcNow));
Microsoft.AspNetCore.DataProtection.Extensions (1)
TimeLimitedDataProtector.cs (1)
40var retVal = Volatile.Read(ref _innerProtectorWithTimeLimitedPurpose);
Microsoft.AspNetCore.Hosting (4)
Internal\HostingEventSource.cs (4)
94_requestsPerSecondCounter ??= new IncrementingPollingCounter("requests-per-second", this, () => Volatile.Read(ref _totalRequests)) 100_totalRequestsCounter ??= new PollingCounter("total-requests", this, () => Volatile.Read(ref _totalRequests)) 105_currentRequestsCounter ??= new PollingCounter("current-requests", this, () => Volatile.Read(ref _currentRequests)) 110_failedRequestsCounter ??= new PollingCounter("failed-requests", this, () => Volatile.Read(ref _failedRequests))
Microsoft.AspNetCore.Http.Connections (4)
Internal\HttpConnectionsEventSource.cs (4)
88_connectionsStartedCounter ??= new PollingCounter("connections-started", this, () => Volatile.Read(ref _connectionsStarted)) 92_connectionsStoppedCounter ??= new PollingCounter("connections-stopped", this, () => Volatile.Read(ref _connectionsStopped)) 96_connectionsTimedOutCounter ??= new PollingCounter("connections-timed-out", this, () => Volatile.Read(ref _connectionsTimedOut)) 100_currentConnectionsCounter ??= new PollingCounter("current-connections", this, () => Volatile.Read(ref _currentConnections))
Microsoft.AspNetCore.Mvc.Core (2)
Infrastructure\ActionSelector.cs (2)
50var cache = Volatile.Read(ref _cache); 58Volatile.Write(ref _cache, cache);
Microsoft.AspNetCore.OutputCaching.StackExchangeRedis (3)
RedisOutputCacheStore.cs (3)
95while (!Volatile.Read(ref _disposed)) 471Volatile.Write(ref field, ticks); // avoid torn values 481var ticks = Volatile.Read(ref field); // avoid torn values
Microsoft.AspNetCore.Razor.Utilities.Shared (8)
src\roslyn\src\Razor\src\Shared\Microsoft.AspNetCore.Razor.SharedUtilities\InterlockedOperations.cs (8)
111if (Volatile.Read(ref state) == Initialized) 127Volatile.Write(ref state, Initialized); 134Volatile.Write(ref state, NotInitialized); 142while (Volatile.Read(ref state) != Initialized) 194if (Volatile.Read(ref state) == Initialized) 210Volatile.Write(ref state, Initialized); 217Volatile.Write(ref state, NotInitialized); 225while (Volatile.Read(ref state) != Initialized)
Microsoft.AspNetCore.Server.HttpSys (1)
src\aspnetcore\src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
76if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.Server.IIS (5)
Core\IO\AsyncIOEngine.cs (3)
235Volatile.Write(ref _cachedAsyncReadOperation, operation); 240Volatile.Write(ref _cachedAsyncWriteOperation, operation); 245Volatile.Write(ref _cachedAsyncFlushOperation, operation);
Core\IO\AsyncIOOperation.cs (1)
23if (ReferenceEquals(Volatile.Read(ref _continuation), null))
src\aspnetcore\src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
76if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.Server.Kestrel.Core (12)
Internal\Http\DateHeaderValueManager.cs (1)
52Volatile.Write(ref _dateValues, dateValues);
Internal\Infrastructure\KestrelEventSource.cs (10)
308_connectionsPerSecondCounter ??= new IncrementingPollingCounter("connections-per-second", this, () => Volatile.Read(ref _totalConnections)) 314_totalConnectionsCounter ??= new PollingCounter("total-connections", this, () => Volatile.Read(ref _totalConnections)) 319_tlsHandshakesPerSecondCounter ??= new IncrementingPollingCounter("tls-handshakes-per-second", this, () => Volatile.Read(ref _totalTlsHandshakes)) 325_totalTlsHandshakesCounter ??= new PollingCounter("total-tls-handshakes", this, () => Volatile.Read(ref _totalTlsHandshakes)) 330_currentTlsHandshakesCounter ??= new PollingCounter("current-tls-handshakes", this, () => Volatile.Read(ref _currentTlsHandshakes)) 335_failedTlsHandshakesCounter ??= new PollingCounter("failed-tls-handshakes", this, () => Volatile.Read(ref _failedTlsHandshakes)) 340_currentConnectionsCounter ??= new PollingCounter("current-connections", this, () => Volatile.Read(ref _currentConnections)) 345_connectionQueueLengthCounter ??= new PollingCounter("connection-queue-length", this, () => Volatile.Read(ref _connectionQueueLength)) 350_httpRequestQueueLengthCounter ??= new PollingCounter("request-queue-length", this, () => Volatile.Read(ref _httpRequestQueueLength)) 355_currrentUpgradedHttpRequestsCounter ??= new PollingCounter("current-upgraded-requests", this, () => Volatile.Read(ref _currentUpgradedHttpRequests))
src\aspnetcore\src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
76if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes (1)
src\aspnetcore\src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
76if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (4)
Internal\QuicConnectionContext.cs (3)
265Volatile.Write(ref _heartbeatTimestamp, now); 272stream.PoolExpirationTimestamp = Volatile.Read(ref _heartbeatTimestamp) + StreamPoolExpirySeconds * timeProvider.TimestampFrequency; 294Volatile.Write(ref _heartbeatTimestamp, now);
src\aspnetcore\src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
76if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.SignalR.Client.Core (4)
HubConnection.cs (4)
2523Volatile.Write(ref _nextActivationSendPing, (DateTime.UtcNow + _hubConnection.KeepAliveInterval).Ticks); 2528Volatile.Write(ref _nextActivationServerTimeout, (DateTime.UtcNow + _hubConnection.ServerTimeout).Ticks); 2539if (DateTime.UtcNow.Ticks > Volatile.Read(ref _nextActivationServerTimeout)) 2544if (DateTime.UtcNow.Ticks > Volatile.Read(ref _nextActivationSendPing) && !Stopping)
Microsoft.AspNetCore.SignalR.Core (6)
HubConnectionContext.cs (6)
121var hubCallerContext = Volatile.Read(ref _hubCallerContext); 180get => Volatile.Read(ref _userIdentifier); 183Volatile.Write(ref _userIdentifier, value); 222Volatile.Write(ref _userIdentifier, userIdentifier); 783var elapsed = _timeProvider.GetElapsedTime(Volatile.Read(ref _lastSendTick), currentTime); 801Volatile.Write(ref _lastSendTick, currentTime);
Microsoft.Build (8)
BackEnd\Components\RequestBuilder\RequestBuilder.cs (1)
1578var count = Volatile.Read(ref _availableThreads);
Evaluation\LazyItemEvaluator.cs (2)
154var normalizedItemValue = Volatile.Read(ref _normalizedItemValue); 158Volatile.Write(ref _normalizedItemValue, normalizedItemValue);
Graph\ParallelWorkSet.cs (2)
75get => Volatile.Read(ref _isSchedulingCompleted); 76private set => Volatile.Write(ref _isSchedulingCompleted, value);
src\5057ed6cf5d6323b\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\5057ed6cf5d6323b\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\5057ed6cf5d6323b\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
Microsoft.Build.Framework (1)
Utilities\TypeInfo.cs (1)
27int value = Volatile.Read(ref s_hasReferences);
Microsoft.CodeAnalysis (20)
CodeGen\TokenMap.cs (4)
80Volatile.Write(ref _items, items); 83Volatile.Write(ref _count, count); 111int count = Volatile.Read(ref _count); 113object[] items = Volatile.Read(ref _items);
Compilation\Compilation.cs (2)
1862if (Volatile.Read(ref _eventQueueEnqueuePendingCount) != 0) 1864SpinWait.SpinUntil(() => Volatile.Read(ref _eventQueueEnqueuePendingCount) == 0);
InternalUtilities\InterlockedOperations.cs (5)
34=> Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory()); 49return Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory(arg)); 68var existingValue = Volatile.Read(ref target); 87var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory())); 105var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory(arg)));
InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
InternalUtilities\StringTable.cs (2)
379Volatile.Write(ref arr[idx].Text, text); 455Volatile.Write(ref arr[idx].Text, text);
InternalUtilities\TextKeyedCache.cs (1)
228Volatile.Write(ref arr[idx].Entry, e);
src\roslyn\src\Dependencies\Collections\RoslynImmutableInterlocked.cs (1)
622Volatile.ReadBarrier();
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
Microsoft.CodeAnalysis.Analyzers (13)
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
34=> Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory()); 49return Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory(arg)); 68var existingValue = Volatile.Read(ref target); 87var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory())); 105var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory(arg)));
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (2)
379Volatile.Write(ref arr[idx].Text, text); 455Volatile.Write(ref arr[idx].Text, text);
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
src\roslyn\src\Dependencies\Threading\CancellationSeries.cs (1)
80var priorSource = Volatile.Read(ref _cts);
Microsoft.CodeAnalysis.AnalyzerUtilities (13)
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
34=> Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory()); 49return Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory(arg)); 68var existingValue = Volatile.Read(ref target); 87var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory())); 105var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory(arg)));
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (2)
379Volatile.Write(ref arr[idx].Text, text); 455Volatile.Write(ref arr[idx].Text, text);
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
src\roslyn\src\Dependencies\Threading\CancellationSeries.cs (1)
80var priorSource = Volatile.Read(ref _cts);
Microsoft.CodeAnalysis.CodeStyle (15)
src\roslyn\src\Analyzers\Core\Analyzers\OrderModifiers\OrderModifiersHelpers.cs (2)
51var lastParsed = Volatile.Read(ref _lastParsed); 61Volatile.Write(ref _lastParsed, lastParsed);
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
34=> Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory()); 49return Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory(arg)); 68var existingValue = Volatile.Read(ref target); 87var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory())); 105var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory(arg)));
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (2)
379Volatile.Write(ref arr[idx].Text, text); 455Volatile.Write(ref arr[idx].Text, text);
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
src\roslyn\src\Dependencies\Threading\CancellationSeries.cs (1)
80var priorSource = Volatile.Read(ref _cts);
Microsoft.CodeAnalysis.CSharp (45)
Compilation\CSharpCompilation.cs (1)
146internal ImmutableHashSet<SyntaxTree>? UsageOfUsingsRecordedInTrees => Volatile.Read(ref _usageOfUsingsRecordedInTrees);
Symbols\Compilation_UsedAssemblies.cs (4)
65if (!_usedAssemblyReferencesFrozen && !Volatile.Read(ref _usedAssemblyReferencesFrozen)) 113if (_usedAssemblyReferencesFrozen || Volatile.Read(ref _usedAssemblyReferencesFrozen)) 137if (_usedAssemblyReferencesFrozen || Volatile.Read(ref _usedAssemblyReferencesFrozen)) 148if (_usedAssemblyReferencesFrozen || Volatile.Read(ref _usedAssemblyReferencesFrozen))
Symbols\LexicalSortKey.cs (2)
131return Volatile.Read(ref _position) >= 0; 139Volatile.Write(ref _position, other._position);
Symbols\Metadata\PE\PEEventSymbol.cs (2)
369var requiresUnsafeState = (ThreeState)Volatile.Read(ref _lazyRequiresUnsafe); 552var requiresUnsafeState = (ThreeState)Volatile.Read(ref _lazyRequiresUnsafe);
Symbols\Metadata\PE\PEGlobalNamespaceSymbol.cs (2)
86if (Volatile.Read(ref lazyTypes) == null || Volatile.Read(ref lazyNamespaces) == null)
Symbols\Metadata\PE\PEMethodSymbol.cs (10)
140public bool IsObsoleteAttributePopulated => (Volatile.Read(ref _bits) & IsObsoleteAttributePopulatedBit) != 0; 141public bool IsCustomAttributesPopulated => (Volatile.Read(ref _bits) & IsCustomAttributesPopulatedBit) != 0; 142public bool IsUseSiteDiagnosticPopulated => (Volatile.Read(ref _bits) & IsUseSiteDiagnosticPopulatedBit) != 0; 143public bool IsConditionalPopulated => (Volatile.Read(ref _bits) & IsConditionalPopulatedBit) != 0; 144public bool IsOverriddenOrHiddenMembersPopulated => (Volatile.Read(ref _bits) & IsOverriddenOrHiddenMembersPopulatedBit) != 0; 149public bool IsMemberNotNullPopulated => (Volatile.Read(ref _bits) & IsMemberNotNullPopulatedBit) != 0; 152public bool IsUnmanagedCallersOnlyAttributePopulated => (Volatile.Read(ref _bits) & IsUnmanagedCallersOnlyAttributePopulatedBit) != 0; 157public bool IsOverloadResolutionPriorityPopulated => (Volatile.Read(ref _bits) & OverloadResolutionPriorityPopulatedBit) != 0; 158public bool RequiresUnsafe => (Volatile.Read(ref _bits) & RequiresUnsafeBit) != 0; 159public bool RequiresUnsafePopulated => (Volatile.Read(ref _bits) & RequiresUnsafePopulatedBit) != 0;
Symbols\Metadata\PE\PENamedTypeSymbol.cs (3)
1713if (Volatile.Read(ref _lazyMembersByName) == null) 1893if (Volatile.Read(ref _lazyMembersByName) == null) 2236var result = (TypeKind)Volatile.Read(ref Unsafe.As<TypeKind, byte>(ref _lazyKind));
Symbols\Metadata\PE\PENestedNamespaceSymbol.cs (1)
128var typesByNS = Volatile.Read(ref _typesByNS);
Symbols\Metadata\PE\PEPropertySymbol.cs (4)
154public bool IsUseSiteDiagnosticPopulated => (Volatile.Read(ref _bits) & IsUseSiteDiagnosticPopulatedBit) != 0; 161public bool IsObsoleteAttributePopulated => (Volatile.Read(ref _bits) & IsObsoleteAttributePopulatedBit) != 0; 168public bool IsCustomAttributesPopulated => (Volatile.Read(ref _bits) & IsCustomAttributesPopulatedBit) != 0; 175public bool IsOverloadResolutionPriorityPopulated => (Volatile.Read(ref _bits) & IsOverloadResolutionPriorityPopulatedBit) != 0;
Symbols\Source\SourceMemberContainerSymbol.cs (12)
1716if (Volatile.Read(ref _lazyMembersDictionary) is Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> result) 1829RoslynDebug.AssertOrFailFast(Volatile.Read(ref _lazyTypeMembers)?.Values.Any(types => types.Contains(t => t == (object)type)) == true); 1853var membersAndInitializers = Volatile.Read(ref _lazyMembersAndInitializers); 1868var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 1881membersAndInitializers = Volatile.Read(ref _lazyMembersAndInitializers); 3676if (Volatile.Read(ref _lazyMembersAndInitializers) != null) 3693if (Volatile.Read(ref _lazyMembersAndInitializers) is not null) 3746if (Volatile.Read(ref _lazyDeclaredMembersAndInitializers) != DeclaredMembersAndInitializers.UninitializedSentinel) 3867var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 3888var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 3935var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 3962var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers);
Symbols\Source\SourceMemberFieldSymbol.cs (1)
661return _lazyFieldTypeInferred != 0 || Volatile.Read(ref _lazyFieldTypeInferred) != 0;
Symbols\Source\SourceModuleSymbol.cs (3)
288Volatile.Write(ref DeclaringCompilation.InterceptorsDiscoveryComplete, true); 358if (!Volatile.Read(ref DeclaringCompilation.InterceptorsDiscoveryComplete)) 361Volatile.Write(ref DeclaringCompilation.InterceptorsDiscoveryComplete, true);
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
src\roslyn\src\Analyzers\CSharp\Analyzers\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (1)
104Volatile.Write(ref _hasTypeInstanceAssignment, true);
Microsoft.CodeAnalysis.CSharp.Features (1)
src\roslyn\src\Analyzers\CSharp\Analyzers\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (1)
104Volatile.Write(ref _hasTypeInstanceAssignment, true);
Microsoft.CodeAnalysis.Extensions.Package (3)
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
Microsoft.CodeAnalysis.Features (8)
NavigateTo\AbstractNavigateToSearchService.CachedDocumentSearch.cs (6)
52Volatile.Write(ref s_cachedIndexMap, null); 53Volatile.Write(ref s_cachedFilterIndexMap, null); 54Volatile.Write(ref s_stringTable, null); 62cachedIndexMap = Volatile.Read(ref s_cachedIndexMap); 63cachedFilterIndexMap = Volatile.Read(ref s_cachedFilterIndexMap); 64stringTable = Volatile.Read(ref s_stringTable);
src\roslyn\src\Analyzers\Core\Analyzers\OrderModifiers\OrderModifiersHelpers.cs (2)
51var lastParsed = Volatile.Read(ref _lastParsed); 61Volatile.Write(ref _lastParsed, lastParsed);
Microsoft.CodeAnalysis.NetAnalyzers (2)
Microsoft.NetCore.Analyzers\Usage\UseVolatileReadWrite.Fixer.cs (2)
23private const string VolatileReadMethodName = nameof(Volatile.Read); 24private const string VolatileWriteMethodName = nameof(Volatile.Write);
Microsoft.CodeAnalysis.Razor.Compiler (2)
Language\Intermediate\LazyContent.cs (2)
42return Volatile.Read(ref _state) == Initialized 65Volatile.Write(ref _state, Initialized);
Microsoft.CodeAnalysis.ResxSourceGenerator (13)
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
34=> Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory()); 49return Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory(arg)); 68var existingValue = Volatile.Read(ref target); 87var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory())); 105var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory(arg)));
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (2)
379Volatile.Write(ref arr[idx].Text, text); 455Volatile.Write(ref arr[idx].Text, text);
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
src\roslyn\src\Dependencies\Threading\CancellationSeries.cs (1)
80var priorSource = Volatile.Read(ref _cts);
Microsoft.CodeAnalysis.VisualBasic (20)
BoundTree\BoundMethodGroup.vb (2)
86useSiteInfo.AddDiagnostics(System.Threading.Volatile.Read(_lazyUseSiteDiagnostics)) 87useSiteInfo.AddDependencies(System.Threading.Volatile.Read(_lazyUseSiteDependencies))
Symbols\Attributes\PEAttributeData.vb (1)
123If Volatile.Read(_lazyConstructorArguments) Is Nothing Then
Symbols\LexicalSortKey.vb (2)
229Return Volatile.Read(Me._position) >= 0 237Volatile.Write(Me._position, other._position)
Symbols\Metadata\PE\PEGlobalNamespaceSymbol.vb (2)
66If Volatile.Read(m_lazyTypes) Is Nothing OrElse Volatile.Read(m_lazyMembers) Is Nothing Then
Symbols\Metadata\PE\PEMethodSymbol.vb (5)
118Return (Volatile.Read(_bits) And s_isObsoleteAttributePopulatedBit) <> 0 124Return (Volatile.Read(_bits) And s_isCustomAttributesPopulatedBit) <> 0 130Return (Volatile.Read(_bits) And s_isUseSiteDiagnosticPopulatedBit) <> 0 136Return (Volatile.Read(_bits) And s_isConditionalAttributePopulatedBit) <> 0 205Return (Volatile.Read(_bits) And s_OverloadResolutionPriorityIsPopulatedBit) <> 0
Symbols\Metadata\PE\PENamedTypeSymbol.vb (1)
655If Volatile.Read(_lazyMembers) Is Nothing Then
Symbols\Metadata\PE\PENestedNamespaceSymbol.vb (1)
121Dim typesByNS = Volatile.Read(_typesByNS)
Symbols\Metadata\PE\PETypeParameterSymbol.vb (1)
162Return CType(Volatile.Read(_lazyHasIsUnmanagedConstraint), ThreeState).Value()
Symbols\UsedAssemblies.vb (4)
43If Not _usedAssemblyReferencesFrozen AndAlso Not Volatile.Read(_usedAssemblyReferencesFrozen) Then 86If _usedAssemblyReferencesFrozen OrElse Volatile.Read(_usedAssemblyReferencesFrozen) Then 103If _usedAssemblyReferencesFrozen OrElse Volatile.Read(_usedAssemblyReferencesFrozen) Then 111If _usedAssemblyReferencesFrozen OrElse Volatile.Read(_usedAssemblyReferencesFrozen) Then
Symbols\WellKnownMembers.vb (1)
126ctorError = DirectCast(Volatile.Read(_lazyExtensionAttributeConstructorErrorInfo), DiagnosticInfo)
Microsoft.CodeAnalysis.Workspaces (22)
Shared\Utilities\StreamingProgressTracker.cs (2)
32=> updateAction?.Invoke(Volatile.Read(ref _completedItems), Volatile.Read(ref _totalItems), cancellationToken) ?? default;
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
34=> Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory()); 49return Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory(arg)); 68var existingValue = Volatile.Read(ref target); 87var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory())); 105var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory(arg)));
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (2)
379Volatile.Write(ref arr[idx].Text, text); 455Volatile.Write(ref arr[idx].Text, text);
src\roslyn\src\Dependencies\Collections\RoslynImmutableInterlocked.cs (1)
622Volatile.ReadBarrier();
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
src\roslyn\src\Dependencies\Threading\CancellationSeries.cs (1)
80var priorSource = Volatile.Read(ref _cts);
Workspace\Host\PersistentStorage\AbstractPersistentStorage.cs (2)
41=> Volatile.Read(ref _isDisabled); 44=> Volatile.Write(ref _isDisabled, true);
Workspace\Solution\SolutionCompilationState.RegularCompilationTracker.cs (2)
86=> Volatile.Read(ref _stateDoNotAccessDirectly); 90Volatile.Write(ref _stateDoNotAccessDirectly, state);
Workspace\Workspace.cs (2)
158return Volatile.Read(ref _latestSolution); 479var oldSolution = Volatile.Read(ref _latestSolution);
Microsoft.DotNet.Cli.Utils (1)
TypeInfo.cs (1)
30int value = Volatile.Read(ref s_hasReferences);
Microsoft.Extensions.AsyncState (1)
AsyncState.cs (1)
104internal int ContextCount => Volatile.Read(ref _contextCount);
Microsoft.Extensions.Caching.Hybrid (27)
Internal\DefaultHybridCache.CacheItem.cs (2)
41internal int RefCount => Volatile.Read(ref _refCount); 81int oldValue = Volatile.Read(ref _refCount);
Internal\DefaultHybridCache.Debug.cs (1)
35=> flush ? Interlocked.Exchange(ref _outstandingBufferCount, 0) : Volatile.Read(ref _outstandingBufferCount);
Internal\DefaultHybridCache.ImmutableCacheItem.cs (2)
30ImmutableCacheItem<T>? obj = Volatile.Read(ref _sharedDefault); 35Volatile.Write(ref _sharedDefault, obj);
Internal\HybridCacheEventSource.cs (22)
55Volatile.Write(ref _totalLocalCacheHit, 0); 56Volatile.Write(ref _totalLocalCacheMiss, 0); 57Volatile.Write(ref _totalDistributedCacheHit, 0); 58Volatile.Write(ref _totalDistributedCacheMiss, 0); 59Volatile.Write(ref _totalUnderlyingDataQuery, 0); 60Volatile.Write(ref _currentUnderlyingDataQuery, 0); 61Volatile.Write(ref _currentDistributedFetch, 0); 62Volatile.Write(ref _totalLocalCacheWrite, 0); 63Volatile.Write(ref _totalDistributedCacheWrite, 0); 64Volatile.Write(ref _totalStampedeJoin, 0); 65Volatile.Write(ref _totalTagInvalidations, 0); 208new PollingCounter("total-local-cache-hits", this, () => Volatile.Read(ref _totalLocalCacheHit)) { DisplayName = "Total Local Cache Hits" }, 209new PollingCounter("total-local-cache-misses", this, () => Volatile.Read(ref _totalLocalCacheMiss)) { DisplayName = "Total Local Cache Misses" }, 210new PollingCounter("total-distributed-cache-hits", this, () => Volatile.Read(ref _totalDistributedCacheHit)) { DisplayName = "Total Distributed Cache Hits" }, 211new PollingCounter("total-distributed-cache-misses", this, () => Volatile.Read(ref _totalDistributedCacheMiss)) { DisplayName = "Total Distributed Cache Misses" }, 212new PollingCounter("total-data-query", this, () => Volatile.Read(ref _totalUnderlyingDataQuery)) { DisplayName = "Total Data Queries" }, 213new PollingCounter("current-data-query", this, () => Volatile.Read(ref _currentUnderlyingDataQuery)) { DisplayName = "Current Data Queries" }, 214new PollingCounter("current-distributed-cache-fetches", this, () => Volatile.Read(ref _currentDistributedFetch)) { DisplayName = "Current Distributed Cache Fetches" }, 215new PollingCounter("total-local-cache-writes", this, () => Volatile.Read(ref _totalLocalCacheWrite)) { DisplayName = "Total Local Cache Writes" }, 216new PollingCounter("total-distributed-cache-writes", this, () => Volatile.Read(ref _totalDistributedCacheWrite)) { DisplayName = "Total Distributed Cache Writes" }, 217new PollingCounter("total-stampede-joins", this, () => Volatile.Read(ref _totalStampedeJoin)) { DisplayName = "Total Stampede Joins" }, 218new PollingCounter("total-tag-invalidations", this, () => Volatile.Read(ref _totalTagInvalidations)) { DisplayName = "Total Tag Invalidations" },
Microsoft.Extensions.Caching.Hybrid.Tests (26)
L2Tests.cs (1)
215public int OpCount => Volatile.Read(ref ProtectedOpCount);
SizeTests.cs (6)
195Assert.Equal(runCount, Volatile.Read(ref actualRunCount)); 261Assert.Equal(runCount, Volatile.Read(ref actualRunCount)); 285public int ReadCount => Volatile.Read(ref _readCount); 286public int WriteCount => Volatile.Read(ref _writeCount); 328public int ReadCount => Volatile.Read(ref _readCount); 329public int WriteCount => Volatile.Read(ref _writeCount);
StampedeTests.cs (19)
117Assert.Equal(0, Volatile.Read(ref executeCount)); 118Assert.Equal(0, Volatile.Read(ref cancelCount)); 121Assert.Equal(1, Volatile.Read(ref executeCount)); 122Assert.Equal(0, Volatile.Read(ref cancelCount)); 128Assert.Equal(1, Volatile.Read(ref executeCount)); 129Assert.Equal(0, Volatile.Read(ref cancelCount)); 132Volatile.Write(ref executeCount, 0); 153Assert.Equal(0, Volatile.Read(ref executeCount)); 154Assert.Equal(0, Volatile.Read(ref cancelCount)); 158Assert.Equal(1, Volatile.Read(ref executeCount)); 159Assert.Equal(0, Volatile.Read(ref cancelCount)); 165Assert.Equal(1, Volatile.Read(ref executeCount)); 166Assert.Equal(0, Volatile.Read(ref cancelCount)); 229Assert.Equal(0, Volatile.Read(ref executeCount)); 238Assert.Equal(1, Volatile.Read(ref executeCount)); 239Assert.Equal(1, Volatile.Read(ref cancelCount)); 313Assert.Equal(0, Volatile.Read(ref executeCount)); 322Assert.Equal(1, Volatile.Read(ref executeCount)); 323Assert.Equal(0, Volatile.Read(ref cancelCount)); // ran to completion
Microsoft.Extensions.Caching.Memory (5)
MemoryCache.cs (5)
449hits += Volatile.Read(ref stats.Hits); 450misses += Volatile.Read(ref stats.Misses); 492_accumulatedHits += Volatile.Read(ref current.Hits); 493_accumulatedMisses += Volatile.Read(ref current.Misses); 851internal long Size => Volatile.Read(ref _cacheSize);
Microsoft.Extensions.Caching.StackExchangeRedis (2)
RedisCache.cs (2)
70var ticks = Volatile.Read(ref field); // avoid torn values 77Volatile.Write(ref field, ticks); // avoid torn values
Microsoft.Extensions.Diagnostics (9)
Tracing\DefaultActivitySourceFactory.cs (9)
129if (Volatile.Read(ref _disposed)) 155Volatile.Write(ref _disposed, true); 250Volatile.Write(ref _state, newState); 272ListenerState state = Volatile.Read(ref _state); 284ListenerState state = Volatile.Read(ref _state); 296ListenerState state = Volatile.Read(ref _state); 306ListenerState state = Volatile.Read(ref _state); 316ListenerState state = Volatile.Read(ref _state); 389ListenerState state = Volatile.Read(ref _state);
Microsoft.Extensions.Diagnostics.ResourceMonitoring (2)
Linux\LinuxUtilizationProvider.cs (1)
319if (Volatile.Read(ref _measurementsUnavailable) == 1 &&
Linux\Network\LinuxNetworkMetrics.cs (1)
93if (Volatile.Read(ref unavailableFlag) == 0 || _timeProvider.GetUtcNow() - lastFailureTime > _retryInterval)
Microsoft.Extensions.Diagnostics.Testing (2)
Logging\FakeLogCollector.LogEnumeration.cs (2)
173Volatile.Write(ref _moveNextActive, 0); 205if (Volatile.Read(ref _disposed) == 1)
Microsoft.Extensions.FileProviders.Physical (2)
PhysicalFilesWatcher.cs (2)
538Volatile.Read(ref _subdirectoryRequiringTokenCount) == 0) 585Volatile.Read(ref _subdirectoryRequiringTokenCount) > 0;
Microsoft.Extensions.Hosting (1)
Internal\Host.cs (1)
337List<Exception>? backgroundServiceExceptions = Volatile.Read(ref _backgroundServiceExceptions);
Microsoft.Extensions.Http (2)
ActiveHandlerTrackingEntry.cs (2)
51if (Volatile.Read(ref _timerInitialized)) 65if (Volatile.Read(ref _timerInitialized))
Microsoft.Extensions.ML (7)
PoolLoader.cs (5)
54public ObjectPool<PredictionEngine<TData, TPrediction>> PredictionEnginePool { get { return Volatile.Read(ref _pool); } } 62var pool = Volatile.Read(ref _pool); 63if (Volatile.Read(ref _disposed) != 0 || pool == null) 99if (Volatile.Read(ref _disposed) != 0) 113if (Volatile.Read(ref _disposed) != 0 && Interlocked.CompareExchange(ref _pool, null, newPool) == newPool)
PredictionEnginePool.cs (2)
90if (Volatile.Read(ref _disposed) != 0) 151if (Volatile.Read(ref _disposed) != 0)
Microsoft.Extensions.Primitives (2)
ChangeToken.cs (2)
113if (Volatile.Read(ref _disposable) == _disposedSentinel) 132IDisposable? current = Volatile.Read(ref _disposable);
Microsoft.Interop.JavaScript.JSImportGenerator (1)
Analyzers\JSImportExportDiagnosticsAnalyzer.cs (1)
103if (Volatile.Read(ref foundMethod) != 0)
Microsoft.Interop.LibraryImportGenerator (1)
Analyzers\LibraryImportDiagnosticsAnalyzer.cs (1)
81if (Volatile.Read(ref foundLibraryImportMethod) != 0 && !unsafeEnabled)
Microsoft.Interop.LibraryImportGenerator.Downlevel (1)
DownlevelLibraryImportDiagnosticsAnalyzer.cs (1)
75if (Volatile.Read(ref foundLibraryImportMethod) != 0)
Microsoft.ML.Tokenizers (3)
Model\CodeGenTokenizer.cs (1)
266IReadOnlyDictionary<string, int>? publicVocab = Volatile.Read(ref _vocabOriginal);
Model\EnglishRobertaTokenizer.cs (1)
236Dictionary<string, int>? publicVocab = Volatile.Read(ref _vocabOriginal);
Model\SentencePieceBpeModel.cs (1)
48IReadOnlyDictionary<string, int>? publicVocab = Volatile.Read(ref _publicVocab);
MSBuild.Coordinator (1)
CoordinatorServer.cs (1)
36private bool HasActiveConnections => Volatile.Read(ref _activeConnections) > 0;
mscorlib (1)
src\runtime\src\libraries\shims\mscorlib\ref\mscorlib.cs (1)
1186[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.Volatile))]
netstandard (1)
netstandard.cs (1)
2149[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.Volatile))]
Roslyn.Diagnostics.Analyzers (13)
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (5)
34=> Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory()); 49return Volatile.Read(ref target!) ?? GetOrStore(ref target, valueFactory(arg)); 68var existingValue = Volatile.Read(ref target); 87var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory())); 105var box = Volatile.Read(ref target!) ?? GetOrStore(ref target, new StrongBox<T?>(valueFactory(arg)));
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
src\roslyn\src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (2)
379Volatile.Write(ref arr[idx].Text, text); 455Volatile.Write(ref arr[idx].Text, text);
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
22var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
22var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\roslyn\src\Dependencies\Collections\Segmented\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
22var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
src\roslyn\src\Dependencies\Threading\CancellationSeries.cs (1)
80var priorSource = Volatile.Read(ref _cts);
System.Collections.Concurrent (2)
System\Collections\Concurrent\PartitionerStatic.cs (2)
1090long oldSharedIndex = Volatile.Read(ref _sharedIndex.Value); 1132return Volatile.Read(ref _sharedIndex.Value) >= SourceCount - 1;
System.Collections.Immutable (16)
System\Collections\Immutable\ImmutableInterlocked.cs (16)
39T oldValue = Volatile.Read(ref location); 86T oldValue = Volatile.Read(ref location); 128T[]? oldArray = Volatile.Read(ref Unsafe.AsRef(in location.array)); 175T[]? oldArray = Volatile.Read(ref Unsafe.AsRef(in location.array)); 258ImmutableDictionary<TKey, TValue> map = Volatile.Read(ref location); 287ImmutableDictionary<TKey, TValue> map = Volatile.Read(ref location); 311ImmutableDictionary<TKey, TValue> priorCollection = Volatile.Read(ref location); 350ImmutableDictionary<TKey, TValue> priorCollection = Volatile.Read(ref location); 397ImmutableDictionary<TKey, TValue> priorCollection = Volatile.Read(ref location); 440ImmutableDictionary<TKey, TValue> priorCollection = Volatile.Read(ref location); 473ImmutableDictionary<TKey, TValue> priorCollection = Volatile.Read(ref location); 506ImmutableDictionary<TKey, TValue> priorCollection = Volatile.Read(ref location); 539ImmutableStack<T> priorCollection = Volatile.Read(ref location); 568ImmutableStack<T> priorCollection = Volatile.Read(ref location); 594ImmutableQueue<T> priorCollection = Volatile.Read(ref location); 623ImmutableQueue<T> priorCollection = Volatile.Read(ref location);
System.CommandLine (2)
Invocation\ProcessTerminationHandler.cs (2)
23internal Task<int> StartedHandler { set => Volatile.Write(ref _startedHandler, value); } 89var startedHandler = Volatile.Read(ref _startedHandler);
System.ComponentModel.TypeConverter (3)
System\ComponentModel\InterlockedBitVector32.cs (1)
20get => (Volatile.Read(ref _data) & bit) == bit;
System\ComponentModel\TypeDescriptor.cs (2)
2295RefreshEventHandler? handler = Volatile.Read(ref Refreshed); 2302RefreshEventHandler? handler = Volatile.Read(ref Refreshed);
System.Console (27)
System\Console.cs (24)
48return Volatile.Read(ref s_in) ?? EnsureInitialized(); 59Volatile.Write(ref s_in, ConsolePal.GetOrCreateReader()); 75Encoding? encoding = Volatile.Read(ref s_inputEncoding); 82Volatile.Write(ref s_inputEncoding, ConsolePal.InputEncoding); 98Volatile.Write(ref s_inputEncoding, (Encoding)value.Clone()); 103Volatile.Write(ref s_in, null); 112Encoding? encoding = Volatile.Read(ref s_outputEncoding); 119Volatile.Write(ref s_outputEncoding, ConsolePal.OutputEncoding); 144Volatile.Write(ref s_out, null!); 149Volatile.Write(ref s_error, null!); 152Volatile.Write(ref s_outputEncoding, (Encoding)value.Clone()); 201return Volatile.Read(ref s_out) ?? EnsureInitialized(); 209Volatile.Write(ref s_out, CreateOutputWriter(ConsolePal.OpenStandardOutput())); 221return Volatile.Read(ref s_error) ?? EnsureInitialized(); 229Volatile.Write(ref s_error, CreateOutputWriter(ConsolePal.OpenStandardError())); 259StrongBox<bool> redirected = Volatile.Read(ref _isStdInRedirected) ?? EnsureInitialized(); 264Volatile.Write(ref _isStdInRedirected, new StrongBox<bool>(ConsolePal.IsInputRedirectedCore())); 274StrongBox<bool> redirected = Volatile.Read(ref _isStdOutRedirected) ?? EnsureInitialized(); 279Volatile.Write(ref _isStdOutRedirected, new StrongBox<bool>(ConsolePal.IsOutputRedirectedCore())); 289StrongBox<bool> redirected = Volatile.Read(ref _isStdErrRedirected) ?? EnsureInitialized(); 294Volatile.Write(ref _isStdErrRedirected, new StrongBox<bool>(ConsolePal.IsErrorRedirectedCore())); 713Volatile.Write(ref s_in, newIn); 733Volatile.Write(ref s_out, newOut); 750Volatile.Write(ref s_error, newError);
System\ConsolePal.Unix.cs (3)
86return Volatile.Read(ref s_stdInReader) ?? EnsureInitialized(); 989int cursorVersion = mayChangeCursorPosition ? Volatile.Read(ref s_cursorVersion) : -1; 1112Volatile.Write(ref s_invalidateCachedSettings, 1);
System.Data.OleDb (1)
ColumnBinding.cs (1)
1048Volatile.Write(ref delegateInstance, mi.CreateDelegate(typeof(Func<object, IntPtr>)));
System.Diagnostics.DiagnosticSource (12)
System\Diagnostics\ActivityListener.cs (4)
63internal bool IsDisposed => Volatile.Read(ref _disposed); 79if (Volatile.Read(ref _disposed)) 92if (Volatile.Read(ref _disposed)) 100Volatile.Write(ref _disposed, true);
System\Diagnostics\ActivitySource.cs (3)
83SynchronizedList<ActivityListener>? listeners = Volatile.Read(ref _listeners); 476SynchronizedList<ActivityListener>? listeners = Volatile.Read(ref _listeners); 503SynchronizedList<ActivityListener>? listeners = Volatile.Read(ref _listeners);
System\Diagnostics\Metrics\CounterAggregator.cs (2)
99Volatile.Write(ref _currValue, value); 108currentValue = Volatile.Read(ref _currValue);
System\Diagnostics\Metrics\LastValueAggregator.cs (2)
48public override void Update(double value) => Volatile.Write(ref _lastValue, value); 50public override IAggregationStatistics Collect() => new SynchronousLastValueStatistics(Volatile.Read(ref _lastValue));
System\Diagnostics\RateLimiter.cs (1)
46int currentOperationCount = Volatile.Read(ref _currentOperationCount);
System.Diagnostics.PerformanceCounter (2)
System\Diagnostics\SharedPerformanceCounter.cs (2)
996long tickDelta = (DateTime.Now.Ticks - Volatile.Read(ref s_lastInstanceLifetimeSweepTick)); 1102Volatile.Write(ref s_lastInstanceLifetimeSweepTick, DateTime.Now.Ticks);
System.Diagnostics.Process (2)
System\Diagnostics\Process.Unix.cs (2)
437long ticksPerSecond = Volatile.Read(ref s_ticksPerSecond); 448Volatile.Write(ref s_ticksPerSecond, ticksPerSecond);
System.Formats.Nrbf (1)
System\Formats\Nrbf\Utils\BinaryReaderExtensions.cs (1)
203Volatile.Write(ref s_baseAmbiguousDstDateTime, baseDateTime); // it's ok if two threads race here
System.IO.Pipes (2)
Microsoft\Win32\SafeHandles\SafePipeHandle.Unix.cs (2)
43if (disposing && Volatile.Read(ref _pipeSocket) is Socket socket) 90Volatile.Write(ref _pipeSocket, null);
System.IO.Ports (2)
System\IO\Ports\SerialStream.Unix.cs (2)
364get => Volatile.Read(ref field); 365set => Volatile.Write(ref field, value);
System.Linq.Expressions (3)
System\Dynamic\Utils\CacheDict.cs (3)
58Entry entry = Volatile.Read(ref _entries[idx]); 78Entry entry = Volatile.Read(ref _entries[idx]); 81Volatile.Write(ref _entries[idx], new Entry(hash, key, value));
System.Linq.Parallel (1)
System\Linq\Parallel\QueryOperators\Unary\SingleQueryOperator.cs (1)
176if (Volatile.Read(ref _totalElementCount.Value) > 1)
System.Net.Http (7)
System\Net\Http\SocketsHttpHandler\ConnectionPool\HttpConnectionPool.Http1.cs (2)
376if (Volatile.Read(ref _http11RequestQueueIsEmptyAndNotDisposed)) 392if (!Volatile.Read(ref _http11RequestQueueIsEmptyAndNotDisposed))
System\Net\Http\SocketsHttpHandler\ConnectionPool\HttpConnectionPool.Http2.cs (1)
338Volatile.Write(ref waiter.ConnectionCancellationTokenSource, null);
System\Net\Http\SocketsHttpHandler\CreditManager.cs (1)
31public bool IsCreditAvailable => Volatile.Read(ref _current) > 0;
System\Net\Http\SocketsHttpHandler\Http3Connection.cs (1)
54public Exception? AbortException => Volatile.Read(ref _abortException);
System\Net\Http\SocketsHttpHandler\Http3RequestStream.cs (2)
66get => Volatile.Read(ref _streamId); 67set => Volatile.Write(ref _streamId, value);
System.Net.Http.WinHttpHandler (3)
src\runtime\src\libraries\Common\src\System\Threading\Tasks\RendezvousAwaitable.cs (1)
44Action? c = Volatile.Read(ref _continuation);
System\Net\Http\CachedCertificateValue.cs (2)
18get => Volatile.Read(ref _lastUsedTime); 19set => Volatile.Write(ref _lastUsedTime, value);
System.Net.Quic (11)
src\runtime\src\libraries\Common\src\System\Net\StreamBuffer.cs (1)
339Volatile.Write(ref _hasWaiter, true);
System\Net\Quic\Internal\ResettableValueTaskSource.cs (1)
58public bool IsCompleted => (State)Volatile.Read(ref Unsafe.As<State, byte>(ref _state)) == State.Completed;
System\Net\Quic\Internal\ValueTaskSource.cs (1)
41public bool IsCompleted => (State)Volatile.Read(ref Unsafe.As<State, byte>(ref _state)) == State.Completed;
System\Net\Quic\QuicStream.cs (6)
460Volatile.Write(ref _sendLocked, 0); 467exception = Volatile.Read(ref _sendException); 536Volatile.Write(ref _sendLocked, 0); 607Volatile.Write(ref _receivedNeedsEnable, 1); 619Volatile.Write(ref _sendLocked, 0); 622Exception? exception = Volatile.Read(ref _sendException);
System\Net\Quic\QuicStream.Stream.cs (2)
89public override bool CanRead => !Volatile.Read(ref _disposed) && _canRead; 152public override bool CanWrite => !Volatile.Read(ref _disposed) && _canWrite;
System.Net.Requests (1)
System\Net\WebRequest.cs (1)
371Volatile.Write(ref s_prefixList, value);
System.Net.Sockets (11)
System\Net\Sockets\Socket.Unix.cs (2)
159Volatile.Write(ref _handle, newHandle); 168if (Volatile.Read(ref _disposed))
System\Net\Sockets\SocketAsyncContext.Unix.cs (8)
52Volatile.Write(ref _cachedAcceptOperation, operation); // benign race condition 61Volatile.Write(ref _cachedBufferMemoryReceiveOperation, operation); // benign race condition 70Volatile.Write(ref _cachedBufferListReceiveOperation, operation); // benign race condition 79Volatile.Write(ref _cachedBufferMemorySendOperation, operation); // benign race condition 88Volatile.Write(ref _cachedBufferListSendOperation, operation); // benign race condition 820QueueState state = (QueueState)Volatile.Read(ref Unsafe.As<QueueState, int>(ref _state)); 821observedSequenceNumber = Volatile.Read(ref _sequenceNumber); 1302Volatile.Write(ref _asyncEngine, engine);
System\Net\Sockets\TCPClient.cs (1)
279Socket chkClientSocket = Volatile.Read(ref _clientSocket);
System.Net.WebClient (2)
src\runtime\src\libraries\Common\src\System\Threading\Tasks\RendezvousAwaitable.cs (1)
44Action? c = Volatile.Read(ref _continuation);
System\Net\WebClient.cs (1)
216public bool IsBusy => Volatile.Read(ref _callNesting) > 0;
System.Private.CoreLib (192)
Internal\Runtime\Augments\RuntimeAugments.cs (3)
274Volatile.Write<object>(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)address), fieldValue); 279return Volatile.Read<object>(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)address)); 285Volatile.Write<object>(ref Unsafe.As<byte, object>(ref address), fieldValue);
src\runtime\src\coreclr\nativeaot\Common\src\System\Collections\Concurrent\ConcurrentUnifier.cs (2)
157int i = Volatile.Read(ref _buckets[bucket]); 188Volatile.Write(ref _buckets[bucket], newEntryIdx);
src\runtime\src\coreclr\nativeaot\Common\src\System\Collections\Concurrent\ConcurrentUnifierW.cs (2)
184int i = Volatile.Read(ref _buckets[bucket]); 245Volatile.Write(ref _buckets[bucket], newEntryIdx);
src\runtime\src\coreclr\nativeaot\Common\src\System\Collections\Concurrent\ConcurrentUnifierWKeyed.cs (2)
193int i = Volatile.Read(ref _buckets[bucket]); 227Volatile.Write(ref _buckets[bucket], newEntryIdx);
src\runtime\src\coreclr\nativeaot\Runtime.Base\src\System\Runtime\CachedInterfaceDispatch.cs (1)
98Volatile.Write(ref pDispatchCell->MethodTable, (nint)pInstanceType);
src\runtime\src\coreclr\tools\Common\TypeSystem\Common\Utilities\LockFreeReaderHashtable.cs (10)
194sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel); 224sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel); 243TValue sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel); 250TValue value = Volatile.Read(ref hashtable[tableIndex]); 291TValue sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel); 405TValue examineEntry = Volatile.Read(ref hashTable[tableIndex]); 534Volatile.Write(ref hashTableLocal[tableIndex], value); 546Volatile.Write(ref hashTableLocal[tableIndex], default(TValue)!); 616sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel); 640sentinel = Volatile.Read(ref _entryInProcessOfWritingSentinel);
src\runtime\src\coreclr\tools\Common\TypeSystem\Common\Utilities\LockFreeReaderHashtableOfPointers.cs (5)
221IntPtr value = Volatile.Read(ref hashtable[tableIndex]); 360IntPtr examineEntry = Volatile.Read(ref hashTable[tableIndex]); 483Volatile.Write(ref hashTableLocal[tableIndex], value); 494Volatile.Write(ref hashTableLocal[tableIndex], IntPtr.Zero); 619IntPtr examineEntry = Volatile.Read(ref _hashtableContentsToEnumerate[_index]);
src\runtime\src\libraries\Common\src\System\Collections\Concurrent\SingleProducerSingleConsumerQueue.cs (1)
124Volatile.Write(ref _tail._next, newSegment); // ensure segment not published until item is fully stored
src\runtime\src\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.ThreadPoolValueTaskSource.cs (1)
76Volatile.Write(ref _fileHandle._reusableThreadPoolValueTaskSource, this);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\Concurrent\ConcurrentDictionary.cs (7)
486Volatile.Write(ref bucket, curr._next); 685Volatile.Write(ref bucket, newNode); 982Volatile.Write(ref bucket, newNode); 1006Volatile.Write(ref bucket, resultNode); 2442Volatile.Write(ref bucket, newNode); 2472Volatile.Write(ref bucket, resultNode); 2628Volatile.Write(ref bucket, curr._next);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\Concurrent\ConcurrentQueue.cs (23)
266int headHead = Volatile.Read(ref head._headAndTail.Head); 267int headTail = Volatile.Read(ref head._headAndTail.Tail); 278headHead == Volatile.Read(ref head._headAndTail.Head) && 279headTail == Volatile.Read(ref head._headAndTail.Tail)) 288int tailHead = Volatile.Read(ref tail._headAndTail.Head); 289int tailTail = Volatile.Read(ref tail._headAndTail.Tail); 292headHead == Volatile.Read(ref head._headAndTail.Head) && 293headTail == Volatile.Read(ref head._headAndTail.Tail) && 294tailHead == Volatile.Read(ref tail._headAndTail.Head) && 295tailTail == Volatile.Read(ref tail._headAndTail.Tail)) 314int tailHead = Volatile.Read(ref tail._headAndTail.Head); 315int tailTail = Volatile.Read(ref tail._headAndTail.Tail); 316if (headHead == Volatile.Read(ref head._headAndTail.Head) && 317headTail == Volatile.Read(ref head._headAndTail.Tail) && 318tailHead == Volatile.Read(ref tail._headAndTail.Head) && 319tailTail == Volatile.Read(ref tail._headAndTail.Tail)) 379int headTail = (head == tail ? tailTail : Volatile.Read(ref head._headAndTail.Tail)) - head.FreezeOffset; 516headHead = Volatile.Read(ref head._headAndTail.Head); 517tailTail = Volatile.Read(ref tail._headAndTail.Tail); 533while ((Volatile.Read(ref segment._slots[i].SequenceNumber) & segment._slotsMask) != expectedSequenceNumberAndMask) 553int headTail = (head == tail ? tailTail : Volatile.Read(ref head._headAndTail.Tail)) - head.FreezeOffset; 767ConcurrentQueueSegment<T>? next = Volatile.Read(ref s._nextSegment); 785else if (Volatile.Read(ref s._nextSegment) == null)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Collections\Concurrent\ConcurrentQueueSegment.cs (11)
116int currentHead = Volatile.Read(ref _headAndTail.Head); 120int sequenceNumber = Volatile.Read(ref slots[slotsIndex].SequenceNumber); 140if (!Volatile.Read(ref _preservedForObservation)) 149Volatile.Write(ref slots[slotsIndex].SequenceNumber, currentHead + slots.Length); 167int currentTail = Volatile.Read(ref _headAndTail.Tail); 212int currentHead = Volatile.Read(ref _headAndTail.Head); 216int sequenceNumber = Volatile.Read(ref slots[slotsIndex].SequenceNumber); 236int currentTail = Volatile.Read(ref _headAndTail.Tail); 274int currentTail = Volatile.Read(ref _headAndTail.Tail); 278int sequenceNumber = Volatile.Read(ref slots[slotsIndex].SequenceNumber); 298Volatile.Write(ref slots[slotsIndex].SequenceNumber, currentTail + 1);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventCounter.cs (1)
63int count = Volatile.Read(ref _count);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventPipeEventDispatcher.cs (4)
125Debug.Assert(Volatile.Read(ref m_sessionID) == 0); 126Volatile.Write(ref m_sessionID, sessionID); 141ulong sessionID = Volatile.Read(ref m_sessionID); 145Volatile.Write(ref m_sessionID, 0);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventPipeEventDispatcher.Threads.cs (1)
46while (Volatile.Read(ref m_sessionID) == sessionID)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\TraceLogging\TraceLoggingEventHandleTable.cs (2)
27IntPtr[] innerTable = Volatile.Read(ref m_innerTable); 53Volatile.Write(ref m_innerTable, newTable);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Globalization\OrdinalCasing.Icu.cs (2)
514Volatile.Write(ref s_casingTable[pageNumber], casingTable); 555Volatile.Write(ref s_lowerCasingTable[pageNumber], i == 256 ? NoCasingPage : casingTable);
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\Strategies\OSFileStreamStrategy.cs (1)
278if (_fileHandle.TryGetCachedLength(out long cachedLength) && Volatile.Read(ref _filePosition) >= cachedLength)
src\runtime\src\libraries\System.Private.CoreLib\src\System\IO\UnmanagedMemoryStream.cs (5)
370long len = (long)Volatile.Read(ref _length); 492long len = (long)Volatile.Read(ref _length); 590Volatile.Write(ref _length, (nuint)value); // volatile to prevent reading of uninitialized memory 657Volatile.Write(ref _length, (nuint)n); // volatile to prevent reading of uninitialized memory 784Volatile.Write(ref _length, (nuint)n); // volatile to prevent reading of uninitialized memory
src\runtime\src\libraries\System.Private.CoreLib\src\System\Reflection\Emit\Opcode.cs (2)
112string name = Volatile.Read(ref nameCache[idx]); 118Volatile.Write(ref nameCache[idx], name);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\CastCache.cs (4)
159uint version = Volatile.Read(ref pEntry._version); 181Volatile.ReadBarrier(); 317Volatile.Write(ref pEntry._version, newVersion + 1); 378Volatile.Write(ref pEntry._version, newVersion + 1);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\ConditionalWeakTable.cs (4)
624Volatile.Write(ref _buckets[bucket], newEntry); 660for (int entriesIndex = Volatile.Read(ref _buckets[bucket]); entriesIndex != -1; entriesIndex = _entries[entriesIndex].Next) 732Volatile.Write(ref entry.HashCode, -1); 865Volatile.Write(ref oldEntry.HashCode, -1);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\GenericCache.cs (4)
153uint version = Volatile.Read(ref pEntry.Version); 166Volatile.ReadBarrier(); 300Volatile.Write(ref pEntry.Version, newVersion + 1); 362Volatile.Write(ref pEntry.Version, newVersion + 1);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\PoolingAsyncValueTaskMethodBuilderT.cs (1)
373Volatile.Write(ref slot, this);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeHandle.cs (1)
76Volatile.Write(ref _fullyInitialized, true);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Runtime\MemoryFailPoint.cs (6)
92get => Volatile.Read(ref s_hiddenLastKnownFreeAddressSpace); 93set => Volatile.Write(ref s_hiddenLastKnownFreeAddressSpace, value); 101get => Volatile.Read(ref s_hiddenLastTimeCheckingAddressSpace); 102set => Volatile.Write(ref s_hiddenLastTimeCheckingAddressSpace, value); 337Debug.Assert(Volatile.Read(ref s_failPointReservedMemory) >= 0, "Process-wide MemoryFailPoint reserved memory was negative!"); 338return (ulong)Volatile.Read(ref s_failPointReservedMemory);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Security\SecureString.cs (3)
72return Volatile.Read(ref _decryptedLength); 210return Volatile.Read(ref _readOnly); 216Volatile.Write(ref _readOnly, true);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\CancellationTokenSource.cs (5)
329Registrations? registrations = Volatile.Read(ref _registrations); 500Volatile.Read(ref _registrations)?.UnregisterAll(); 605Registrations? registrations = Volatile.Read(ref _registrations); 1132while (Volatile.Read(ref ExecutingCallbackId) == id) 1149while (Volatile.Read(ref ExecutingCallbackId) == id)
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\LazyInitializer.cs (11)
51Volatile.Read(ref target!) ?? EnsureInitializedCore(ref target); 103Volatile.Read(ref target!) ?? EnsureInitializedCore(ref target, valueFactory); 136if (Volatile.Read(ref initialized)) 160if (!Volatile.Read(ref initialized)) 171Volatile.Write(ref initialized, true); 196if (Volatile.Read(ref initialized)) 222if (!Volatile.Read(ref initialized)) 225Volatile.Write(ref initialized, true); 243Volatile.Read(ref target!) ?? EnsureInitializedCore(ref target, ref syncLock, valueFactory); 262if (Volatile.Read(ref target) == null) 264Volatile.Write(ref target, valueFactory());
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Lock.cs (3)
780StaticsInitializationStage stage = (StaticsInitializationStage)Volatile.Read(ref s_staticsInitializationStage); 805stage = (StaticsInitializationStage)Volatile.Read(ref s_staticsInitializationStage); 895Volatile.Write(
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\ManualResetEventSlim.cs (1)
104return Volatile.Read(ref m_combinedState) < 0;
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.cs (4)
259workerThreads = Volatile.Read(ref _minThreads); 320workerThreads = Volatile.Read(ref _maxThreads); 428Volatile.Write(ref _separated.priorCompletedWorkRequestsTime, currentTicks); 454int priorTime = Volatile.Read(ref _separated.priorCompletedWorkRequestsTime);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.ThreadCounts.cs (1)
162public ThreadCounts VolatileRead() => new ThreadCounts(Volatile.Read(ref _data));
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\ReaderWriterLockSlim.cs (1)
1611Volatile.Write(ref _isLocked, false);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\ConcurrentExclusiveSchedulerPair.cs (2)
149return Volatile.Read(ref m_completionState) ?? InitializeCompletionState(); 160private bool CompletionRequested => m_completionState != null && Volatile.Read(ref m_completionState.m_completionRequested);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Sources\ManualResetValueTaskSourceCore.cs (1)
83internal bool IsCompleted => ReferenceEquals(Volatile.Read(ref _continuation), ManualResetValueTaskSourceCoreShared.s_sentinel);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (16)
198Volatile.Read(ref s_currentActiveTasks) ?? 227return Volatile.Read(ref s_runtimeAsyncContinuationTimestamps) ?? 234return Volatile.Read(ref s_runtimeAsyncTaskTimestamps) ?? 1342if (Volatile.Read(ref m_taskId) == 0) 1465ContingentProperties? props = Volatile.Read(ref m_contingentProperties); 1479return Volatile.Read(ref m_contingentProperties) ?? InitializeContingentProperties(); 1504ContingentProperties? props = Volatile.Read(ref m_contingentProperties); 1661ContingentProperties? props = Volatile.Read(ref m_contingentProperties); 1766ContingentProperties? cp = Volatile.Read(ref m_contingentProperties); 2025return Volatile.Read(ref m_contingentProperties)?.m_exceptionsHolder?.GetCancellationExceptionDispatchInfo(); // may be null 2031Volatile.Read(ref m_contingentProperties)?.m_exceptionsHolder?.MarkAsHandled(calledFromFinalizer: false); 2201ContingentProperties? cp = Volatile.Read(ref m_contingentProperties); 2249cp = Volatile.Read(ref m_contingentProperties); // need to re-read after updating state 2311ContingentProperties? props = Volatile.Read(ref m_contingentProperties); 2372TaskExceptionHolder? exceptionHolder = Volatile.Read(ref task.m_contingentProperties)!.m_exceptionsHolder; 3465ContingentProperties? cp = Volatile.Read(ref m_contingentProperties);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\Thread.cs (26)
567public static byte VolatileRead(ref byte address) => Volatile.Read(ref address); 570public static double VolatileRead(ref double address) => Volatile.Read(ref address); 573public static short VolatileRead(ref short address) => Volatile.Read(ref address); 576public static int VolatileRead(ref int address) => Volatile.Read(ref address); 579public static long VolatileRead(ref long address) => Volatile.Read(ref address); 582public static nint VolatileRead(ref nint address) => Volatile.Read(ref address); 586public static object? VolatileRead([NotNullIfNotNull(nameof(address))] ref object? address) => Volatile.Read(ref address); 590public static sbyte VolatileRead(ref sbyte address) => Volatile.Read(ref address); 593public static float VolatileRead(ref float address) => Volatile.Read(ref address); 597public static ushort VolatileRead(ref ushort address) => Volatile.Read(ref address); 601public static uint VolatileRead(ref uint address) => Volatile.Read(ref address); 605public static ulong VolatileRead(ref ulong address) => Volatile.Read(ref address); 609public static nuint VolatileRead(ref nuint address) => Volatile.Read(ref address); 612public static void VolatileWrite(ref byte address, byte value) => Volatile.Write(ref address, value); 615public static void VolatileWrite(ref double address, double value) => Volatile.Write(ref address, value); 618public static void VolatileWrite(ref short address, short value) => Volatile.Write(ref address, value); 621public static void VolatileWrite(ref int address, int value) => Volatile.Write(ref address, value); 624public static void VolatileWrite(ref long address, long value) => Volatile.Write(ref address, value); 627public static void VolatileWrite(ref nint address, nint value) => Volatile.Write(ref address, value); 630public static void VolatileWrite([NotNullIfNotNull(nameof(value))] ref object? address, object? value) => Volatile.Write(ref address, value); 634public static void VolatileWrite(ref sbyte address, sbyte value) => Volatile.Write(ref address, value); 637public static void VolatileWrite(ref float address, float value) => Volatile.Write(ref address, value); 641public static void VolatileWrite(ref ushort address, ushort value) => Volatile.Write(ref address, value); 645public static void VolatileWrite(ref uint address, uint value) => Volatile.Write(ref address, value); 649public static void VolatileWrite(ref ulong address, ulong value) => Volatile.Write(ref address, value); 653public static void VolatileWrite(ref nuint address, nuint value) => Volatile.Write(ref address, value);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolWorkQueue.cs (4)
250Volatile.Write(ref m_array[i & m_mask], null); 293object? obj = Volatile.Read(ref m_array[idx]); 313object? obj = Volatile.Read(ref m_array[idx]); 358object? obj = Volatile.Read(ref m_array[idx]);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Threading\WaitSubsystem.ThreadWaitInfo.Unix.cs (1)
562return Volatile.Read(ref _namedMutexOwnershipChain) ?? AllocateOwnershipChain();
System\Reflection\Runtime\TypeInfos\RuntimeTypeInfo.TypeComponentsCache.cs (2)
69object result = Volatile.Read(ref _nameAgnosticQueryCaches[index]); 75Volatile.Write(ref _nameAgnosticQueryCaches[index], result);
System\Threading\ManagedThreadId.cs (2)
216var priorIdDispenser = Volatile.Read(ref s_idDispenser); 238var priorIdDispenser = Volatile.Read(ref s_idDispenser);
System\Threading\SyncTable.cs (1)
186Volatile.Write(ref s_entries, newEntries);
System\Threading\Thread.NativeAot.cs (2)
494Volatile.Write(ref s_allDone, new ManualResetEvent(false)); 498if (Volatile.Read(ref s_foregroundRunningCount) == 0)
System.Reflection.Metadata (1)
System\Reflection\PortableExecutable\PEReader.cs (1)
390AbstractMemoryBlock? existingBlock = Volatile.Read(ref _lazyPESectionBlocks[index]);
System.Reflection.MetadataLoadContext (8)
System\Reflection\TypeLoading\Assemblies\RoAssembly.Modules.cs (2)
53RoModule? module = Volatile.Read(ref _loadedModules[i]); 79RoModule? prior = Volatile.Read(ref _loadedModules[loadedModulesIndex]);
System\Reflection\TypeLoading\General\Ecma\MetadataTable.cs (1)
36T? result = Volatile.Read(ref table[index]);
System\Reflection\TypeLoading\Modules\GetTypeCoreCache.cs (2)
84int i = Volatile.Read(ref _buckets[bucket]); 115Volatile.Write(ref _buckets[bucket], newEntryIdx);
System\Reflection\TypeLoading\RuntimeTypeInfo.TypeComponentsCache.cs (3)
65object result = Volatile.Read(ref _nameAgnosticQueryCaches[index]); 70Volatile.Write(ref _nameAgnosticQueryCaches[index], newResult); 78Volatile.Write(ref _nameAgnosticQueryCaches[index], newResult);
System.Security.Cryptography (1)
src\runtime\src\libraries\Common\src\Interop\Windows\BCrypt\BCryptAeadHandleCache.cs (1)
28SafeAlgorithmHandle? existingHandle = Volatile.Read(ref handle);
System.Text.Encodings.Web (2)
System\Text\Unicode\UnicodeRanges.cs (2)
33Volatile.Write(ref range, new UnicodeRange(0, 0)); 41Volatile.Write(ref range, UnicodeRange.Create(first, last));
System.Text.Json (14)
System\Text\Json\Serialization\Metadata\JsonPropertyInfo.cs (3)
168Func<ICustomAttributeProvider>? attributeProviderFactory = Volatile.Read(ref AttributeProviderFactory); 174Volatile.Write(ref AttributeProviderFactory, null); 184Volatile.Write(ref AttributeProviderFactory, null);
System\Text\Json\Serialization\Metadata\JsonTypeInfo.cs (4)
902Func<ICustomAttributeProvider>? ctorAttrProviderFactory = Volatile.Read(ref ConstructorAttributeProviderFactory); 908Volatile.Write(ref ConstructorAttributeProviderFactory, null); 918Volatile.Write(ref ConstructorAttributeProviderFactory, null); 1106JsonTypeClassifierFactory? factory = Volatile.Read(ref _typeClassifierFactory);
System\Text\Json\Serialization\Metadata\ReflectionEmitCachingMemberAccessor.Cache.cs (7)
40Volatile.Write(ref entry.LastUsedTimestamp, nowTimestamp); 42if (Stopwatch.GetElapsedTime(Volatile.Read(ref _lastEvictedTimestamp), nowTimestamp) >= _evictionInterval) 46if (Stopwatch.GetElapsedTime(Volatile.Read(ref _lastEvictedTimestamp), nowTimestamp) >= _evictionInterval) 49Volatile.Write(ref _lastEvictedTimestamp, nowTimestamp); 52Volatile.Write(ref _evictLock, 0); 62Volatile.Write(ref _lastEvictedTimestamp, Stopwatch.GetTimestamp()); 69if (Stopwatch.GetElapsedTime(Volatile.Read(ref kvp.Value.LastUsedTimestamp), nowTimestamp) >= _slidingExpiration)
System.Text.RegularExpressions (11)
System\Text\RegularExpressions\Regex.Cache.cs (5)
188lastAccessedStamp = Volatile.Read(ref lastAccessed.LastAccessStamp); 202Volatile.Write(ref node.LastAccessStamp, lastAccessedStamp + 1); 257long min = Volatile.Read(ref s_cacheList[minListIndex].LastAccessStamp); 263long next = Volatile.Read(ref s_cacheList[nextIndex].LastAccessStamp); 284node.LastAccessStamp = Volatile.Read(ref lastAccessed.LastAccessStamp) + 1;
System\Text\RegularExpressions\Symbolic\SymbolicRegexMatcher.Automata.cs (4)
114Volatile.Write(ref array, newArray); 377Volatile.Write(ref _dfaDelta[offset], targetState.Id); 412Volatile.Write(ref _nfaDelta[nfaOffset], targets); 444Volatile.Write(ref _capturingNfaDelta[offset], targets);
System\Text\RegularExpressions\Symbolic\SymbolicRegexNode.cs (2)
247byte b = Volatile.Read(ref _nullabilityCache[context]); 328Volatile.Write(ref _nullabilityCache[context], is_nullable ? TrueByte : FalseByte);
System.Threading (3)
src\runtime\artifacts\obj\System.Threading\Release\net11.0\System.Threading.Forwards.cs (1)
31[assembly: System.Runtime.CompilerServices.TypeForwardedTo(typeof(System.Threading.Volatile))]
System\Threading\Barrier.cs (2)
187get { return Volatile.Read(ref _currentPhase); } 189internal set { Volatile.Write(ref _currentPhase, value); }
System.Threading.Channels (5)
src\runtime\src\libraries\Common\src\System\Collections\Concurrent\SingleProducerSingleConsumerQueue.cs (1)
124Volatile.Write(ref _tail._next, newSegment); // ensure segment not published until item is fully stored
System\Threading\Channels\AsyncOperation.cs (4)
142internal bool IsCompleted => ReferenceEquals(Volatile.Read(ref _continuation), s_completedSentinel); 209if (Volatile.Read(ref _continuation) is not null || 485Volatile.Write(ref _continuation, s_availableSentinel); 541Volatile.Write(ref _continuation, s_availableSentinel);
System.Threading.RateLimiting (6)
System\Threading\RateLimiting\DefaultPartitionedRateLimiter.cs (2)
114Volatile.Write(ref limiterEntry.LastAccessTimestamp, Stopwatch.GetTimestamp()); 312? RateLimiterHelper.GetElapsedTime(Volatile.Read(ref limiterEntry.LastAccessTimestamp))
System\Threading\RateLimiting\FixedWindowRateLimiter.cs (4)
98TotalFailedLeases = Volatile.Read(ref _failedLeasesCount), 99TotalSuccessfulLeases = Volatile.Read(ref _successfulLeasesCount), 220long lastReplenishmentTick = Volatile.Read(ref _lastReplenishmentTick); 309Volatile.Write(ref _lastReplenishmentTick, nowTicks);
System.Threading.Tasks.Dataflow (14)
Base\DataflowBlock.cs (4)
1084if (Volatile.Read(ref target._cleanupReserved)) 1157if (Volatile.Read(ref _cleanupReserved)) return DataflowMessageStatus.DecliningPermanently; 1208if (Volatile.Read(ref _cleanupReserved)) return false; 1228Debug.Assert(Volatile.Read(ref _cleanupReserved), "Should only be called once by whomever reserved the right.");
Blocks\BatchBlock.cs (1)
676bool triggered = Volatile.Read(ref _nonGreedyState.AcceptFewerThanBatchSize);
Blocks\BroadcastBlock.cs (1)
1142(Volatile.Read(ref _exceptions) != null && _decliningPermanently);
Blocks\JoinBlock.cs (2)
75Volatile.Write(ref _sharedResources!._hasExceptions, true); 293Volatile.Write(ref _sharedResources!._hasExceptions, true);
Internal\SourceCore.cs (2)
497return Volatile.Read(ref _exceptions) != null; 553if (!Volatile.Read(ref _enableOffering))
Internal\TargetCore.cs (3)
708return _dataflowBlockOptions.CancellationToken.IsCancellationRequested || Volatile.Read(ref _exceptions) != null; 776if (Volatile.Read(ref _exceptions) != null) 781_completionSource.TrySetException(Volatile.Read(ref _exceptions!));
src\runtime\src\libraries\Common\src\System\Collections\Concurrent\SingleProducerSingleConsumerQueue.cs (1)
124Volatile.Write(ref _tail._next, newSegment); // ensure segment not published until item is fully stored
System.Threading.Tasks.Parallel (2)
System\Threading\Tasks\ParallelLoopState.cs (2)
362return Unsafe.BitCast<int, TInt>(Volatile.Read(ref Unsafe.As<TInt, int>(ref _lowestBreakIteration))); 366return Unsafe.BitCast<long, TInt>(Volatile.Read(ref Unsafe.As<TInt, long>(ref _lowestBreakIteration)));