| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- // Licensed to the .NET Foundation under one or more agreements.
- // The .NET Foundation licenses this file to you under the MIT license.
- // See the LICENSE file in the project root for more information.
- using System.Diagnostics;
- namespace System.Runtime
- {
- public enum GCLargeObjectHeapCompactionMode
- {
- Default = 1,
- CompactOnce = 2
- }
- // These settings are the same format as in the GC in the runtime.
- public enum GCLatencyMode
- {
- Batch = 0,
- Interactive = 1,
- LowLatency = 2,
- SustainedLowLatency = 3,
- NoGCRegion = 4
- }
- public static partial class GCSettings
- {
- private enum SetLatencyModeStatus
- {
- Succeeded = 0,
- NoGCInProgress = 1 // NoGCRegion is in progress, can't change pause mode.
- };
- public static GCLatencyMode LatencyMode
- {
- get => GetGCLatencyMode();
- set
- {
- if ((value < GCLatencyMode.Batch) ||
- (value > GCLatencyMode.SustainedLowLatency))
- {
- throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_Enum);
- }
- SetLatencyModeStatus status = SetGCLatencyMode(value);
- if (status == SetLatencyModeStatus.NoGCInProgress)
- {
- throw new InvalidOperationException(SR.InvalidOperation_SetLatencyModeNoGC);
- }
- Debug.Assert(status == SetLatencyModeStatus.Succeeded, $"Unexpected return value '{status}' from {nameof(SetGCLatencyMode)}.");
- }
- }
- public static GCLargeObjectHeapCompactionMode LargeObjectHeapCompactionMode
- {
- get => GetLOHCompactionMode();
- set
- {
- if ((value < GCLargeObjectHeapCompactionMode.Default) ||
- (value > GCLargeObjectHeapCompactionMode.CompactOnce))
- {
- throw new ArgumentOutOfRangeException(nameof(value), SR.ArgumentOutOfRange_Enum);
- }
- SetLOHCompactionMode(value);
- }
- }
- }
- }
|