Skip to content

Commit

Permalink
Switch back to Interlocked.Exchange.
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeBlanch committed Feb 16, 2024
1 parent c9cfe4e commit c4c12ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/OpenTelemetry/Metrics/MetricPointOptionalComponents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public MetricPointOptionalComponents Copy()
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void AcquireLock()
{
if (Interlocked.CompareExchange(ref this.isCriticalSectionOccupied, 1, 0) != 0)
if (Interlocked.Exchange(ref this.isCriticalSectionOccupied, 1) != 0)
{
this.AcquireLockRare();
}
Expand All @@ -64,6 +64,6 @@ private void AcquireLockRare()
{
sw.SpinOnce();
}
while (Interlocked.CompareExchange(ref this.isCriticalSectionOccupied, 1, 0) != 0);
while (Interlocked.Exchange(ref this.isCriticalSectionOccupied, 1) != 0);
}
}

0 comments on commit c4c12ec

Please sign in to comment.