998 references to Volatile
aspire (26)
Backchannel\ExtensionBackchannel.cs (2)
89if (Volatile.Read(ref _connected) == 0) 172Volatile.Write(ref _connected, 1);
Commands\LsCommand.cs (5)
208onDirectoryEnumerated: count => Volatile.Write(ref directoriesSearched, count), 219updateStatus(FormatSearchingStatus(Volatile.Read(ref directoriesSearched), Volatile.Read(ref appHostsFound))); 239update(FormatSearchingStatus(Volatile.Read(ref directoriesSearched), Volatile.Read(ref appHostsFound)));
Commands\TerminalTapePlayCommand.cs (1)
215catch (OperationCanceledException) when (Volatile.Read(ref disconnected) != 0)
ConsoleCancellationManager.cs (3)
100internal void SetStartedHandler(Task handler) => Volatile.Write(ref _startedHandler, handler); 106internal void SetLogger(ILogger logger) => Volatile.Write(ref _logger, logger); 342var startedHandler = Volatile.Read(ref _startedHandler);
DotNet\ProcessExecution.cs (7)
89Volatile.Read(ref _process) 120Volatile.Write(ref _process, process); 125Volatile.Write(ref _lifecycleState, (int)LifecycleState.Started); 129Volatile.Write(ref _lifecycleState, (int)LifecycleState.Disposed); 130if (ReferenceEquals(Volatile.Read(ref _process), process)) 132Volatile.Write(ref _process, null); 482switch ((LifecycleState)Volatile.Read(ref _lifecycleState))
Processes\IsolatedProcess.cs (4)
228return (LifecycleState)Volatile.Read(ref _lifecycleState) switch 259switch ((LifecycleState)Volatile.Read(ref _lifecycleState)) 339Volatile.Write(ref _lifecycleState, (int)LifecycleState.Started); 344Volatile.Write(ref _lifecycleState, (int)LifecycleState.Disposed);
Telemetry\AspireCliTelemetry.cs (1)
240var completionTask = Volatile.Read(ref _internalMicrosoftDiagnosticsCompletionTask);
Telemetry\InternalMicrosoftDetector.cs (1)
317stageDeadlineTimestamp = Math.Min(stageDeadlineTimestamp, Volatile.Read(ref stageTimeoutTimestamp));
Tui\TerminalViewerApp.cs (2)
308if (_embeddedFault is not null && Volatile.Read(ref _userDetachRequested) == 0) 599Volatile.Write(ref _resizeInFlight, 0);
Aspire.Cli.Tests (5)
Commands\AppHostLauncherTests.cs (2)
1717public int WaitForExitCallCount => Volatile.Read(ref _waitForExitCallCount); 1719public int WaitForExitWithCancelableTokenCount => Volatile.Read(ref _waitForExitWithCancelableTokenCount);
Commands\TerminalTapePlayCommandTests.cs (1)
199Assert.Equal(2, Volatile.Read(ref requests));
TestServices\TestAppHostAuxiliaryBackchannel.cs (2)
83public int GetResourceSnapshotsCallCount => Volatile.Read(ref _getResourceSnapshotsCallCount); 88public bool? LastGetResourceSnapshotsIncludeHidden => Volatile.Read(ref _lastGetResourceSnapshotsIncludeHidden) switch
Aspire.Dashboard (15)
Components\Controls\Chart\ChartContainer.razor.cs (2)
132var lastDataFetchTimestamp = Volatile.Read(ref _lastDataFetchTimestamp); 333Volatile.Write(ref _lastDataFetchTimestamp, TimeProvider.GetTimestamp());
Components\Dialogs\FilterDialog.razor.cs (2)
222if (updateVersion != Volatile.Read(ref _fieldValuesUpdateVersion)) 257if (updateVersion != Volatile.Read(ref _fieldValuesUpdateVersion))
Components\Dialogs\GenAIVisualizerDialog.razor.cs (1)
266if (updateVersion != Volatile.Read(ref _contentUpdateVersion))
Components\Pages\TraceDetail.razor.cs (2)
318if (updateVersion != Volatile.Read(ref _detailViewUpdateVersion)) 328if (updateVersion != Volatile.Read(ref _detailViewUpdateVersion))
Model\DimensionFilterViewModel.cs (1)
21public IReadOnlySet<DimensionValueViewModel> SelectedValues => Volatile.Read(ref _selectedValues);
ServiceClient\GrpcTerminalClientStream.cs (2)
33public bool TerminalEnded => Volatile.Read(ref _terminalEnded); 107Volatile.Write(ref _terminalEnded, true);
ServiceClient\SqliteResourceRepository.cs (1)
521private void ThrowIfDisposed() => ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this);
Terminal\TerminalViewSessionRegistry.cs (4)
92get => Volatile.Read(ref _disposed) != 0 || _ended.Task.IsCompleted || Volatile.Read(ref _readOnly) != 0; 93set => Volatile.Write(ref _readOnly, value ? 1 : 0); 103if (Volatile.Read(ref _disposed) != 0)
Aspire.Dashboard.Components.Tests (9)
Interactions\InteractionsProviderTests.cs (2)
124Assert.Equal(1, Volatile.Read(ref liveSubscriptionCount)); 125Assert.Equal(0, Volatile.Read(ref selectedSubscriptionCount));
Pages\ConsoleLogsTests.cs (1)
397Assert.Equal(0, Volatile.Read(ref repositorySubscriptionCount));
Pages\MetricsTests.cs (2)
344var activityCountAfterDispose = Volatile.Read(ref tickActivityCount); 347Assert.Equal(activityCountAfterDispose, Volatile.Read(ref tickActivityCount));
Shared\TestJSObjectReference.cs (1)
16public int DisposeCount => Volatile.Read(ref _disposeCount);
tests\Shared\TestDashboardClient.cs (3)
44public int TerminalSubscriptionCount => Volatile.Read(ref _terminalSubscriptionCount); 45public int ActiveTerminalSubscriptionCount => Volatile.Read(ref _activeTerminalSubscriptionCount); 46public int ResourceSubscriptionCount => Volatile.Read(ref _resourceSubscriptionCount);
Aspire.Dashboard.Tests (17)
Integration\Playwright\TerminalDockTests.cs (4)
388terminalChannelProvider: () => Volatile.Read(ref _updates), 390closeTerminal: (id, token) => Volatile.Read(ref _closes).Writer.WriteAsync(id, token).AsTask()); 398Volatile.Write(ref _updates, updates); 399Volatile.Write(ref _closes, closes);
Model\DashboardClientTests.cs (3)
947Assert.Equal(1, Volatile.Read(ref subscriptions)); 961Assert.Equal(2, Volatile.Read(ref subscriptions)); 1041Assert.Equal(1, Volatile.Read(ref subscriptions));
Shared\TerminalTestHost.cs (7)
55public int DisposedAttachments => Volatile.Read(ref _disposedAttachments); 69Volatile.Write(ref _includeHmpExit, includeHmpExit ? 1 : 0); 70Volatile.Write(ref _terminalEnded, 1); 134var connection = failure is not null || Volatile.Read(ref _terminalEnded) != 0 141new TerminalResponseReader(connection, () => Volatile.Read(ref _terminalEnded) != 0, 142() => Volatile.Read(ref _includeHmpExit) != 0, _endedObserved, failure), 266ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this);
tests\Shared\TestDashboardClient.cs (3)
44public int TerminalSubscriptionCount => Volatile.Read(ref _terminalSubscriptionCount); 45public int ActiveTerminalSubscriptionCount => Volatile.Read(ref _activeTerminalSubscriptionCount); 46public int ResourceSubscriptionCount => Volatile.Read(ref _resourceSubscriptionCount);
Aspire.Hosting (3)
Dcp\KubernetesService.cs (2)
494var retryDuration = Volatile.Read(ref _kubernetesApiReady) 509Volatile.Write(ref _kubernetesApiReady, true);
Publishing\ResourceContainerImageManager.cs (1)
654var crossOsDiagnosticPresent = Volatile.Read(ref crossOsAotDiagnosticSeen) != 0 ||
Aspire.Hosting.Azure.Tests (9)
AzureBicepProvisionerTests.cs (2)
676Assert.Equal(2, Volatile.Read(ref maxConcurrentLookups)); 682var observed = Volatile.Read(ref maxConcurrentLookups);
AzureEnvironmentResourceExtensionsTests.cs (5)
5722public int GetOrCreateResourceCallCount => Volatile.Read(ref _getOrCreateResourceCallCount); 5767public bool ParentStartedBeforeChildCompleted => Volatile.Read(ref _parentStartedBeforeChildCompleted) == 1; 5793Volatile.Write(ref _childCompleted, 1); 5798Volatile.Read(ref _childCompleted) == 0) 5800Volatile.Write(ref _parentStartedBeforeChildCompleted, 1);
DefaultArmClientProviderTests.cs (2)
395public int MaxConcurrentNestedDeploymentOperationRequests => Volatile.Read(ref _maxConcurrentNestedDeploymentOperationRequests); 586var observed = Volatile.Read(ref _maxConcurrentNestedDeploymentOperationRequests);
Aspire.Hosting.Blazor (1)
BrowserDebuggerHelper.cs (1)
189if (Volatile.Read(ref debugSessionGeneration) == currentGeneration)
Aspire.Hosting.Browsers (11)
BrowserHostRegistry.cs (4)
54ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this); 76ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this); 160if (Volatile.Read(ref _disposed) != 0) 175if (Volatile.Read(ref _disposed) != 0)
BrowserLogsCdpConnectionMultiplexer.cs (3)
38ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this); 46ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this); 203ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this);
BrowserLogsSessionManager.cs (3)
180ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposing) != 0, this); 248ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposing) != 0, this); 322if (Volatile.Read(ref _disposing) != 0)
BrowserPageSession.cs (1)
83ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this);
Aspire.Hosting.Browsers.Tests (11)
src\Aspire.Hosting.Browsers\BrowserHostRegistry.cs (4)
54ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this); 76ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this); 160if (Volatile.Read(ref _disposed) != 0) 175if (Volatile.Read(ref _disposed) != 0)
src\Aspire.Hosting.Browsers\BrowserLogsCdpConnectionMultiplexer.cs (3)
38ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this); 46ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this); 203ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this);
src\Aspire.Hosting.Browsers\BrowserLogsSessionManager.cs (3)
180ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposing) != 0, this); 248ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposing) != 0, this); 322if (Volatile.Read(ref _disposing) != 0)
src\Aspire.Hosting.Browsers\BrowserPageSession.cs (1)
83ObjectDisposedException.ThrowIf(Volatile.Read(ref _disposed) != 0, this);
Aspire.Hosting.Dotnet (4)
DotnetProjectMetadata.cs (4)
29Volatile.Read(ref _buildEnvironment); 32Volatile.Read(ref _buildWorkingDirectory); 57Volatile.Write(ref _buildEnvironment, new ReadOnlyDictionary<string, string>(snapshot)); 62Volatile.Write(ref _buildWorkingDirectory, workingDirectory);
Aspire.Hosting.Dotnet.Tests (3)
DotnetProjectBuildCoordinatorTests.cs (3)
3165Assert.Equal(0, Volatile.Read(ref resolverCallCount)); 3170Assert.Equal(1, Volatile.Read(ref resolverCallCount)); 3271Assert.Equal(1, Volatile.Read(ref applicationStoppedAccessCount));
Aspire.Hosting.Maui (2)
Annotations\OtlpDevTunnelConfigurationAnnotation.cs (2)
43public bool IsOtlpEndpointResolved => Volatile.Read(ref _isOtlpEndpointResolved) != 0; 82Volatile.Write(ref _isOtlpEndpointResolved, 1);
Aspire.Hosting.Tests (33)
Dcp\DcpExecutorTests.cs (22)
2022Assert.Equal(1, Volatile.Read(ref failedToStartFollowStreamCount)); 2191() => Volatile.Read(ref blockingTerminalNotifications) >= 2, 2194Assert.Equal(2, Volatile.Read(ref blockingTerminalNotifications)); 2197Assert.Equal(3, Volatile.Read(ref blockingTerminalFollowStreamCount)); 2278Assert.Equal(2, Volatile.Read(ref terminalStdErrFollowStreamCount)); 2446Assert.Equal(2, Volatile.Read(ref stdoutFollowStreamCount)); 2555() => Volatile.Read(ref terminalNotifications) >= 1, 2562() => Volatile.Read(ref runningNotifications) >= 2, 2580() => Volatile.Read(ref terminalNotifications) >= 2, 2594Assert.Equal(2, Volatile.Read(ref terminalFlushes)); 2711() => Volatile.Read(ref terminalNotifications) >= 1, 2718() => Volatile.Read(ref runningNotifications) >= 2, 2745Assert.Equal(1, Volatile.Read(ref terminalFlushes)); 3156() => Volatile.Read(ref terminalNotifications) >= 1, 3173() => Volatile.Read(ref terminalNotifications) >= 2, 3191Assert.Equal(2, Volatile.Read(ref replacementStdErrFollowStreams)); 3302flushesAtNotification.Enqueue(Volatile.Read(ref flushStreamOpens)); 3382flushesAtNotification.Enqueue(Volatile.Read(ref flushStreamOpens)); 3421() => Volatile.Read(ref runningNotifications) >= 2, 5132Assert.Equal(1, Volatile.Read(ref environmentCallbackInvocationCount)); 6971Assert.Equal(1, Volatile.Read(ref producerInvocationCount)); 7115Assert.Equal(1, Volatile.Read(ref producerInvocationCount));
Dcp\KubernetesServiceTests.cs (6)
413Volatile.Write( 415Volatile.Read(ref _responseState.RequestCount) + count + 1); 426Volatile.Write(ref _responseState.BlockWatchResponses, true); 436while (Volatile.Read(ref _responseState.WatchRequestCount) < expectedCount) 468if (isWatchRequest && Volatile.Read(ref responseState.BlockWatchResponses)) 497if (Interlocked.Increment(ref responseState.RequestCount) < Volatile.Read(ref responseState.SuccessfulRequestNumber))
DotnetProgramPublishingTests.cs (1)
374CheckIfRunningAsyncCallback = _ => Task.FromResult(Volatile.Read(ref running) != 0)
Publishing\ContainerRuntimeReadinessTests.cs (4)
53CheckIfRunningAsyncCallback = _ => Task.FromResult(Volatile.Read(ref running) != 0) 83CheckIfRunningAsyncCallback = _ => Task.FromResult(Volatile.Read(ref running) != 0) 107CheckIfRunningAsyncCallback = _ => Task.FromResult(Volatile.Read(ref running) != 0) 127CheckIfRunningAsyncCallback = _ => Task.FromResult(Volatile.Read(ref running) != 0)
Aspire.Hosting.TestUtilities (2)
Publishing\FakeContainerRuntime.cs (2)
21public int CheckIfRunningCallCount => Volatile.Read(ref _checkIfRunningCallCount); 22public int ResolveAsyncCallCount => Volatile.Read(ref _resolveAsyncCallCount);
dotnet-aot (12)
parent\dotnet\Commands\Test\MTP\CtrlCCancellationManager.cs (1)
70if (Volatile.Read(ref _state) == StateForcing)
parent\dotnet\Commands\Test\MTP\TestApplication.cs (9)
124Volatile.Write(ref _standardOutputCollector, stdOutBuilder); 125Volatile.Write(ref _standardErrorCollector, stdErrBuilder); 270Volatile.Write(ref _standardOutputCollector, null); 271Volatile.Write(ref _standardErrorCollector, null); 673if (Volatile.Read(ref _sessionCancellationRequested) != 0) 881Volatile.Write(ref _protocolNegotiated, 1); 886Volatile.Read(ref _protocolNegotiated) == 0 ? null : IsProtocol_1_1_OrHigher; 910Volatile.Read(ref _standardOutputCollector)?.FlushBufferedOutputIfLiveStreamingEnabled(liveOutputStreamingState); 911Volatile.Read(ref _standardErrorCollector)?.FlushBufferedOutputIfLiveStreamingEnabled(liveOutputStreamingState);
parent\dotnet\Commands\Test\MTP\TestRunPolicy.cs (2)
69int reason = Volatile.Read(ref _reason); 76public int FailedTests => Volatile.Read(ref _failedTests);
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 (3)
Compiler\ReadyToRunCodegenCompilation.cs (2)
892return Volatile.Read(ref _compilationSessionGeneratedColdCode) != 0; 955Volatile.Write(ref _compilationSessionGeneratedColdCode, 1);
Compiler\ReadyToRunCompilationModuleGroupBase.cs (1)
795Volatile.Write(ref _typeRefsInCompilationModuleSet, typeRefsInCompilationModuleSet);
ILCompiler.TypeSystem (10)
parent\parent\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); 352existingCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 377existingCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 411Volatile.Write(ref _cacheableKeyRing, existingCacheableKeyRing.WithTemporaryExtendedLifetime(utcNow)); 424Volatile.Write(ref _cacheableKeyRing, newCacheableKeyRing); 489Volatile.Write(ref _cacheableKeyRing, newCacheableKeyRing); 494var existingCacheableKeyRing = Volatile.Read(ref _cacheableKeyRing); 499Volatile.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)
2638Volatile.Write(ref _nextActivationSendPing, (DateTime.UtcNow + _hubConnection.KeepAliveInterval).Ticks); 2643Volatile.Write(ref _nextActivationServerTimeout, (DateTime.UtcNow + _hubConnection.ServerTimeout).Ticks); 2654if (DateTime.UtcNow.Ticks > Volatile.Read(ref _nextActivationServerTimeout)) 2659if (DateTime.UtcNow.Ticks > Volatile.Read(ref _nextActivationSendPing) && !Stopping)
Microsoft.AspNetCore.SignalR.Core (6)
HubConnectionContext.cs (6)
120var hubCallerContext = Volatile.Read(ref _hubCallerContext); 179get => Volatile.Read(ref _userIdentifier); 182Volatile.Write(ref _userIdentifier, value); 221Volatile.Write(ref _userIdentifier, userIdentifier); 787var elapsed = _timeProvider.GetElapsedTime(Volatile.Read(ref _lastSendTick), currentTime); 805Volatile.Write(ref _lastSendTick, currentTime);
Microsoft.Build (18)
BackEnd\BuildManager\CoordinatorClient.HeartbeatTimer.cs (2)
27private bool IsDisposingOrDisposed => Volatile.Read(ref _disposeState) != NotDisposed; 57Volatile.Write(ref _disposeState, Disposed);
BackEnd\BuildManager\MultiThreadedStrictModeScope.cs (3)
45internal static MultiThreadedStrictModeScope? ActiveScope => Volatile.Read(ref s_activeScope); 92Volatile.Write(ref s_activeScope, scope); 145Volatile.Write(ref s_activeScope, null);
BackEnd\Components\Communications\NodeProviderOutOfProcBase.cs (1)
1363if (Volatile.Read(ref _closed) != 0)
BackEnd\Components\RequestBuilder\RequestBuilder.cs (1)
1618var count = Volatile.Read(ref _availableThreads);
BuildCheck\Infrastructure\BuildCheckCentralContext.cs (4)
69internal bool HasActions => Volatile.Read(ref _callbacks).Length > 0; 71internal (CheckWrapper, Action<BuildCheckDataContext<T>>)[] Snapshot => Volatile.Read(ref _callbacks); 80Volatile.Write(ref _callbacks, callbacks); 91Volatile.Write(ref _callbacks, callbacks.Where(callback => callback.Item1 != check).ToArray());
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 (7)
AssemblyReferenceConflictEventArgs.cs (4)
487AssemblyConflictMessageFormatter.LocalizedMessage? localizedMessage = Volatile.Read(ref _localizedMessage); 494Volatile.Write(ref _localizedMessage, new(culture, message)); 617AssemblyConflictMessageFormatter.LocalizedMessage? localizedMessage = Volatile.Read(ref _localizedMessage); 625Volatile.Write(ref _localizedMessage, new(culture, message));
AssemblyResolutionSearchTraceEventArgs.cs (2)
298LocalizedMessage? localizedMessage = Volatile.Read(ref _localizedMessage); 305Volatile.Write(ref _localizedMessage, new LocalizedMessage(culture, message));
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); 557var 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)
1715if (Volatile.Read(ref _lazyMembersDictionary) is Dictionary<ReadOnlyMemory<char>, ImmutableArray<Symbol>> result) 1828RoslynDebug.AssertOrFailFast(Volatile.Read(ref _lazyTypeMembers)?.Values.Any(types => types.Contains(t => t == (object)type)) == true); 1852var membersAndInitializers = Volatile.Read(ref _lazyMembersAndInitializers); 1867var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 1880membersAndInitializers = Volatile.Read(ref _lazyMembersAndInitializers); 3671if (Volatile.Read(ref _lazyMembersAndInitializers) != null) 3688if (Volatile.Read(ref _lazyMembersAndInitializers) is not null) 3741if (Volatile.Read(ref _lazyDeclaredMembersAndInitializers) != DeclaredMembersAndInitializers.UninitializedSentinel) 3862var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 3883var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 3930var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers); 3957var declared = Volatile.Read(ref _lazyDeclaredMembersAndInitializers);
Symbols\Source\SourceMemberFieldSymbol.cs (1)
662return _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)
24private const string VolatileReadMethodName = nameof(Volatile.Read); 25private 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)
155return Volatile.Read(ref _latestSolution); 476var oldSolution = Volatile.Read(ref _latestSolution);
Microsoft.DotNet.Cli.Utils (1)
TypeInfo.cs (1)
30int value = Volatile.Read(ref s_hasReferences);
Microsoft.DotNet.HotReload.Watch (3)
src\sdk\src\Dotnet.Watch\AspireService\Helpers\ImmutableInterlockedExtensions.cs (1)
18T oldValue = Volatile.Read(ref location);
src\sdk\src\Dotnet.Watch\HotReloadClient\Web\AbstractBrowserRefreshServer.cs (2)
142=> Volatile.Write(ref _sessionKeyFactory, value); 243sessionKey = Volatile.Read(ref _sessionKeyFactory)();
Microsoft.Extensions.AI.OpenAI (2)
OpenAIRequestPolicies.cs (2)
68var current = Volatile.Read(ref _entries); 87var snapshot = Volatile.Read(ref _entries);
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)); 232Assert.Equal(0, Volatile.Read(ref executeCount)); 241Assert.Equal(1, Volatile.Read(ref executeCount)); 242Assert.Equal(1, Volatile.Read(ref cancelCount)); 319Assert.Equal(0, Volatile.Read(ref executeCount)); 328Assert.Equal(1, Volatile.Read(ref executeCount)); 329Assert.Equal(0, Volatile.Read(ref cancelCount)); // ran to completion
Microsoft.Extensions.Caching.Memory (14)
CacheEntry.cs (2)
198Volatile.Write(ref _isDisposed, true); 339if (_cache.TrackLinkedCacheEntries && Volatile.Read(ref _isDisposed))
CacheEntry.ExpirationTokensList.cs (7)
44return new ReadOnlySpan<IChangeToken>(state._items, 0, Volatile.Read(ref state._count)); 53return Volatile.Read(ref state._count); 64return (uint)index >= (uint)Volatile.Read(ref state._count) 225return Array.IndexOf(state._items, item, 0, Volatile.Read(ref state._count)); 231Array.Copy(state._items, 0, array, arrayIndex, Volatile.Read(ref state._count)); 238int count = Volatile.Read(ref state._count); 285Volatile.Write(ref state._count, count);
MemoryCache.cs (5)
454hits += Volatile.Read(ref stats.Hits); 455misses += Volatile.Read(ref stats.Misses); 497_accumulatedHits += Volatile.Read(ref current.Hits); 498_accumulatedMisses += Volatile.Read(ref current.Misses); 870internal 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)
616Volatile.Read(ref _subdirectoryRequiringTokenCount) == 0) 663Volatile.Read(ref _subdirectoryRequiringTokenCount) > 0;
Microsoft.Extensions.Hosting (1)
Internal\Host.cs (1)
406List<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)
82if (Volatile.Read(ref foundLibraryImportMethod) != 0 && !unsafeEnabled)
Microsoft.Interop.LibraryImportGenerator.Downlevel (1)
DownlevelLibraryImportDiagnosticsAnalyzer.cs (1)
76if (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);
Microsoft.NET.ProjectData (4)
Donor\ProjectDataDonorIndex.Git.cs (4)
221 public bool WasCancelled => Volatile.Read(ref this.wasCancelled); 223 public bool TimedOut => Volatile.Read(ref this.timedOut); 238 Volatile.Write(ref this.wasCancelled, true); 253 Volatile.Write(ref this.timedOut, true);
Microsoft.Private.Windows.Core (1)
Windows\Win32\System\Com\AgileComPointer.cs (1)
41public bool IsDisposed => Volatile.Read(ref _cookie) == 0;
Microsoft.TestPlatform.CommunicationUtilities (1)
SocketServer.cs (1)
138catch (Exception ex) when (Volatile.Read(ref _stopRequested) != 0 && ex is ObjectDisposedException or SocketException or InvalidOperationException)
Microsoft.VisualStudio.TestPlatform.Extensions.Trx.TestLogger (3)
TrxLogger.cs (3)
220/// The test run. Read from multiple threads, so accesses go through <see cref="Volatile"/> to 226get => Volatile.Read(ref _loggerTestRun); 227private set => Volatile.Write(ref _loggerTestRun, value);
MSBuild.Coordinator (1)
CoordinatorServer.cs (1)
36private bool HasActiveConnections => Volatile.Read(ref _activeConnections) > 0;
mscorlib (1)
parent\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)
88return Volatile.Read(ref s_stdInReader) ?? EnsureInitialized(); 991int cursorVersion = mayChangeCursorPosition ? Volatile.Read(ref s_cursorVersion) : -1; 1114Volatile.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)
462long ticksPerSecond = Volatile.Read(ref s_ticksPerSecond); 473Volatile.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.Pipelines (1)
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.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)
381if (Volatile.Read(ref _http11RequestQueueIsEmptyAndNotDisposed)) 397if (!Volatile.Read(ref _http11RequestQueueIsEmptyAndNotDisposed))
System\Net\Http\SocketsHttpHandler\ConnectionPool\HttpConnectionPool.Http2.cs (1)
346Volatile.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)
461Volatile.Write(ref _sendLocked, 0); 468exception = Volatile.Read(ref _sendException); 537Volatile.Write(ref _sendLocked, 0); 608Volatile.Write(ref _receivedNeedsEnable, 1); 620Volatile.Write(ref _sendLocked, 0); 623Exception? 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 831QueueState state = (QueueState)Volatile.Read(ref Unsafe.As<QueueState, int>(ref _state)); 832observedSequenceNumber = Volatile.Read(ref _sequenceNumber); 1313Volatile.Write(ref _asyncEngine, engine);
System\Net\Sockets\TCPClient.cs (1)
279Socket chkClientSocket = Volatile.Read(ref _clientSocket);
System.Private.CoreLib (193)
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);
parent\parent\Runtime.Base\src\System\Runtime\CachedInterfaceDispatch.cs (1)
98Volatile.Write(ref pDispatchCell->MethodTable, (nint)pInstanceType);
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\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)
118int currentHead = Volatile.Read(ref _headAndTail.Head); 122int sequenceNumber = Volatile.Read(ref slots[slotsIndex].SequenceNumber); 142if (!Volatile.Read(ref _preservedForObservation)) 151Volatile.Write(ref slots[slotsIndex].SequenceNumber, currentHead + slots.Length); 168bool frozen = Volatile.Read(ref _frozenForEnqueues); 214int currentHead = Volatile.Read(ref _headAndTail.Head); 218int sequenceNumber = Volatile.Read(ref slots[slotsIndex].SequenceNumber); 237bool frozen = Volatile.Read(ref _frozenForEnqueues); 276int currentTail = Volatile.Read(ref _headAndTail.Tail); 280int sequenceNumber = Volatile.Read(ref slots[slotsIndex].SequenceNumber); 300Volatile.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)
126Debug.Assert(Volatile.Read(ref m_sessionID) == 0); 127Volatile.Write(ref m_sessionID, sessionID); 142ulong sessionID = Volatile.Read(ref m_sessionID); 146Volatile.Write(ref m_sessionID, 0);
src\runtime\src\libraries\System.Private.CoreLib\src\System\Diagnostics\Tracing\EventPipeEventDispatcher.Threads.cs (1)
47while (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 (5)
169uint version = Volatile.Read(ref pEntry._version); 170nuint entrySource = Volatile.Read(ref pEntry._source); 179nuint entryTargetAndResult = Volatile.Read(ref pEntry._targetAndResult); 319Volatile.Write(ref pEntry._version, newVersion + 1); 380Volatile.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)
164uint version = Volatile.Read(ref pEntry.Version); 177Volatile.ReadBarrier(); 311Volatile.Write(ref pEntry.Version, newVersion + 1); 373Volatile.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)
266workerThreads = Volatile.Read(ref _minThreads); 327workerThreads = Volatile.Read(ref _maxThreads); 435Volatile.Write(ref _separated.priorCompletedWorkRequestsTime, currentTicks); 461int 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)
247Volatile.Write(ref m_array[i & m_mask], null); 290object? obj = Volatile.Read(ref m_array[idx]); 310object? obj = Volatile.Read(ref m_array[idx]); 355object? 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.Private.Windows.Core (1)
Windows\Win32\System\Com\AgileComPointer.cs (1)
41public bool IsDisposed => Volatile.Read(ref _cookie) == 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)
85int i = Volatile.Read(ref _buckets[bucket]); 116Volatile.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)
166Func<ICustomAttributeProvider>? attributeProviderFactory = Volatile.Read(ref AttributeProviderFactory); 172Volatile.Write(ref AttributeProviderFactory, null); 182Volatile.Write(ref AttributeProviderFactory, null);
System\Text\Json\Serialization\Metadata\JsonTypeInfo.cs (4)
883Func<ICustomAttributeProvider>? ctorAttrProviderFactory = Volatile.Read(ref ConstructorAttributeProviderFactory); 889Volatile.Write(ref ConstructorAttributeProviderFactory, null); 899Volatile.Write(ref ConstructorAttributeProviderFactory, null); 1087JsonTypeClassifierFactory? 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)
143internal bool IsCompleted => ReferenceEquals(Volatile.Read(ref _continuation), s_completedSentinel); 210if (Volatile.Read(ref _continuation) is not null || 486Volatile.Write(ref _continuation, s_availableSentinel); 542Volatile.Write(ref _continuation, s_availableSentinel);
System.Threading.RateLimiting (7)
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\RateLimiting\SlidingWindowRateLimiter.cs (1)
364Volatile.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)));
System.Windows.Forms (4)
System\Windows\Forms\Rendering\Animation\AnimationManager.cs (1)
138if (Volatile.Read(ref _disposed) != 0)
System\Windows\Forms\SystemVisualSettingsTracker.cs (3)
25=> Volatile.Read(ref s_currentSettings); 41SystemVisualSettings next = Volatile.Read(ref s_snapshotProvider).Invoke(); 123Volatile.Write(ref s_snapshotProvider, snapshotProvider ?? GetNativeSnapshot);
System.Windows.Forms.Primitives (18)
System\Windows\Forms\Animation\HighPrecisionTimer.cs (18)
51=> 1000.0 / Volatile.Read(ref s_effectiveFramesPerSecond); 59get => Volatile.Read(ref s_requestedFramesPerSecond); 86=> Volatile.Read(ref s_highResolutionAvailable) != 0; 144Volatile.Write(ref registration.IsActive, 0); 169Volatile.Write(ref s_effectiveFramesPerSecond, framesPerSecond); 170Volatile.Write(ref s_highResolutionAvailable, waitableTimer is null ? 0 : 1); 178Volatile.Write(ref s_highResolutionAvailable, 0); 259Volatile.Write(ref s_highResolutionAvailable, 0); 381if (!ReferenceEquals(Volatile.Read(ref s_loopState), state)) 386Registration[] registrations = Volatile.Read(ref s_registrationSnapshot); 390if (Volatile.Read(ref registration.IsActive) == 0) 438|| Volatile.Read(ref registration.IsActive) == 0 439|| !ReferenceEquals(Volatile.Read(ref s_loopState), state)) 600LoopState? state = Volatile.Read(ref s_loopState); 669Volatile.Write(ref registration.IsActive, 0); 673Volatile.Write(ref s_registrationSnapshot, []); 675Volatile.Write(ref s_effectiveFramesPerSecond, MaximumFramesPerSecond); 684Volatile.Write(ref s_registrationSnapshot, registrations);
System.Xaml (2)
System\Xaml\Schema\TypeBits.cs (2)
78object value = Volatile.Read(ref _value); 102Volatile.Write(ref _value, newValue);