641 references to Volatile
InMemory.FunctionalTests (1)
src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
75if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.ConcurrencyLimiter (2)
ConcurrencyLimiterEventSource.cs (2)
91_rejectedRequestsCounter ??= new PollingCounter("requests-rejected", this, () => Volatile.Read(ref _rejectedRequests)) 96_queueLengthCounter ??= new PollingCounter("queue-length", this, () => Volatile.Read(ref _queueLength))
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 (15)
KeyManagement\KeyRing.cs (3)
78IAuthenticatedEncryptor? encryptor = Volatile.Read(ref _encryptor); 83encryptor = Volatile.Read(ref _encryptor); 87Volatile.Write(ref _encryptor, encryptor);
KeyManagement\KeyRingBasedDataProtector.cs (2)
333var existingTemplate = Volatile.Read(ref _aadTemplate); 356Volatile.Write(ref _aadTemplate, newTemplate);
KeyManagement\KeyRingProvider.cs (10)
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); 422var newCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 460Volatile.Write(ref _cacheableKeyRing, newCacheableKeyRing); 465var existingCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 470Volatile.Write(ref _cacheableKeyRing, existingCacheableKeyRing.WithTemporaryExtendedLifetime(utcNow));
Microsoft.AspNetCore.DataProtection.Extensions (1)
TimeLimitedDataProtector.cs (1)
39var 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.Server.HttpSys (1)
src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
75if (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\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
75if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.Server.Kestrel.Core (11)
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))
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (1)
src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
75if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (1)
src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
75if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes (1)
src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
75if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (4)
Internal\QuicConnectionContext.cs (3)
264Volatile.Write(ref _heartbeatTimestamp, now); 271stream.PoolExpirationTimestamp = Volatile.Read(ref _heartbeatTimestamp) + StreamPoolExpirySeconds * timeProvider.TimestampFrequency; 293Volatile.Write(ref _heartbeatTimestamp, now);
src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
75if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (1)
src\Shared\Buffers.MemoryPool\DiagnosticPoolBlock.cs (1)
75if (Volatile.Read(ref _pinCount) > 0)
Microsoft.AspNetCore.SignalR.Client.Core (4)
HubConnection.cs (4)
2335Volatile.Write(ref _nextActivationSendPing, (DateTime.UtcNow + _hubConnection.KeepAliveInterval).Ticks); 2340Volatile.Write(ref _nextActivationServerTimeout, (DateTime.UtcNow + _hubConnection.ServerTimeout).Ticks); 2351if (DateTime.UtcNow.Ticks > Volatile.Read(ref _nextActivationServerTimeout)) 2356if (DateTime.UtcNow.Ticks > Volatile.Read(ref _nextActivationSendPing) && !Stopping)
Microsoft.AspNetCore.SignalR.Core (2)
HubConnectionContext.cs (2)
672var elapsed = _timeProvider.GetElapsedTime(Volatile.Read(ref _lastSendTick), currentTime); 690Volatile.Write(ref _lastSendTick, currentTime);
Microsoft.Build (5)
BackEnd\Components\RequestBuilder\RequestBuilder.cs (1)
1535var 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);
Microsoft.Build.Framework (2)
ImmutableSegmentedDictionary`2+PrivateInterlocked.cs (1)
19var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
ImmutableSegmentedList`1+PrivateInterlocked.cs (1)
19var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
Microsoft.CodeAnalysis (19)
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)
1844if (Volatile.Read(ref _eventQueueEnqueuePendingCount) != 0) 1846SpinWait.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)
562Volatile.Write(ref arr[idx].Text, text); 651Volatile.Write(ref arr[idx].Text, text);
InternalUtilities\TextKeyedCache.cs (1)
216Volatile.Write(ref arr[idx].Entry, e);
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
Microsoft.CodeAnalysis.CodeStyle (15)
src\Analyzers\Core\Analyzers\OrderModifiers\OrderModifiersHelpers.cs (2)
51var lastParsed = Volatile.Read(ref _lastParsed); 61Volatile.Write(ref _lastParsed, lastParsed);
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\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (2)
562Volatile.Write(ref arr[idx].Text, text); 651Volatile.Write(ref arr[idx].Text, text);
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
src\Dependencies\Threading\CancellationSeries.cs (1)
78var priorSource = Volatile.Read(ref _cts);
Microsoft.CodeAnalysis.Collections.Package (3)
ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
ImmutableSegmentedList`1+PrivateMarshal.cs (1)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
Microsoft.CodeAnalysis.CSharp (41)
Compilation\CSharpCompilation.cs (1)
145internal ImmutableHashSet<SyntaxTree>? UsageOfUsingsRecordedInTrees => Volatile.Read(ref _usageOfUsingsRecordedInTrees);
Symbols\Compilation_UsedAssemblies.cs (4)
66if (!_usedAssemblyReferencesFrozen && !Volatile.Read(ref _usedAssemblyReferencesFrozen)) 114if (_usedAssemblyReferencesFrozen || Volatile.Read(ref _usedAssemblyReferencesFrozen)) 138if (_usedAssemblyReferencesFrozen || Volatile.Read(ref _usedAssemblyReferencesFrozen)) 149if (_usedAssemblyReferencesFrozen || Volatile.Read(ref _usedAssemblyReferencesFrozen))
Symbols\LexicalSortKey.cs (2)
131return Volatile.Read(ref _position) >= 0; 139Volatile.Write(ref _position, other._position);
Symbols\Metadata\PE\PEGlobalNamespaceSymbol.cs (2)
85if (Volatile.Read(ref lazyTypes) == null || Volatile.Read(ref lazyNamespaces) == null)
Symbols\Metadata\PE\PEMethodSymbol.cs (8)
134public bool IsObsoleteAttributePopulated => (Volatile.Read(ref _bits) & IsObsoleteAttributePopulatedBit) != 0; 135public bool IsCustomAttributesPopulated => (Volatile.Read(ref _bits) & IsCustomAttributesPopulatedBit) != 0; 136public bool IsUseSiteDiagnosticPopulated => (Volatile.Read(ref _bits) & IsUseSiteDiagnosticPopulatedBit) != 0; 137public bool IsConditionalPopulated => (Volatile.Read(ref _bits) & IsConditionalPopulatedBit) != 0; 138public bool IsOverriddenOrHiddenMembersPopulated => (Volatile.Read(ref _bits) & IsOverriddenOrHiddenMembersPopulatedBit) != 0; 143public bool IsMemberNotNullPopulated => (Volatile.Read(ref _bits) & IsMemberNotNullPopulatedBit) != 0; 146public bool IsUnmanagedCallersOnlyAttributePopulated => (Volatile.Read(ref _bits) & IsUnmanagedCallersOnlyAttributePopulatedBit) != 0; 151public bool IsOverloadResolutionPriorityPopulated => (Volatile.Read(ref _bits) & OverloadResolutionPriorityPopulatedBit) != 0;
Symbols\Metadata\PE\PENamedTypeSymbol.cs (3)
1459if (Volatile.Read(ref _lazyMembersByName) == null) 1639if (Volatile.Read(ref _lazyMembersByName) == null) 1955var 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)
131public bool IsUseSiteDiagnosticPopulated => (Volatile.Read(ref _bits) & IsUseSiteDiagnosticPopulatedBit) != 0; 138public bool IsObsoleteAttributePopulated => (Volatile.Read(ref _bits) & IsObsoleteAttributePopulatedBit) != 0; 145public bool IsCustomAttributesPopulated => (Volatile.Read(ref _bits) & IsCustomAttributesPopulatedBit) != 0; 152public bool IsOverloadResolutionPriorityPopulated => (Volatile.Read(ref _bits) & IsOverloadResolutionPriorityPopulatedBit) != 0;
Symbols\Source\SourceMemberContainerSymbol.cs (12)
1582if (Volatile.Read(ref _lazyMembersDictionary) is Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> result) 1696RoslynDebug.AssertOrFailFast(Volatile.Read(ref _lazyTypeMembers)?.Values.Any(types => types.Contains(t => t == (object)type)) == true); 1720var membersAndInitializers = Volatile.Read(ref _lazyMembersAndInitializers); 1735var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 1748membersAndInitializers = Volatile.Read(ref _lazyMembersAndInitializers); 3469if (Volatile.Read(ref _lazyMembersAndInitializers) != null) 3486if (Volatile.Read(ref _lazyMembersAndInitializers) is not null) 3539if (Volatile.Read(ref _lazyDeclaredMembersAndInitializers) != DeclaredMembersAndInitializers.UninitializedSentinel) 3651var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 3672var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 3717var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 3742var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers);
Symbols\Source\SourceMemberFieldSymbol.cs (1)
630return _lazyFieldTypeInferred != 0 || Volatile.Read(ref _lazyFieldTypeInferred) != 0;
Symbols\Source\SourceModuleSymbol.cs (3)
277Volatile.Write(ref DeclaringCompilation.InterceptorsDiscoveryComplete, true); 329if (!Volatile.Read(ref DeclaringCompilation.InterceptorsDiscoveryComplete)) 332Volatile.Write(ref DeclaringCompilation.InterceptorsDiscoveryComplete, true);
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
src\Analyzers\CSharp\Analyzers\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (1)
104Volatile.Write(ref _hasTypeInstanceAssignment, true);
Microsoft.CodeAnalysis.CSharp.Features (1)
src\Analyzers\CSharp\Analyzers\MakeStructFieldsWritable\CSharpMakeStructFieldsWritableDiagnosticAnalyzer.cs (1)
104Volatile.Write(ref _hasTypeInstanceAssignment, true);
Microsoft.CodeAnalysis.EditorFeatures.Wpf (2)
InlineHints\InlineHintsKeyProcessorProvider.cs (2)
47return Volatile.Read(ref _state) == 1; 53Volatile.Write(ref _state, value ? 1 : 0);
Microsoft.CodeAnalysis.Features (6)
NavigateTo\AbstractNavigateToSearchService.CachedDocumentSearch.cs (4)
45Volatile.Write(ref s_cachedIndexMap, null); 46Volatile.Write(ref s_stringTable, null); 53cachedIndexMap = Volatile.Read(ref s_cachedIndexMap); 54stringTable = Volatile.Read(ref s_stringTable);
src\Analyzers\Core\Analyzers\OrderModifiers\OrderModifiersHelpers.cs (2)
51var lastParsed = Volatile.Read(ref _lastParsed); 61Volatile.Write(ref _lastParsed, lastParsed);
Microsoft.CodeAnalysis.InteractiveHost (4)
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
src\Dependencies\Threading\CancellationSeries.cs (1)
78var priorSource = Volatile.Read(ref _cts);
Microsoft.CodeAnalysis.Threading.Package (4)
CancellationSeries.cs (1)
78var priorSource = Volatile.Read(ref _cts);
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
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)
65If 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)
654If 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 (21)
Shared\Utilities\StreamingProgressTracker.cs (2)
32=> updateAction?.Invoke(Volatile.Read(ref _completedItems), Volatile.Read(ref _totalItems), cancellationToken) ?? default;
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\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (2)
562Volatile.Write(ref arr[idx].Text, text); 651Volatile.Write(ref arr[idx].Text, text);
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
src\Dependencies\Threading\CancellationSeries.cs (1)
78var 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)
157return Volatile.Read(ref _latestSolution); 507var oldSolution = Volatile.Read(ref _latestSolution);
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (13)
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\Compilers\Core\Portable\InternalUtilities\SingleInitNullable.cs (2)
52=> Volatile.Read(ref _initialized) == 2 ? _value : null; 64Volatile.Write(ref _initialized, 2);
src\Compilers\Core\Portable\InternalUtilities\StringTable.cs (2)
562Volatile.Write(ref arr[idx].Text, text); 651Volatile.Write(ref arr[idx].Text, text);
src\Compilers\Core\Portable\InternalUtilities\TextKeyedCache.cs (1)
216Volatile.Write(ref arr[idx].Entry, e);
src\Dependencies\Collections\ImmutableSegmentedDictionary`2+PrivateMarshal.cs (1)
20var dictionary = Volatile.Read(ref Unsafe.AsRef(in location._dictionary));
src\Dependencies\Collections\ImmutableSegmentedHashSet`1+PrivateMarshal.cs (1)
20var set = Volatile.Read(ref Unsafe.AsRef(in location._set));
src\Dependencies\Collections\ImmutableSegmentedList`1+PrivateMarshal.cs (1)
20var list = Volatile.Read(ref Unsafe.AsRef(in location._list));
Microsoft.Extensions.AsyncState (1)
AsyncState.cs (1)
108internal 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)
214public 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)
413hits += Volatile.Read(ref stats.Hits); 414misses += Volatile.Read(ref stats.Misses); 443_accumulatedHits += Volatile.Read(ref current.Hits); 444_accumulatedMisses += Volatile.Read(ref current.Misses); 782internal 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.Http (2)
ActiveHandlerTrackingEntry.cs (2)
51if (Volatile.Read(ref _timerInitialized)) 65if (Volatile.Read(ref _timerInitialized))
Microsoft.Extensions.Primitives (1)
ChangeToken.cs (1)
115IDisposable? current = Volatile.Read(ref _disposable);
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);
mscorlib (1)
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))]
System.Collections.Concurrent (9)
System\Collections\Concurrent\ConcurrentDictionary.cs (7)
486Volatile.Write(ref bucket, curr._next); 685Volatile.Write(ref bucket, newNode); 1007Volatile.Write(ref bucket, newNode); 1031Volatile.Write(ref bucket, resultNode); 2472Volatile.Write(ref bucket, newNode); 2502Volatile.Write(ref bucket, resultNode); 2658Volatile.Write(ref bucket, curr._next);
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.ComponentModel.TypeConverter (3)
System\ComponentModel\InterlockedBitVector32.cs (1)
20get => (Volatile.Read(ref _data) & bit) == bit;
System\ComponentModel\TypeDescriptor.cs (2)
2286RefreshEventHandler? handler = Volatile.Read(ref Refreshed); 2293RefreshEventHandler? handler = Volatile.Read(ref Refreshed);
System.Console (27)
System\Console.cs (24)
47return Volatile.Read(ref s_in) ?? EnsureInitialized(); 58Volatile.Write(ref s_in, ConsolePal.GetOrCreateReader()); 74Encoding? encoding = Volatile.Read(ref s_inputEncoding); 81Volatile.Write(ref s_inputEncoding, ConsolePal.InputEncoding); 97Volatile.Write(ref s_inputEncoding, (Encoding)value.Clone()); 102Volatile.Write(ref s_in, null); 111Encoding? encoding = Volatile.Read(ref s_outputEncoding); 118Volatile.Write(ref s_outputEncoding, ConsolePal.OutputEncoding); 143Volatile.Write(ref s_out, null!); 148Volatile.Write(ref s_error, null!); 151Volatile.Write(ref s_outputEncoding, (Encoding)value.Clone()); 200return Volatile.Read(ref s_out) ?? EnsureInitialized(); 208Volatile.Write(ref s_out, CreateOutputWriter(ConsolePal.OpenStandardOutput())); 220return Volatile.Read(ref s_error) ?? EnsureInitialized(); 228Volatile.Write(ref s_error, CreateOutputWriter(ConsolePal.OpenStandardError())); 258StrongBox<bool> redirected = Volatile.Read(ref _isStdInRedirected) ?? EnsureInitialized(); 263Volatile.Write(ref _isStdInRedirected, new StrongBox<bool>(ConsolePal.IsInputRedirectedCore())); 273StrongBox<bool> redirected = Volatile.Read(ref _isStdOutRedirected) ?? EnsureInitialized(); 278Volatile.Write(ref _isStdOutRedirected, new StrongBox<bool>(ConsolePal.IsOutputRedirectedCore())); 288StrongBox<bool> redirected = Volatile.Read(ref _isStdErrRedirected) ?? EnsureInitialized(); 293Volatile.Write(ref _isStdErrRedirected, new StrongBox<bool>(ConsolePal.IsErrorRedirectedCore())); 666Volatile.Write(ref s_in, newIn); 686Volatile.Write(ref s_out, newOut); 703Volatile.Write(ref s_error, newError);
System\ConsolePal.Unix.cs (3)
78return Volatile.Read(ref s_stdInReader) ?? EnsureInitialized(); 981int cursorVersion = mayChangeCursorPosition ? Volatile.Read(ref s_cursorVersion) : -1; 1104Volatile.Write(ref s_invalidateCachedSettings, 1);
System.Diagnostics.DiagnosticSource (5)
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.Process (2)
System\Diagnostics\Process.Unix.cs (2)
825long ticksPerSecond = Volatile.Read(ref s_ticksPerSecond); 836Volatile.Write(ref s_ticksPerSecond, ticksPerSecond);
System.Diagnostics.TraceSource (1)
System\Diagnostics\Trace.cs (1)
25Volatile.Read(ref s_correlationManager) ??
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)
365get => Volatile.Read(ref _hasCancelledTasksToProcess); 366set => Volatile.Write(ref _hasCancelledTasksToProcess, 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)
325Volatile.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)
53public Exception? AbortException => Volatile.Read(ref _abortException);
System\Net\Http\SocketsHttpHandler\Http3RequestStream.cs (2)
64get => Volatile.Read(ref _streamId); 65set => Volatile.Write(ref _streamId, value);
System.Net.Quic (11)
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)
423Volatile.Write(ref _sendLocked, 0); 430exception = Volatile.Read(ref _sendException); 499Volatile.Write(ref _sendLocked, 0); 570Volatile.Write(ref _receivedNeedsEnable, 1); 582Volatile.Write(ref _sendLocked, 0); 585Exception? 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)
144Volatile.Write(ref _handle, newHandle); 153if (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 818QueueState state = (QueueState)Volatile.Read(ref Unsafe.As<QueueState, int>(ref _state)); 819observedSequenceNumber = Volatile.Read(ref _sequenceNumber); 1300Volatile.Write(ref _asyncEngine, engine);
System\Net\Sockets\TCPClient.cs (1)
282Socket chkClientSocket = Volatile.Read(ref _clientSocket);
System.Net.WebClient (2)
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 (186)
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\libraries\System.Private.CoreLib\src\Microsoft\Win32\SafeHandles\SafeFileHandle.ThreadPoolValueTaskSource.cs (1)
76Volatile.Write(ref _fileHandle._reusableThreadPoolValueTaskSource, this);
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\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\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventCounter.cs (1)
63int count = Volatile.Read(ref _count);
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\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventPipeEventDispatcher.Threads.cs (1)
46while (Volatile.Read(ref m_sessionID) == sessionID)
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\libraries\System.Private.CoreLib\src\System\Globalization\OrdinalCasing.Icu.cs (1)
439Volatile.Write(ref s_casingTable[pageNumber], casingTable);
src\libraries\System.Private.CoreLib\src\System\IO\Strategies\OSFileStreamStrategy.cs (1)
279if (_fileHandle.TryGetCachedLength(out long cachedLength) && Volatile.Read(ref _filePosition) >= cachedLength)
src\libraries\System.Private.CoreLib\src\System\IO\UnmanagedMemoryStream.cs (5)
369long len = (long)Volatile.Read(ref _length); 491long len = (long)Volatile.Read(ref _length); 589Volatile.Write(ref _length, (nuint)value); // volatile to prevent reading of uninitialized memory 656Volatile.Write(ref _length, (nuint)n); // volatile to prevent reading of uninitialized memory 783Volatile.Write(ref _length, (nuint)n); // volatile to prevent reading of uninitialized memory
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\libraries\System.Private.CoreLib\src\System\Reflection\FieldAccessor.cs (12)
131return Volatile.Read(ref Unsafe.As<byte, object>(ref Unsafe.AddByteOffset(ref obj.GetRawData(), _addressOrOffset))); 152return Volatile.Read(ref Unsafe.As<IntPtr, object>(ref *(IntPtr*)_addressOrOffset)); 222Volatile.Write( 230Volatile.Write( 238Volatile.Write( 246Volatile.Write( 254Volatile.Write( 261Volatile.Write(ref Unsafe.As<IntPtr, object?>(ref *(IntPtr*)_addressOrOffset), value); 266Volatile.Write( 273Volatile.Write( 280Volatile.Write( 287Volatile.Write(
src\libraries\System.Private.CoreLib\src\System\Resources\ResourceReader.Core.cs (4)
70if (Volatile.Read(ref _binaryFormatter) is null) 102if (Volatile.Read(ref s_binaryFormatterType) is null || Volatile.Read(ref s_deserializeMethod) is null) 116Volatile.Write(ref _binaryFormatter, Activator.CreateInstance(s_binaryFormatterType!));
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\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\ConditionalWeakTable.cs (4)
621Volatile.Write(ref _buckets[bucket], newEntry); 657for (int entriesIndex = Volatile.Read(ref _buckets[bucket]); entriesIndex != -1; entriesIndex = _entries[entriesIndex].Next) 729Volatile.Write(ref entry.HashCode, -1); 862Volatile.Write(ref oldEntry.HashCode, -1);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\GenericCache.cs (4)
154uint version = Volatile.Read(ref pEntry.Version); 167Volatile.ReadBarrier(); 301Volatile.Write(ref pEntry.Version, newVersion + 1); 363Volatile.Write(ref pEntry.Version, newVersion + 1);
src\libraries\System.Private.CoreLib\src\System\Runtime\CompilerServices\PoolingAsyncValueTaskMethodBuilderT.cs (1)
344Volatile.Write(ref slot, this);
src\libraries\System.Private.CoreLib\src\System\Runtime\InteropServices\SafeHandle.cs (1)
83Volatile.Write(ref _fullyInitialized, true);
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\libraries\System.Private.CoreLib\src\System\Security\SecureString.cs (3)
71return Volatile.Read(ref _decryptedLength); 209return Volatile.Read(ref _readOnly); 215Volatile.Write(ref _readOnly, true);
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); 1144while (Volatile.Read(ref ExecutingCallbackId) == id) 1161while (Volatile.Read(ref ExecutingCallbackId) == id)
src\libraries\System.Private.CoreLib\src\System\Threading\DeferredDisposableLifetime.cs (3)
50int oldCount = Volatile.Read(ref _count); 67int oldCount = Volatile.Read(ref _count); 99int oldCount = Volatile.Read(ref _count);
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\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.cs (4)
245workerThreads = Volatile.Read(ref _minThreads); 306workerThreads = Volatile.Read(ref _maxThreads); 410Volatile.Write(ref _separated.priorCompletedWorkRequestsTime, currentTicks); 436int priorTime = Volatile.Read(ref _separated.priorCompletedWorkRequestsTime);
src\libraries\System.Private.CoreLib\src\System\Threading\PortableThreadPool.ThreadCounts.cs (1)
103public ThreadCounts VolatileRead() => new ThreadCounts(Volatile.Read(ref _data));
src\libraries\System.Private.CoreLib\src\System\Threading\ReaderWriterLockSlim.cs (1)
1611Volatile.Write(ref _isLocked, false);
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\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Future.cs (1)
477Volatile.Read(ref s_Factory) ??
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Sources\ManualResetValueTaskSourceCore.cs (2)
88Volatile.Read(ref _continuation) is null || !_completed ? ValueTaskSourceStatus.Pending : 219Volatile.Read(ref _continuation) ??
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (14)
190Volatile.Read(ref s_currentActiveTasks) ?? 1195if (Volatile.Read(ref m_taskId) == 0) 1318ContingentProperties? props = Volatile.Read(ref m_contingentProperties); 1332return Volatile.Read(ref m_contingentProperties) ?? InitializeContingentProperties(); 1357ContingentProperties? props = Volatile.Read(ref m_contingentProperties); 1510ContingentProperties? props = Volatile.Read(ref m_contingentProperties); 1615ContingentProperties? cp = Volatile.Read(ref m_contingentProperties); 1873return Volatile.Read(ref m_contingentProperties)?.m_exceptionsHolder?.GetCancellationExceptionDispatchInfo(); // may be null 1879Volatile.Read(ref m_contingentProperties)?.m_exceptionsHolder?.MarkAsHandled(calledFromFinalizer: false); 2049ContingentProperties? cp = Volatile.Read(ref m_contingentProperties); 2097cp = Volatile.Read(ref m_contingentProperties); // need to re-read after updating state 2159ContingentProperties? props = Volatile.Read(ref m_contingentProperties); 2220TaskExceptionHolder? exceptionHolder = Volatile.Read(ref task.m_contingentProperties)!.m_exceptionsHolder; 3304ContingentProperties? cp = Volatile.Read(ref m_contingentProperties);
src\libraries\System.Private.CoreLib\src\System\Threading\Thread.cs (26)
564public static byte VolatileRead(ref byte address) => Volatile.Read(ref address); 567public static double VolatileRead(ref double address) => Volatile.Read(ref address); 570public static short VolatileRead(ref short address) => Volatile.Read(ref address); 573public static int VolatileRead(ref int address) => Volatile.Read(ref address); 576public static long VolatileRead(ref long address) => Volatile.Read(ref address); 579public static IntPtr VolatileRead(ref IntPtr address) => Volatile.Read(ref address); 583public static object? VolatileRead([NotNullIfNotNull(nameof(address))] ref object? address) => Volatile.Read(ref address); 587public static sbyte VolatileRead(ref sbyte address) => Volatile.Read(ref address); 590public static float VolatileRead(ref float address) => Volatile.Read(ref address); 594public static ushort VolatileRead(ref ushort address) => Volatile.Read(ref address); 598public static uint VolatileRead(ref uint address) => Volatile.Read(ref address); 602public static ulong VolatileRead(ref ulong address) => Volatile.Read(ref address); 606public static UIntPtr VolatileRead(ref UIntPtr address) => Volatile.Read(ref address); 609public static void VolatileWrite(ref byte address, byte value) => Volatile.Write(ref address, value); 612public static void VolatileWrite(ref double address, double value) => Volatile.Write(ref address, value); 615public static void VolatileWrite(ref short address, short value) => Volatile.Write(ref address, value); 618public static void VolatileWrite(ref int address, int value) => Volatile.Write(ref address, value); 621public static void VolatileWrite(ref long address, long value) => Volatile.Write(ref address, value); 624public static void VolatileWrite(ref IntPtr address, IntPtr value) => Volatile.Write(ref address, value); 627public static void VolatileWrite([NotNullIfNotNull(nameof(value))] ref object? address, object? value) => Volatile.Write(ref address, value); 631public static void VolatileWrite(ref sbyte address, sbyte value) => Volatile.Write(ref address, value); 634public static void VolatileWrite(ref float address, float value) => Volatile.Write(ref address, value); 638public static void VolatileWrite(ref ushort address, ushort value) => Volatile.Write(ref address, value); 642public static void VolatileWrite(ref uint address, uint value) => Volatile.Write(ref address, value); 646public static void VolatileWrite(ref ulong address, ulong value) => Volatile.Write(ref address, value); 650public static void VolatileWrite(ref UIntPtr address, UIntPtr value) => Volatile.Write(ref address, value);
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolWorkQueue.cs (8)
130Volatile.Write(ref m_array[tail & m_mask], obj); 159Volatile.Write(ref m_array[tail & m_mask], obj); 238Volatile.Write(ref m_array[i & m_mask], null); 281object? obj = Volatile.Read(ref m_array[idx]); 301object? obj = Volatile.Read(ref m_array[idx]); 346object? obj = Volatile.Read(ref m_array[idx]); 710Volatile.Write(ref _mayHaveHighPriorityWorkItems, true); 752Volatile.Write(ref queue._mayHaveHighPriorityWorkItems, true);
src\libraries\System.Private.CoreLib\src\System\Threading\Win32ThreadPoolNativeOverlapped.cs (3)
53while ((freePtr = Volatile.Read(ref s_freeList)) != IntPtr.Zero) 78OverlappedData[]? dataArray = Volatile.Read(ref s_dataArray); 166IntPtr freePtr = Volatile.Read(ref s_freeList);
src\System\Reflection\Emit\DynamicMethod.CoreCLR.cs (1)
109Volatile.Write(ref _signature, newSig);
src\System\Reflection\RuntimeConstructorInfo.CoreCLR.cs (1)
84Volatile.Write(ref m_signature, newSig);
src\System\Reflection\RuntimeMethodInfo.CoreCLR.cs (1)
96Volatile.Write(ref m_signature, newSig);
src\System\Runtime\CompilerServices\RuntimeHelpers.CoreCLR.cs (2)
1047public bool IsClassInited => (Volatile.Read(ref Flags) & enum_flag_Initialized) != 0; 1049public bool IsClassInitedAndActive => (Volatile.Read(ref Flags) & (enum_flag_Initialized | enum_flag_EnsuredInstanceActive)) == (enum_flag_Initialized | enum_flag_EnsuredInstanceActive);
src\System\RuntimeType.CoreCLR.cs (8)
454Volatile.Write(ref m_cacheComplete, true); 571Volatile.Write(ref cachedMembers[freeSlotIndex], newMemberInfo); // value may be read outside of lock 1393if (Volatile.Read(ref m_cacheComplete)) 2476if (Volatile.Read(ref m_cache) == IntPtr.Zero) 4400Volatile.Write(ref keys[index], key); 4455Volatile.Write(ref m_Table, newTable); 4462Table table = Volatile.Read(ref m_Table); 4476K hit = Volatile.Read(ref keys[index]);
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 (2)
src\libraries\Common\src\System\Security\Cryptography\SP800108HmacCounterKdfImplementationManaged.cs (1)
74int current = Volatile.Read(ref _keyReferenceCount);
System\Security\Cryptography\X509Certificates\OpenSslCachedSystemStoreProvider.cs (1)
319Volatile.Write(ref s_nativeCollections, newCollections);
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 (11)
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 (3)
645Func<ICustomAttributeProvider>? ctorAttrProviderFactory = Volatile.Read(ref ConstructorAttributeProviderFactory); 651Volatile.Write(ref ConstructorAttributeProviderFactory, null); 661Volatile.Write(ref ConstructorAttributeProviderFactory, null);
System\Text\Json\Serialization\Metadata\ReflectionEmitCachingMemberAccessor.Cache.cs (5)
40Volatile.Write(ref entry.LastUsedTicks, utcNowTicks); 42if (utcNowTicks - Volatile.Read(ref _lastEvictedTicks) >= _evictionIntervalTicks) 49Volatile.Write(ref _lastEvictedTicks, utcNowTicks); 52Volatile.Write(ref _evictLock, 0); 69if (utcNowTicks - Volatile.Read(ref kvp.Value.LastUsedTicks) >= _slidingExpirationTicks)
System.Text.RegularExpressions (11)
System\Text\RegularExpressions\Regex.Cache.cs (5)
168lastAccessedStamp = Volatile.Read(ref lastAccessed.LastAccessStamp); 182Volatile.Write(ref node.LastAccessStamp, lastAccessedStamp + 1); 237long min = Volatile.Read(ref s_cacheList[minListIndex].LastAccessStamp); 243long next = Volatile.Read(ref s_cacheList[nextIndex].LastAccessStamp); 264node.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)
artifacts\obj\System.Threading\Debug\net10.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 (3)
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 (2)
148Volatile.Write(ref _continuation, s_availableSentinel); // only after fetching all needed data 174Volatile.Write(ref _continuation, s_availableSentinel); // only after fetching all needed data
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\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)));
System.Xaml (2)
System\Xaml\Schema\TypeBits.cs (2)
78object value = Volatile.Read(ref _value); 102Volatile.Write(ref _value, newValue);