2601 references to Interlocked
AnalyzerRunner (1)
Aspire.Dashboard (8)
Aspire.Hosting.Analyzers (1)
Aspire.Hosting.Tests (13)
Aspire.Microsoft.Data.SqlClient (2)
Aspire.Microsoft.EntityFrameworkCore.SqlServer (2)
BasicWebSite (2)
Binding.ReliableSession.IntegrationTests (6)
Client.ChannelLayer.IntegrationTests (2)
Client.ExpectedExceptions.IntegrationTests (4)
ClientSample (2)
dotnet-svcutil-lib (68)
FrameworkFork\System.ServiceModel\System\ServiceModel\Channels\WebSocketTransportDuplexSessionChannel.cs (7)
330if (Interlocked.CompareExchange(ref _cleanupStatus, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted)
510if (Interlocked.CompareExchange(ref _asyncReceiveState, AsyncReceiveState.Cancelled, AsyncReceiveState.Started) == AsyncReceiveState.Started)
725int currentState = Interlocked.CompareExchange(ref _asyncReceiveState, AsyncReceiveState.Started, AsyncReceiveState.Finished);
806if (Interlocked.CompareExchange(ref _asyncReceiveState, AsyncReceiveState.Finished, AsyncReceiveState.Started) == AsyncReceiveState.Started)
1181if (Interlocked.CompareExchange(ref _endOfMessageWritten, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted)
1259if (Interlocked.CompareExchange(ref _messageSourceCleanState, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted)
1301if (Interlocked.CompareExchange(ref _endOfMessageWritten, WebSocketHelper.OperationFinished, WebSocketHelper.OperationNotStarted) == WebSocketHelper.OperationNotStarted)
HttpStress (3)
InMemory.FunctionalTests (3)
InProcessWebSite (4)
Interop.FunctionalTests (5)
Microsoft.AspNetCore.App.Analyzers (1)
Microsoft.AspNetCore.Components (1)
Microsoft.AspNetCore.Components.Endpoints (1)
Microsoft.AspNetCore.Components.Server (1)
Microsoft.AspNetCore.Components.Tests (2)
Microsoft.AspNetCore.Components.WebAssembly (2)
Microsoft.AspNetCore.ConcurrencyLimiter (3)
Microsoft.AspNetCore.ConcurrencyLimiter.Microbenchmarks (2)
Microsoft.AspNetCore.ConcurrencyLimiter.Tests (2)
Microsoft.AspNetCore.Cryptography.Internal (2)
Microsoft.AspNetCore.DataProtection (2)
Microsoft.AspNetCore.DataProtection.Extensions (1)
Microsoft.AspNetCore.HeaderParsing (1)
Microsoft.AspNetCore.Hosting (4)
Microsoft.AspNetCore.Hosting.Tests (1)
Microsoft.AspNetCore.Http (4)
Microsoft.AspNetCore.Http.Connections (5)
Microsoft.AspNetCore.Http.RequestDelegateGenerator (1)
Microsoft.AspNetCore.Mvc (1)
Microsoft.AspNetCore.Mvc.Core (2)
Microsoft.AspNetCore.Mvc.RazorPages (1)
Microsoft.AspNetCore.OutputCaching.StackExchangeRedis (2)
Microsoft.AspNetCore.ResponseCaching (1)
Microsoft.AspNetCore.Routing (1)
Microsoft.AspNetCore.Routing.Tests (2)
Microsoft.AspNetCore.Server.HttpSys (10)
Microsoft.AspNetCore.Server.HttpSys.FunctionalTests (2)
Microsoft.AspNetCore.Server.IIS (6)
Microsoft.AspNetCore.Server.Kestrel.Core (51)
Microsoft.AspNetCore.Server.Kestrel.Core.Tests (1)
Microsoft.AspNetCore.Server.Kestrel.Microbenchmarks (4)
Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes (2)
Microsoft.AspNetCore.Server.Kestrel.Transport.Quic (1)
Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets (9)
Microsoft.AspNetCore.Shared.Tests (1)
Microsoft.AspNetCore.SignalR.Client.Core (3)
Microsoft.AspNetCore.SignalR.Client.Tests (1)
Microsoft.AspNetCore.SignalR.Core (2)
Microsoft.AspNetCore.SignalR.Specification.Tests (1)
Microsoft.AspNetCore.SignalR.StackExchangeRedis (1)
Microsoft.AspNetCore.SignalR.StackExchangeRedis.Tests (1)
Microsoft.AspNetCore.SignalR.Tests.Utils (1)
Microsoft.Build (33)
Microsoft.Build.Engine.OM.UnitTests (9)
Microsoft.Build.Engine.UnitTests (3)
Microsoft.Build.Framework (8)
Microsoft.Build.Tasks.Core (3)
Microsoft.Build.Tasks.UnitTests (1)
Microsoft.Build.UnitTests.Shared (1)
Microsoft.CodeAnalysis (87)
Emit\CommonPEModuleBuilder.cs (7)
822Interlocked.CompareExchange(ref NestedTypes, new ConcurrentQueue<Cci.INestedTypeDefinition>(), null);
914Interlocked.CompareExchange(ref defs.Methods, new ConcurrentQueue<Cci.IMethodDefinition>(), null);
927Interlocked.CompareExchange(ref defs.Properties, new ConcurrentQueue<Cci.IPropertyDefinition>(), null);
940Interlocked.CompareExchange(ref defs.Fields, new ConcurrentQueue<Cci.IFieldDefinition>(), null);
959Interlocked.CompareExchange(ref _lazySynthesizedNamespaceMembers, new ConcurrentDictionary<INamespaceSymbolInternal, ConcurrentQueue<INamespaceOrTypeSymbolInternal>>(), null);
1059if (Interlocked.CompareExchange(ref _lazyArrayMethods, result, null) != null)
1093if (Interlocked.CompareExchange(ref _lazyPrivateImplementationDetails, result, null) != null)
InternalUtilities\InterlockedOperations.cs (6)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue);
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Syntax\SyntaxNode.cs (7)
145Interlocked.CompareExchange(ref field, green.CreateRed(this, this.GetChildPosition(slot)), null);
163Interlocked.CompareExchange(ref field, green.CreateRed(this, this.Position), null);
180Interlocked.CompareExchange(ref field, (T)green.CreateRed(this, this.GetChildPosition(slot)), null);
198Interlocked.CompareExchange(ref field, (T)green.CreateRed(this, this.Position), null);
221Interlocked.CompareExchange(ref element, green.CreateRed(this.Parent, this.GetChildPosition(slot)), null);
243Interlocked.CompareExchange(ref element, green.CreateRed(this.Parent, this.GetChildPosition(1)), null);
278if (Interlocked.CompareExchange(ref slot, newWeakReference, previousWeakReference) == previousWeakReference)
Microsoft.CodeAnalysis.CodeStyle (27)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (6)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue);
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.CodeStyle.Fixes (1)
Microsoft.CodeAnalysis.Collections.Package (8)
Microsoft.CodeAnalysis.CSharp (228)
Compilation\CSharpCompilation.cs (11)
87Interlocked.CompareExchange(ref _conversions, new BuckStopsHereBinder(this, associatedFileIdentifier: null).Conversions, null);
1429Interlocked.CompareExchange(ref _lazyGlobalNamespace, result, null);
1495Interlocked.CompareExchange(ref _externAliasTargets, new ConcurrentDictionary<string, NamespaceSymbol>(), null);
1540Interlocked.CompareExchange(ref _lazyScriptClass, BindScriptClass()!, ErrorTypeSymbol.UnknownResultType);
1805Interlocked.CompareExchange(ref _lazyHostObjectTypeSymbol, symbol, null);
1913Interlocked.CompareExchange(ref _lazyEntryPoint, entryPoint, null);
2570binderFactories = Interlocked.CompareExchange(ref cachedBinderFactories, binderFactories, null) ?? binderFactories;
2598if (Interlocked.CompareExchange(ref slot!, newWeakReference, previousWeakReference) == previousWeakReference)
2617if (_lazyCompilationUnitCompletedTrees == null) Interlocked.CompareExchange(ref _lazyCompilationUnitCompletedTrees, new HashSet<SyntaxTree>(), null);
2842Interlocked.CompareExchange(ref _lazyDeclarationDiagnostics, diagnostics, null);
3207var recent = Interlocked.CompareExchange(ref _usageOfUsingsRecordedInTrees, updated, current);
Symbols\Metadata\PE\PENamedTypeSymbol.cs (11)
105return Interlocked.CompareExchange(ref _lazyUncommonProperties, result, null) ?? result;
477Interlocked.CompareExchange(ref _lazyBaseType, MakeAcyclicBaseType(), ErrorTypeSymbol.UnknownResultType);
525Interlocked.CompareExchange(ref _lazyDeclaredBaseType, baseType, ErrorTypeSymbol.UnknownResultType);
848Interlocked.CompareExchange(ref _lazyMemberNames, CreateReadOnlyMemberNames(names), null);
1258Interlocked.CompareExchange(ref uncommon.lazyEnumUnderlyingType, underlyingType, null);
1461var exchangeResult = Interlocked.CompareExchange(ref _lazyMembersByName, membersDict, null);
1482Interlocked.Exchange(ref _lazyMemberNames, memberNames);
1574var exchangeResult = Interlocked.CompareExchange(ref _lazyNestedTypes, typesDict, null);
2215Interlocked.CompareExchange(ref uncommon.lazyDefaultMemberName, defaultMemberName ?? "", null);
2364Interlocked.CompareExchange(ref uncommon.lazyComImportCoClassType, coClassType, ErrorTypeSymbol.UnknownResultType);
2505Interlocked.CompareExchange(
Symbols\MetadataOrSourceAssemblySymbol.cs (11)
90Interlocked.CompareExchange(ref _lazySpecialTypes,
94if ((object)Interlocked.CompareExchange(ref _lazySpecialTypes[(int)typeId], corType, null) != null)
102Interlocked.Increment(ref _cachedSpecialTypes);
128Interlocked.CompareExchange(ref _lazyTypeNames, UnionCollection<string>.Create(this.Modules, m => m.TypeNames), null);
141Interlocked.CompareExchange(ref _lazyNativeIntegerTypes, new NativeIntegerTypeSymbol[2], null);
153Interlocked.CompareExchange(ref _lazyNativeIntegerTypes[index], new NativeIntegerTypeSymbol(underlyingType), null);
165Interlocked.CompareExchange(ref _lazyNamespaceNames, UnionCollection<string>.Create(this.Modules, m => m.NamespaceNames), null);
201Interlocked.CompareExchange(ref _lazySpecialTypeMembers, specialTypeMembers, null);
213Interlocked.CompareExchange(ref _lazySpecialTypeMembers[(int)member], result, ErrorTypeSymbol.UnknownResultType);
273Interlocked.CompareExchange(ref _assembliesToWhichInternalAccessHasBeenAnalyzed, new ConcurrentDictionary<AssemblySymbol, IVTConclusion>(), null);
289Interlocked.CompareExchange(ref _lazyTypeConversions, new TypeConversions(this), null);
Symbols\Source\SourceAssemblySymbol.cs (7)
198Interlocked.CompareExchange(ref lazyAssemblyIdentity, ComputeIdentity(), null);
547Interlocked.CompareExchange(ref _lazyStrongNameKeys, ComputeStrongNameKeys(), null);
1178Interlocked.CompareExchange(ref _lazyOmittedAttributeIndices, new ConcurrentSet<int>(), null);
1366Interlocked.CompareExchange(ref lazyNetModuleAttributesBag, CustomAttributesBag<CSharpAttributeData>.Empty, null);
1447if (Interlocked.CompareExchange(ref lazyNetModuleAttributesBag, netModuleAttributesBag, null) == null)
2163Interlocked.CompareExchange(ref _optimisticallyGrantedInternalsAccess, new ConcurrentDictionary<AssemblySymbol, bool>(), null);
2305Interlocked.CompareExchange(ref lazyInternalsVisibleToMap,
Symbols\Source\SourceMemberContainerSymbol.cs (7)
1305if (Interlocked.CompareExchange(ref _lazyTypeMembers, MakeTypeMembers(diagnostics), null) == null)
1597Interlocked.CompareExchange(ref _lazyEarlyAttributeDecodingMembersDictionary, membersByName, null);
1658var alreadyKnown = Interlocked.CompareExchange(ref _lazyMembersAndInitializers, membersAndInitializers, null);
1762if (Interlocked.CompareExchange(ref _lazyMembersDictionary, membersDictionary, null) == null)
2348Interlocked.CompareExchange(ref _lazyKnownCircularStruct, (int)ThreeState.False, (int)ThreeState.Unknown);
2355if (Interlocked.CompareExchange(ref _lazyKnownCircularStruct, value, (int)ThreeState.Unknown) == (int)ThreeState.Unknown)
3236var alreadyKnown = Interlocked.CompareExchange(ref _lazyDeclaredMembersAndInitializers, declaredMembersAndInitializers, DeclaredMembersAndInitializers.UninitializedSentinel);
Symbols\Source\SourcePropertySymbolBase.cs (6)
769Interlocked.CompareExchange(ref _lazyMergedBackingField, backingField, null);
782Interlocked.CompareExchange(ref _lazyDeclaredBackingField, CreateBackingField(), null);
790Interlocked.CompareExchange(ref _lazyMergedBackingField, backingField, null);
1192Interlocked.CompareExchange(ref _lazyOverriddenOrHiddenMembers, this.MakeOverriddenOrHiddenMembers(), null);
1218Interlocked.CompareExchange(ref _lazySynthesizedSealedAccessor, MakeSynthesizedSealedAccessor(), null);
1299bagCreatedOnThisThread = Interlocked.CompareExchange(ref _lazyCustomAttributesBag, attributesBag, null) == null;
Symbols\TypeSymbol.cs (6)
74return Interlocked.CompareExchange(ref _implementationForInterfaceMemberMap, map, null) ?? map;
116return Interlocked.CompareExchange(ref _lazyInterfaceInfo, info, null) ?? info;
393Interlocked.CompareExchange(ref info.interfacesAndTheirBaseInterfaces, MakeInterfacesAndTheirBaseInterfaces(this.InterfacesNoUseSiteDiagnostics()), null);
2272Interlocked.CompareExchange(ref info.explicitInterfaceImplementationMap, MakeExplicitInterfaceImplementationMap(), null);
2314Interlocked.CompareExchange(ref info.synthesizedMethodImplMap, makeSynthesizedMethodImplMap(), null);
2379Interlocked.CompareExchange(ref _lazyAbstractMembers, ComputeAbstractMembers(), null);
Microsoft.CodeAnalysis.CSharp.CodeStyle (1)
Microsoft.CodeAnalysis.CSharp.EditorFeatures.UnitTests (1)
Microsoft.CodeAnalysis.CSharp.Emit3.UnitTests (232)
Microsoft.CodeAnalysis.CSharp.Features (3)
Microsoft.CodeAnalysis.CSharp.Semantic.UnitTests (97)
Microsoft.CodeAnalysis.CSharp.Symbol.UnitTests (2)
Microsoft.CodeAnalysis.CSharp.Workspaces (1)
Microsoft.CodeAnalysis.EditorFeatures (10)
Microsoft.CodeAnalysis.EditorFeatures.Test.Utilities (2)
Microsoft.CodeAnalysis.EditorFeatures.Wpf (2)
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider (2)
Microsoft.CodeAnalysis.ExpressionEvaluator.ResultProvider.Utilities (4)
Microsoft.CodeAnalysis.Features (15)
Microsoft.CodeAnalysis.Features.UnitTests (1)
Microsoft.CodeAnalysis.InteractiveHost (7)
Microsoft.CodeAnalysis.LanguageServer (4)
Microsoft.CodeAnalysis.LanguageServer.Protocol (6)
Microsoft.CodeAnalysis.LanguageServer.Protocol.UnitTests (1)
Microsoft.CodeAnalysis.PooledObjects.Package (2)
Microsoft.CodeAnalysis.Remote.ServiceHub (3)
Microsoft.CodeAnalysis.Remote.Workspaces (2)
Microsoft.CodeAnalysis.Scripting (5)
Microsoft.CodeAnalysis.Test.Utilities (6)
Microsoft.CodeAnalysis.UnitTests (1)
Microsoft.CodeAnalysis.VisualBasic (167)
Compilation\VisualBasicCompilation.vb (6)
257Interlocked.CompareExchange(_lazyMyTemplate, tree, VisualBasicSyntaxTree.Dummy)
276If Interlocked.CompareExchange(_lazyMyTemplate, tree, VisualBasicSyntaxTree.Dummy) Is VisualBasicSyntaxTree.Dummy Then
308Interlocked.CompareExchange(_lazyEmbeddedSymbolManager, New EmbeddedSymbolManager(embedded), Nothing)
1445Interlocked.CompareExchange(_lazyGlobalNamespace, MergedNamespaceSymbol.CreateGlobalNamespace(Me), Nothing)
1510Interlocked.CompareExchange(_lazyEntryPoint, New EntryPoint(entryPoint, diagnostics), Nothing)
1794Interlocked.CompareExchange(_lazyCompilationUnitCompletedTrees, New HashSet(Of SyntaxTree)(), Nothing)
Symbols\Metadata\PE\PENamedTypeSymbol.vb (9)
403Interlocked.CompareExchange(_lazyEnumUnderlyingType,
497Interlocked.CompareExchange(Of ICollection(Of String))(
728Dim exchangeResult = Interlocked.CompareExchange(_lazyMembers, membersDict, Nothing)
732Interlocked.Exchange(Of ICollection(Of String))(_lazyMemberNames, memberNames)
789Interlocked.CompareExchange(_lazyNestedTypes, typesDict, Nothing)
945Interlocked.CompareExchange(
957Interlocked.CompareExchange(
1060Interlocked.CompareExchange(_lazyCoClassType,
1088Interlocked.CompareExchange(_lazyDefaultPropertyName, If(memberName, String.Empty), Nothing)
Symbols\MetadataOrSourceAssemblySymbol.vb (6)
77Interlocked.CompareExchange(_lazySpecialTypes,
81If (Interlocked.CompareExchange(_lazySpecialTypes(CInt(typeId)), corType, Nothing) IsNot Nothing) Then
86Interlocked.Increment(_cachedSpecialTypes)
107Interlocked.CompareExchange(_lazyTypeNames, UnionCollection(Of String).Create(Me.Modules, Function(m) m.TypeNames), Nothing)
117Interlocked.CompareExchange(_lazyNamespaceNames, UnionCollection(Of String).Create(Me.Modules, Function(m) m.NamespaceNames), Nothing)
172Interlocked.CompareExchange(_assembliesToWhichInternalAccessHasBeenAnalyzed, New ConcurrentDictionary(Of AssemblySymbol, IVTConclusion), Nothing)
Symbols\Source\SourceAssemblySymbol.vb (7)
141Interlocked.CompareExchange(m_lazyIdentity, ComputeIdentity(), Nothing)
379Interlocked.CompareExchange(lazyNetModuleAttributesBag, CustomAttributesBag(Of VisualBasicAttributeData).Empty, Nothing)
441Interlocked.CompareExchange(_lazyDuplicateAttributeIndices, attributeIndicesToSkip, Nothing)
983Interlocked.CompareExchange(_lazyInternalsVisibleToMap,
1656Interlocked.CompareExchange(_optimisticallyGrantedInternalsAccess, New ConcurrentDictionary(Of AssemblySymbol, Boolean), Nothing)
1719Interlocked.CompareExchange(_lazyStrongNameKeys, keys, Nothing)
1744Interlocked.CompareExchange(_lazyStrongNameKeys, keys, Nothing)
Symbols\Source\SourceMethodSymbol.vb (5)
1303Interlocked.CompareExchange(_lazyMeParameter, New MeParameterSymbol(Me), Nothing)
1407Interlocked.CompareExchange(lazyCustomAttributesBag, attributesBag, Nothing)
1419Interlocked.CompareExchange(lazyCustomAttributesBag, attributesBag, Nothing)
2181Interlocked.CompareExchange(_lazyOverriddenMethods, overriddenMembers, Nothing)
2183Interlocked.CompareExchange(_lazyReturnType, retType, Nothing)
Symbols\Source\SourceModuleSymbol.vb (8)
187Interlocked.CompareExchange(_lazyGlobalNamespace, globalNS, Nothing)
262Interlocked.CompareExchange(_lazyQuickAttributeChecker, CreateQuickAttributeChecker(), Nothing)
353If Interlocked.CompareExchange(_lazyBoundImports, BindImports(cancellationToken), Nothing) Is Nothing Then
363Interlocked.CompareExchange(_lazyBoundImportsAdditionalDiagnostics, New StrongBox(Of ReadOnlyBindingDiagnostic(Of AssemblySymbol))(diagnosticBag.ToReadOnlyAndFree()), Nothing)
828Return Interlocked.CompareExchange(variable, value, comparand) Is comparand AndAlso comparand Is Nothing
834stored = Interlocked.CompareExchange(variable, value, comparand) Is comparand
861Interlocked.CompareExchange(variable, value, comparand)
866If Interlocked.CompareExchange(variable, value, comparand) <> comparand AndAlso
Symbols\Source\SourceNamedTypeSymbol.vb (8)
1577Dim prev = Interlocked.CompareExchange(m_baseCycleDiagnosticInfo, diag, Nothing)
1604Dim prev = Interlocked.CompareExchange(m_baseCycleDiagnosticInfo, diag, Nothing)
1767If Interlocked.CompareExchange(Me._lazyEnumUnderlyingType, underlyingType, Nothing) Is Nothing Then
1937Interlocked.CompareExchange(_lazyCoClassType, Nothing, DirectCast(ErrorTypeSymbol.UnknownResultType, TypeSymbol))
1943Interlocked.CompareExchange(_lazyCoClassType, Nothing,
2197Interlocked.CompareExchange(_comClassData, New ComClassData(attrData), Nothing)
2228Interlocked.CompareExchange(Me._lazyCoClassType,
2575Interlocked.CompareExchange(Me._lazyWithEventsOverrides,
Microsoft.CodeAnalysis.VisualBasic.CodeStyle (1)
Microsoft.CodeAnalysis.VisualBasic.Features (2)
Microsoft.CodeAnalysis.VisualBasic.Workspaces (2)
Microsoft.CodeAnalysis.Workspaces (66)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (6)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue);
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.Workspaces.MSBuild (2)
Microsoft.CodeAnalysis.Workspaces.MSBuild.BuildHost (23)
src\Compilers\Core\Portable\InternalUtilities\InterlockedOperations.cs (6)
17=> Interlocked.CompareExchange(ref target, value, null) ?? value;
21var existingValue = Interlocked.CompareExchange(ref target, value, uninitializedValue);
117/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
135/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
141T oldValue = Interlocked.CompareExchange(ref target, initializedValue, uninitializedValue);
152/// nearly always more useful than the usual return from <see cref="Interlocked.CompareExchange{T}(ref T, T, T)"/>
Microsoft.CodeAnalysis.Workspaces.MSBuild.UnitTests (1)
Microsoft.CodeAnalysis.Workspaces.Test.Utilities (4)
Microsoft.CodeAnalysis.Workspaces.UnitTests (1)
Microsoft.CSharp (1)
Microsoft.DotNet.RemoteExecutor (2)
Microsoft.Extensions.AsyncState (1)
Microsoft.Extensions.Caching.Hybrid (7)
Microsoft.Extensions.Caching.Hybrid.Tests (21)
Microsoft.Extensions.Caching.Memory (14)
Microsoft.Extensions.Caching.StackExchangeRedis (2)
Microsoft.Extensions.Compliance.Testing (2)
Microsoft.Extensions.Configuration (5)
Microsoft.Extensions.DependencyInjection (1)
Microsoft.Extensions.Diagnostics (1)
Microsoft.Extensions.Diagnostics.Testing (1)
Microsoft.Extensions.Http.Diagnostics (1)
Microsoft.Extensions.Http.Diagnostics.Tests (1)
Microsoft.Extensions.Logging.Abstractions (1)
Microsoft.Extensions.Logging.AzureAppServices (2)
Microsoft.Extensions.Logging.EventSource (3)
Microsoft.Extensions.ML (3)
Microsoft.Extensions.ObjectPool (5)
Microsoft.Extensions.Options (1)
Microsoft.Extensions.Primitives (2)
Microsoft.Extensions.ServiceDiscovery (14)
Microsoft.Extensions.Telemetry (4)
Microsoft.Extensions.TimeProvider.Testing (1)
Microsoft.JSInterop (3)
Microsoft.Maui (4)
Microsoft.Maui.Controls (11)
Microsoft.Maui.Controls.Compatibility (2)
Microsoft.Maui.Controls.Foldable (2)
Microsoft.Maui.Graphics.Skia (1)
Microsoft.Maui.Graphics.Win2D.WinUI.Desktop (1)
Microsoft.ML.AutoML.Interactive (1)
Microsoft.ML.CodeAnalyzer.Tests (1)
Microsoft.ML.Core (11)
Microsoft.ML.CpuMath (1)
Microsoft.ML.Data (33)
Data\Combiner.cs (5)
28Interlocked.CompareExchange(ref _instance, new TextCombiner(), null) ??
54Interlocked.CompareExchange(ref _instance, new FloatAdder(), null) ??
76Interlocked.CompareExchange(ref _instance, new R4Adder(), null);
98Interlocked.CompareExchange(ref _instance, new R8Adder(), null) ??
121Interlocked.CompareExchange(ref _instance, new U4Adder(), null) ??
Microsoft.ML.DataView (16)
DataViewType.cs (16)
100Interlocked.CompareExchange(ref _instance, new TextDataViewType(), null) ??
141Interlocked.CompareExchange(ref _instSByte, new NumberDataViewType(typeof(sbyte)), null) ??
155Interlocked.CompareExchange(ref _instByte, new NumberDataViewType(typeof(byte)), null) ??
169Interlocked.CompareExchange(ref _instInt16, new NumberDataViewType(typeof(short)), null) ??
183Interlocked.CompareExchange(ref _instUInt16, new NumberDataViewType(typeof(ushort)), null) ??
197Interlocked.CompareExchange(ref _instInt32, new NumberDataViewType(typeof(int)), null) ??
211Interlocked.CompareExchange(ref _instUInt32, new NumberDataViewType(typeof(uint)), null) ??
225Interlocked.CompareExchange(ref _instInt64, new NumberDataViewType(typeof(long)), null) ??
239Interlocked.CompareExchange(ref _instUInt64, new NumberDataViewType(typeof(ulong)), null) ??
253Interlocked.CompareExchange(ref _instSingle, new NumberDataViewType(typeof(float)), null) ??
267Interlocked.CompareExchange(ref _instDouble, new NumberDataViewType(typeof(double)), null) ??
298Interlocked.CompareExchange(ref _instance, new RowIdDataViewType(), null) ??
337Interlocked.CompareExchange(ref _instance, new BooleanDataViewType(), null) ??
376Interlocked.CompareExchange(ref _instance, new DateTimeDataViewType(), null) ??
412Interlocked.CompareExchange(ref _instance, new DateTimeOffsetDataViewType(), null) ??
448Interlocked.CompareExchange(ref _instance, new TimeSpanDataViewType(), null) ??
Microsoft.ML.FastTree (9)
Microsoft.ML.StandardTrainers (2)
Microsoft.ML.Tests (3)
Microsoft.ML.TimeSeries (3)
Microsoft.ML.Tokenizers (3)
Microsoft.ML.Transforms (7)
Microsoft.NET.StringTools (1)
Microsoft.VisualBasic.Forms (1)
Microsoft.VisualBasic.Tests (3)
Microsoft.VisualStudio.IntegrationTest.Setup (3)
Microsoft.VisualStudio.LanguageServices (8)
Microsoft.VisualStudio.LanguageServices.CSharp (5)
Microsoft.VisualStudio.LanguageServices.DevKit (1)
MSBuild (5)
MSBuildTaskHost (11)
mscorlib (1)
netstandard (1)
PresentationCore (13)
PresentationFramework (22)
Roslyn.VisualStudio.DiagnosticsWindow (2)
ScenarioTests.Common.Tests (2)
Shared.Tests (1)
SignalR.Client.FunctionalTestApp (1)
Sockets.FunctionalTests (1)
System.Collections (1)
System.Collections.Concurrent (22)
System.Collections.Immutable (21)
System\Collections\Immutable\ImmutableInterlocked.cs (16)
49T interlockedResult = Interlocked.CompareExchange(ref location, newValue, oldValue);
96T interlockedResult = Interlocked.CompareExchange(ref location, newValue, oldValue);
138T[]? interlockedResult = Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), newImmutableArray.array, oldArray);
185T[]? interlockedResult = Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), newImmutableArray.array, oldArray);
205return new ImmutableArray<T>(Interlocked.Exchange(ref Unsafe.AsRef(in location.array), value.array));
219return new ImmutableArray<T>(Interlocked.CompareExchange(ref Unsafe.AsRef(in location.array), value.array, comparand.array));
323ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
371ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
418ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
452ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
487ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
518ImmutableDictionary<TKey, TValue> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
552ImmutableStack<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
575ImmutableStack<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
607ImmutableQueue<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
630ImmutableQueue<T> interlockedResult = Interlocked.CompareExchange(ref location, updatedCollection, priorCollection);
System.ComponentModel.Composition (12)
System.ComponentModel.Composition.Registration (3)
System.ComponentModel.TypeConverter (7)
System.Composition.Hosting (1)
System.Configuration.ConfigurationManager (2)
System.Console (2)
System.Data.Common (13)
System.Data.Odbc (16)
System.Diagnostics.DiagnosticSource (38)
System\Diagnostics\Activity.cs (15)
251Interlocked.CompareExchange(ref _id, id, null);
283Interlocked.CompareExchange(ref _parentId, parentId, null);
287Interlocked.CompareExchange(ref _parentId, Parent.Id, null);
322Interlocked.CompareExchange(ref _rootId, rootId, null);
490if (_tags != null || Interlocked.CompareExchange(ref _tags, new TagsLinkedList(kvp), null) != null)
514if (_tags != null || Interlocked.CompareExchange(ref _tags, new TagsLinkedList(kvp, set: true), null) != null)
529if (_events != null || Interlocked.CompareExchange(ref _events, new DiagLinkedList<ActivityEvent>(e), null) != null)
617if (_links != null || Interlocked.CompareExchange(ref _links, new DiagLinkedList<ActivityLink>(link), null) != null)
638if (_baggage != null || Interlocked.CompareExchange(ref _baggage, new BaggageLinkedList(kvp), null) != null)
662if (_baggage != null || Interlocked.CompareExchange(ref _baggage, new BaggageLinkedList(kvp, set: true), null) != null)
918Interlocked.CompareExchange(ref _spanId, spanId, null);
998Interlocked.CompareExchange(ref _parentSpanId, parentSpanId, null);
1139Interlocked.CompareExchange(ref _customProperties, new Dictionary<string, object>(), null);
1329ret = AppendSuffix(Parent.Id, Interlocked.Increment(ref Parent._currentChildId).ToString(), '.');
1346ret = AppendSuffix(parentId, Interlocked.Increment(ref s_currentRootId).ToString("x"), '_');
System\Diagnostics\Metrics\AggregatorStore.cs (9)
141if (Interlocked.CompareExchange(ref _stateUnion, newState, null) is null)
158if (Interlocked.CompareExchange(ref _stateUnion, newState, state) == state)
177if (Interlocked.CompareExchange(ref _stateUnion, newState, null) is null)
194if (Interlocked.CompareExchange(ref _stateUnion, newState, state) == state)
250Interlocked.CompareExchange(ref NoLabelAggregator, aggregator, null);
266Interlocked.CompareExchange(ref Label1, new FixedSizeLabelNameDictionary<StringSequence1, ObjectSequence1, TAggregator>(), null);
273Interlocked.CompareExchange(ref Label2, new FixedSizeLabelNameDictionary<StringSequence2, ObjectSequence2, TAggregator>(), null);
280Interlocked.CompareExchange(ref Label3, new FixedSizeLabelNameDictionary<StringSequence3, ObjectSequence3, TAggregator>(), null);
287Interlocked.CompareExchange(ref LabelMany, new FixedSizeLabelNameDictionary<StringSequenceMany, ObjectSequenceMany, TAggregator>(), null);
System.Diagnostics.Process (3)
System.Diagnostics.TraceSource (2)
System.Formats.Cbor (1)
System.IO.Compression (4)
System.IO.Compression.Brotli (1)
System.IO.MemoryMappedFiles (1)
System.IO.Pipelines (2)
System.IO.Pipes (2)
System.Linq.Expressions (11)
System.Linq.Parallel (9)
System.Net.Http (48)
System\Net\Http\HttpTelemetry.AnyOS.cs (9)
51_startedRequestsCounter ??= new PollingCounter("requests-started", this, () => Interlocked.Read(ref _startedRequests))
57_startedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-started-rate", this, () => Interlocked.Read(ref _startedRequests))
67_failedRequestsCounter ??= new PollingCounter("requests-failed", this, () => Interlocked.Read(ref _failedRequests))
73_failedRequestsPerSecondCounter ??= new IncrementingPollingCounter("requests-failed-rate", this, () => Interlocked.Read(ref _failedRequests))
82_currentRequestsCounter ??= new PollingCounter("current-requests", this, () => -Interlocked.Read(ref _stoppedRequests) + Interlocked.Read(ref _startedRequests))
87_totalHttp11ConnectionsCounter ??= new PollingCounter("http11-connections-current-total", this, () => Interlocked.Read(ref _openedHttp11Connections))
92_totalHttp20ConnectionsCounter ??= new PollingCounter("http20-connections-current-total", this, () => Interlocked.Read(ref _openedHttp20Connections))
97_totalHttp30ConnectionsCounter ??= new PollingCounter("http30-connections-current-total", this, () => Interlocked.Read(ref _openedHttp30Connections))
System.Net.HttpListener (12)
System\Net\Managed\HttpEndPointListener.cs (6)
332} while (Interlocked.CompareExchange(ref _unhandledPrefixes, future, current) != current);
344} while (Interlocked.CompareExchange(ref _allPrefixes, future, current) != current);
358} while (Interlocked.CompareExchange(ref _prefixes, p2, prefs) != prefs);
373} while (Interlocked.CompareExchange(ref _unhandledPrefixes, future, current) != current);
387} while (Interlocked.CompareExchange(ref _allPrefixes, future, current) != current);
401} while (Interlocked.CompareExchange(ref _prefixes, p2, prefs) != prefs);
System.Net.Mail (12)
System.Net.NameResolution (5)
System.Net.Quic (18)
System\Net\Quic\QuicStream.cs (7)
332if (totalCopied > 0 && Interlocked.CompareExchange(ref _receivedNeedsEnable, 0, 1) == 1)
408if (Interlocked.CompareExchange(ref _sendLocked, 1, 0) == 0)
428Interlocked.CompareExchange(ref _sendException, exception, null);
495Interlocked.CompareExchange(ref _sendException, exception, null);
496if (Interlocked.CompareExchange(ref _sendLocked, 1, 0) == 0)
576return (_receiveBuffers.HasCapacity() && Interlocked.CompareExchange(ref _receivedNeedsEnable, 0, 1) == 1) ? QUIC_STATUS_CONTINUE : QUIC_STATUS_SUCCESS;
715if (Interlocked.Exchange(ref _disposed, true))
System.Net.Requests (17)
System.Net.Security (43)
System\Net\Security\NetSecurityTelemetry.cs (21)
53_tlsHandshakeRateCounter ??= new IncrementingPollingCounter("tls-handshake-rate", this, () => Interlocked.Read(ref _finishedTlsHandshakes))
59_totalTlsHandshakesCounter ??= new PollingCounter("total-tls-handshakes", this, () => Interlocked.Read(ref _finishedTlsHandshakes))
64_currentTlsHandshakesCounter ??= new PollingCounter("current-tls-handshakes", this, () => -Interlocked.Read(ref _finishedTlsHandshakes) + Interlocked.Read(ref _startedTlsHandshakes))
69_failedTlsHandshakesCounter ??= new PollingCounter("failed-tls-handshakes", this, () => Interlocked.Read(ref _failedTlsHandshakes))
74_sessionsOpenCounter ??= new PollingCounter("all-tls-sessions-open", this, () => Interlocked.Read(ref _sessionsOpen))
79_sessionsOpenTls10Counter ??= new PollingCounter("tls10-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls10))
84_sessionsOpenTls11Counter ??= new PollingCounter("tls11-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls11))
89_sessionsOpenTls12Counter ??= new PollingCounter("tls12-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls12))
94_sessionsOpenTls13Counter ??= new PollingCounter("tls13-sessions-open", this, () => Interlocked.Read(ref _sessionsOpenTls13))
135Interlocked.Increment(ref _startedTlsHandshakes);
163Interlocked.Increment(ref _finishedTlsHandshakes);
164Interlocked.Increment(ref _failedTlsHandshakes);
177Interlocked.Increment(ref _finishedTlsHandshakes);
212Interlocked.Increment(ref protocolSessionsOpen);
213Interlocked.Increment(ref _sessionsOpen);
232count = Interlocked.Decrement(ref _sessionsOpenTls10);
236count = Interlocked.Decrement(ref _sessionsOpenTls11);
241count = Interlocked.Decrement(ref _sessionsOpenTls12);
245count = Interlocked.Decrement(ref _sessionsOpenTls13);
251count = Interlocked.Decrement(ref _sessionsOpen);
System\Net\Security\SslStream.IO.cs (10)
65if (Interlocked.Exchange(ref _nestedRead, NestedState.StreamDisposed) == NestedState.StreamNotInUse &&
66Interlocked.Exchange(ref _nestedAuth, NestedState.StreamDisposed) == NestedState.StreamNotInUse)
80if (Interlocked.Exchange(ref _connectionOpenedStatus, ConnectionStatus.Disposed) == ConnectionStatus.HandshakeCompleted)
152bool connectionOpen = Interlocked.CompareExchange(ref _connectionOpenedStatus, ConnectionStatus.HandshakeCompleted, ConnectionStatus.NoHandshake) == ConnectionStatus.NoHandshake;
194if (Interlocked.CompareExchange(ref _nestedAuth, NestedState.StreamInUse, NestedState.StreamNotInUse) != NestedState.StreamNotInUse)
200if (Interlocked.CompareExchange(ref _nestedRead, NestedState.StreamInUse, NestedState.StreamNotInUse) != NestedState.StreamNotInUse)
207if (Interlocked.Exchange(ref _nestedWrite, NestedState.StreamInUse) != NestedState.StreamNotInUse)
291if (Interlocked.Exchange(ref _nestedAuth, NestedState.StreamInUse) == NestedState.StreamInUse)
828if (Interlocked.CompareExchange(ref _nestedRead, NestedState.StreamInUse, NestedState.StreamNotInUse) != NestedState.StreamNotInUse)
970if (Interlocked.Exchange(ref _nestedWrite, NestedState.StreamInUse) == NestedState.StreamInUse)
System.Net.ServerSentEvents (1)
System.Net.Sockets (58)
System\Net\Sockets\Socket.Tasks.cs (20)
62Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ??
95Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ??
262Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ??
320Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ??
348TaskSocketAsyncEventArgs<int>? saea = Interlocked.Exchange(ref _multiBufferReceiveEventArgs, null);
410Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ??
450Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ??
511Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null) ??
566Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ??
584Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ??
612TaskSocketAsyncEventArgs<int>? saea = Interlocked.Exchange(ref _multiBufferSendEventArgs, null);
674Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ??
704Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ??
782Interlocked.Exchange(ref _singleBufferSendEventArgs, null) ??
945if (Interlocked.CompareExchange(ref cache, saea, null) != null)
954Interlocked.Exchange(ref _multiBufferReceiveEventArgs, null)?.Dispose();
955Interlocked.Exchange(ref _multiBufferSendEventArgs, null)?.Dispose();
956Interlocked.Exchange(ref _singleBufferReceiveEventArgs, null)?.Dispose();
957Interlocked.Exchange(ref _singleBufferSendEventArgs, null)?.Dispose();
1033if (Interlocked.CompareExchange(ref cache, this, null) != null)
System\Net\Sockets\SocketAsyncContext.Unix.cs (9)
92Interlocked.Exchange(ref _cachedAcceptOperation, null) ??
96Interlocked.Exchange(ref _cachedBufferMemoryReceiveOperation, null) ??
100Interlocked.Exchange(ref _cachedBufferListReceiveOperation, null) ??
104Interlocked.Exchange(ref _cachedBufferMemorySendOperation, null) ??
108Interlocked.Exchange(ref _cachedBufferListSendOperation, null) ??
157State oldState = Interlocked.CompareExchange(ref _state, State.Running, State.Waiting);
185if (state == Interlocked.CompareExchange(ref _state, newState, state))
221if (state == Interlocked.CompareExchange(ref _state, newState, state))
258Debug.Assert(!Interlocked.Exchange(ref _callbackQueued, true), $"Unexpected _callbackQueued: {_callbackQueued}");
System\Net\Sockets\SocketsTelemetry.cs (15)
86Interlocked.Increment(ref _currentOutgoingConnectAttempts);
147long newCount = Interlocked.Decrement(ref _currentOutgoingConnectAttempts);
164Interlocked.Increment(ref _outgoingConnectionsEstablished);
198Interlocked.Increment(ref _incomingConnectionsEstablished);
212Interlocked.Add(ref _bytesReceived, count);
219Interlocked.Add(ref _bytesSent, count);
225Interlocked.Increment(ref _datagramsReceived);
231Interlocked.Increment(ref _datagramsSent);
266_currentOutgoingConnectAttemptsCounter ??= new PollingCounter("current-outgoing-connect-attempts", this, () => Interlocked.Read(ref _currentOutgoingConnectAttempts))
270_outgoingConnectionsEstablishedCounter ??= new PollingCounter("outgoing-connections-established", this, () => Interlocked.Read(ref _outgoingConnectionsEstablished))
274_incomingConnectionsEstablishedCounter ??= new PollingCounter("incoming-connections-established", this, () => Interlocked.Read(ref _incomingConnectionsEstablished))
278_bytesReceivedCounter ??= new PollingCounter("bytes-received", this, () => Interlocked.Read(ref _bytesReceived))
282_bytesSentCounter ??= new PollingCounter("bytes-sent", this, () => Interlocked.Read(ref _bytesSent))
286_datagramsReceivedCounter ??= new PollingCounter("datagrams-received", this, () => Interlocked.Read(ref _datagramsReceived))
290_datagramsSentCounter ??= new PollingCounter("datagrams-sent", this, () => Interlocked.Read(ref _datagramsSent))
System.Net.WebClient (5)
System.Net.WebProxy (1)
System.Net.WebSockets (3)
System.Net.WebSockets.Client (4)
System.Private.CoreLib (226)
src\libraries\System.Private.CoreLib\src\System\Globalization\CultureInfo.cs (10)
146Interlocked.CompareExchange(ref s_userDefaultCulture, GetUserDefaultCulture(), null);
152Interlocked.CompareExchange(ref s_userDefaultUICulture, GetUserDefaultUICulture(), null);
378Interlocked.CompareExchange(ref s_asyncLocalCurrentCulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentCulture), null);
400Interlocked.CompareExchange(ref s_asyncLocalCurrentUICulture, new AsyncLocal<CultureInfo>(AsyncLocalSetCurrentUICulture), null);
519Interlocked.CompareExchange<CultureInfo?>(ref _parent, culture, null);
715Interlocked.CompareExchange(ref _numInfo, temp, null);
741Interlocked.CompareExchange(ref _dateTimeInfo, temp, null);
833Interlocked.MemoryBarrier();
1127cache = Interlocked.CompareExchange(ref s_cachedCulturesByName, cache, null) ?? cache;
1142cache = Interlocked.CompareExchange(ref s_cachedCulturesByLcid, cache, null) ?? cache;
src\libraries\System.Private.CoreLib\src\System\Threading\CancellationTokenSource.cs (10)
104if (Interlocked.CompareExchange(ref _kernelEvent, mre, null) != null)
448ITimer? currentTimer = Interlocked.CompareExchange(ref _timer, timer, null);
562ManualResetEvent? mre = Interlocked.Exchange<ManualResetEvent?>(ref _kernelEvent!, null);
609registrations = Interlocked.CompareExchange(ref _registrations, registrations, null) ?? registrations;
711Interlocked.CompareExchange(ref _state, States.NotifyingState, States.NotCanceledState) == States.NotCanceledState)
741Registrations? registrations = Interlocked.Exchange(ref _registrations, null);
744Interlocked.Exchange(ref _state, States.NotifyingCompleteState);
833Interlocked.Exchange(ref registrations.ExecutingCallbackId, 0); // for safety, prevent reorderings crossing this point and seeing inconsistent state.
1171if (Interlocked.Exchange(ref value, true))
1179do { sw.SpinOnce(); } while (Interlocked.Exchange(ref value, true));
src\libraries\System.Private.CoreLib\src\System\Threading\Interlocked.cs (4)
206return (IntPtr)Interlocked.Exchange(ref Unsafe.As<IntPtr, long>(ref location1), (long)value);
224return (UIntPtr)Interlocked.Exchange(ref Unsafe.As<UIntPtr, long>(ref location1), (long)value);
456return (IntPtr)Interlocked.CompareExchange(ref Unsafe.As<IntPtr, long>(ref location1), (long)value, (long)comparand);
475return (UIntPtr)Interlocked.CompareExchange(ref Unsafe.As<UIntPtr, long>(ref location1), (long)value, (long)comparand);
src\libraries\System.Private.CoreLib\src\System\Threading\Tasks\Task.cs (31)
191Interlocked.CompareExchange(ref s_currentActiveTasks, new Dictionary<int, Task>(), null) ??
696(Interlocked.CompareExchange(ref m_stateFlags, oldFlags | newBits, oldFlags) == oldFlags ||
706int oldFlags = Interlocked.CompareExchange(ref m_stateFlags, flags | newBits, flags);
721oldFlags = Interlocked.CompareExchange(ref m_stateFlags, flags | newBits, flags);
753Interlocked.And(ref m_stateFlags, ~(int)TaskStateFlags.WaitCompletionNotification);
888Interlocked.Increment(ref props.m_completionCountdown);
900Interlocked.Decrement(ref props.m_completionCountdown);
969if (Interlocked.CompareExchange(ref m_taskScheduler, scheduler, null) != null)
1069if (Interlocked.CompareExchange(ref m_taskScheduler, scheduler, null) != null)
1171newId = Interlocked.Increment(ref s_taskIdCounter);
1198Interlocked.CompareExchange(ref m_taskId, newId, 0);
1336Interlocked.CompareExchange(ref m_contingentProperties, new ContingentProperties(), null);
1486if (Interlocked.CompareExchange(ref contingentProps.m_completionEvent, newMre, null) != null)
1772if (Interlocked.CompareExchange(ref props.m_exceptionsHolder, holder, null) != null)
2006Interlocked.Decrement(ref props.m_completionCountdown) == 0) // Reaching this sub clause means there may be remaining active children,
2093Interlocked.Exchange(ref m_stateFlags, m_stateFlags | completionState);
2167Interlocked.CompareExchange(ref props.m_exceptionalChildren, new List<Task>(), null);
2184if (Interlocked.Decrement(ref props!.m_completionCountdown) == 0)
2293int prevState = Interlocked.Exchange(ref m_stateFlags, m_stateFlags | (int)TaskStateFlags.Canceled);
3306Interlocked.Exchange(ref m_stateFlags, m_stateFlags | (int)TaskStateFlags.Canceled);
3451object? continuationObject = Interlocked.Exchange(ref m_continuationObject, s_taskCompletionSentinel);
4569oldValue = Interlocked.CompareExchange(ref m_continuationObject, list, expected);
4626if ((m_continuationObject != null) || (Interlocked.CompareExchange(ref m_continuationObject, tc, null) != null))
4650continuationsLocalRef = Interlocked.CompareExchange(ref m_continuationObject, new List<object?>(), continuationObject);
5145if (Interlocked.Decrement(ref _count) == 0) Set();
6101object? failedOrCanceled = Interlocked.CompareExchange(ref m_stateObject, completedTask, null);
6120failedOrCanceled = Interlocked.CompareExchange(ref m_stateObject, new List<Task> { first, completedTask }, first);
6134if (Interlocked.Decrement(ref _remainingToComplete) == 0)
6421if (Interlocked.Decrement(ref m_count) == 0)
6653if ((task1 = Interlocked.Exchange(ref _task1, null)) != null)
6915public bool TryStart() => Interlocked.Exchange(ref _enumerated, 1) == 0;
src\libraries\System.Private.CoreLib\src\System\Threading\ThreadPoolWorkQueue.cs (19)
41if (Interlocked.CompareExchange(ref s_queues, newQueues, oldQueues) == oldQueues)
81if (Interlocked.CompareExchange(ref s_queues, newQueues, oldQueues) == oldQueues)
265Interlocked.Exchange(ref m_tailIndex, tail);
331Interlocked.Exchange(ref m_headIndex, head + 1);
613if (Interlocked.Exchange(
743workItem = Interlocked.Exchange(ref _nextWorkItemToProcess, null);
762Interlocked.CompareExchange(ref _mayHaveHighPriorityWorkItems, false, true) &&
933Interlocked.MemoryBarrier();
938workItem = Interlocked.Exchange(ref workQueue._nextWorkItemToProcess, null);
970Interlocked.CompareExchange(
990Interlocked.MemoryBarrier();
1002Interlocked.MemoryBarrier();
1028Interlocked.CompareExchange(
1319if (Interlocked.Exchange(
1340Interlocked.CompareExchange(
1367Interlocked.MemoryBarrier();
1378Interlocked.CompareExchange(
1443Interlocked.MemoryBarrier(); // ensure that an old cached value is not read below
1452Debug.Assert(!Interlocked.Exchange(ref _executed, true), "A QueueUserWorkItemCallback was called twice!");
src\System\RuntimeType.GenericCache.cs (6)
106if (Interlocked.CompareExchange(ref genericCache, newEntry, existing) == existing)
119if (Interlocked.CompareExchange(ref genericCache, compositeCache, existing) != existing)
124if (Interlocked.CompareExchange(ref TCache.GetStorageRef(compositeCache), newEntry, existingEntry) == existingEntry)
142if (Interlocked.CompareExchange(ref genericCache, newEntry, null) == null)
155if (Interlocked.CompareExchange(ref genericCache, compositeCache, existing) != existing)
161TCache? currentEntry = Interlocked.CompareExchange(ref TCache.GetStorageRef(compositeCache), newEntry, null);
System.Private.DataContractSerialization (19)
System.Private.Uri (6)
System.Private.Windows.Core (2)
System.Private.Xml (8)
System.Private.Xml.Linq (12)
System.Reflection.DispatchProxy (1)
System.Reflection.Metadata (18)
System.Reflection.MetadataLoadContext (7)
System.Runtime.Caching (28)
System.Runtime.InteropServices (3)
System.Security.Cryptography (9)
System.Security.Cryptography.Pkcs (2)
System.ServiceModel.Syndication (1)
System.ServiceModel.UnixDomainSocket (2)
System.Text.Encoding.CodePages (4)
System.Text.Json (15)
System.Text.RegularExpressions (14)
System.Text.RegularExpressions.Generator (2)
System.Threading (26)
System\Threading\ReaderWriterLock.cs (21)
49_lockID = Interlocked.Increment(ref s_mostRecentLockID);
85if (Interlocked.CompareExchange(ref _state, LockStates.Reader, 0) == 0)
132currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.Reader, knownState);
186currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.WaitingReader, knownState);
215knownState = Interlocked.Add(ref _state, modifyState) - modifyState;
241Interlocked.Add(ref _state, LockStates.Reader - LockStates.ReaderSignaled);
264Interlocked.Add(ref _state, -LockStates.ReaderSignaled);
287if (Interlocked.CompareExchange(ref _state, LockStates.Writer, 0) == 0)
313currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.Writer, knownState);
356currentState = Interlocked.CompareExchange(ref _state, knownState + LockStates.WaitingWriter, knownState);
380knownState = Interlocked.Add(ref _state, modifyState) - modifyState;
407knownState = Interlocked.Add(ref _state, modifyState) - modifyState;
533currentState = Interlocked.CompareExchange(ref _state, knownState + modifyState, knownState);
641currentState = Interlocked.CompareExchange(ref _state, knownState + modifyState, knownState);
702int knownState = Interlocked.CompareExchange(ref _state, LockStates.Writer, LockStates.Reader);
811currentState = Interlocked.CompareExchange(ref _state, knownState + modifyState, knownState);
941if (Interlocked.CompareExchange(ref _state, LockStates.Writer, 0) == 0)
958Interlocked.CompareExchange(ref _state, knownState + LockStates.Reader, knownState) == knownState)
1026ManualResetEventSlim? previousEvent = Interlocked.CompareExchange(ref _readerEvent, currentEvent, null);
1047AutoResetEvent? previousEvent = Interlocked.CompareExchange(ref _writerEvent, currentEvent, null);
1099Interlocked.Add(ref _state, -LockStates.CachingEvents);
System.Threading.Channels (4)
System.Threading.RateLimiting (51)
System.Threading.Tasks.Dataflow (17)
Base\DataflowBlock.cs (6)
574Interlocked.CompareExchange(ref source._cancellationState, CANCELLATION_STATE_COMPLETING, CANCELLATION_STATE_REGISTERED) == CANCELLATION_STATE_REGISTERED)
673Interlocked.CompareExchange(ref _cancellationState, CANCELLATION_STATE_COMPLETING, curState) == curState))
700Interlocked.CompareExchange(ref _cancellationState, CANCELLATION_STATE_RESERVED, CANCELLATION_STATE_REGISTERED) == CANCELLATION_STATE_REGISTERED);
722if (Interlocked.CompareExchange(ref _cancellationState, CANCELLATION_STATE_REGISTERED, CANCELLATION_STATE_RESERVED) != CANCELLATION_STATE_RESERVED)
1119IDisposable? disposableUnlink = Interlocked.CompareExchange<IDisposable?>(ref target._unlink, null, unlink);
1270IDisposable? disposableUnlink = Interlocked.CompareExchange(ref _unlink, null, unlink);
System.Threading.Tasks.Parallel (15)
System.Transactions.Local (29)
System.Windows.Forms (5)
System.Windows.Forms.Primitives (4)
System.Xaml (19)
System\Xaml\XamlSchemaContext.cs (10)
357Interlocked.CompareExchange(ref _xmlNsCompatDict, CreateDictionary<string, string>(), null);
482Interlocked.CompareExchange(ref _masterBracketCharacterCache, CreateDictionary<XamlType, Dictionary<string, SpecialBracketCharacters>>(), null);
493Interlocked.CompareExchange(ref _masterTypeList, CreateDictionary<Type, XamlType>(ReferenceEqualityComparer.Instance), null);
504Interlocked.CompareExchange(ref _masterValueConverterList, CreateDictionary<ReferenceEqualityTuple<Type, XamlType, Type>, object>(), null);
515Interlocked.CompareExchange(ref _masterMemberList, CreateDictionary<ReferenceEqualityTuple<MemberInfo, MemberInfo>, XamlMember>(), null);
704Interlocked.CompareExchange(ref _xmlnsInfo, CreateDictionary<Assembly, XmlNsInfo>(ReferenceEqualityComparer.Instance), null);
715Interlocked.CompareExchange(ref _xmlnsInfoForDynamicAssemblies, CreateDictionary<WeakRefKey, XmlNsInfo>(), null);
727Interlocked.CompareExchange(ref _namespaceByUriList, CreateDictionary<string, XamlNamespace>(), null);
742Interlocked.CompareExchange(ref _xmlnsInfoForUnreferencedAssemblies, CreateDictionary<Assembly, XmlNsInfo>(ReferenceEqualityComparer.Instance), null);
1238Interlocked.CompareExchange(ref _referenceAssemblyNames, asmNames, null);
UnitTests.Common (2)