Skip to content

Commit 5c99511

Browse files
committed
make DisableCore local function
1 parent 830b1eb commit 5c99511

1 file changed

Lines changed: 15 additions & 16 deletions

File tree

tracer/src/Datadog.Trace/Debugger/RateLimiting/MemoryPressureMonitor.cs

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,21 @@ static int ToScaledInt(double value, int scale)
401401
var scaled = value * scale;
402402
return scaled >= int.MaxValue ? int.MaxValue : (int)scaled;
403403
}
404+
405+
bool DisableCore(MetricTags.DebuggerMemoryPressureDisabledReason reason)
406+
{
407+
if (IsDisposed() || IsDisabled())
408+
{
409+
return false;
410+
}
411+
412+
Volatile.Write(ref _disabled, 1);
413+
Volatile.Write(ref _isHighPressure, false);
414+
Volatile.Write(ref _currentMemoryUsagePercentTenths, 0);
415+
Volatile.Write(ref _gen2CollectionsPerSecondHundredths, 0);
416+
_onDisabled(reason);
417+
return true;
418+
}
404419
}
405420

406421
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@@ -409,22 +424,6 @@ private bool IsStale(long nowMs, long lastRefreshMs)
409424
return (nowMs - lastRefreshMs) >= _staleThresholdMs;
410425
}
411426

412-
// Only ever called from inside the CAS-guarded Refresh, so no synchronization is required.
413-
private bool DisableCore(MetricTags.DebuggerMemoryPressureDisabledReason reason)
414-
{
415-
if (IsDisposed() || IsDisabled())
416-
{
417-
return false;
418-
}
419-
420-
Volatile.Write(ref _disabled, 1);
421-
Volatile.Write(ref _isHighPressure, false);
422-
Volatile.Write(ref _currentMemoryUsagePercentTenths, 0);
423-
Volatile.Write(ref _gen2CollectionsPerSecondHundredths, 0);
424-
_onDisabled(reason);
425-
return true;
426-
}
427-
428427
[MethodImpl(MethodImplOptions.AggressiveInlining)]
429428
private bool IsDisposed()
430429
{

0 commit comments

Comments
 (0)