diff --git a/src/Polly.Core/Hedging/Controller/HedgingController.cs b/src/Polly.Core/Hedging/Controller/HedgingController.cs index a5da3210194..48310cb89f1 100644 --- a/src/Polly.Core/Hedging/Controller/HedgingController.cs +++ b/src/Polly.Core/Hedging/Controller/HedgingController.cs @@ -5,8 +5,8 @@ namespace Polly.Hedging.Utils; internal sealed class HedgingController { - private readonly IObjectPool _contextPool; - private readonly IObjectPool _executionPool; + private readonly ObjectPool _contextPool; + private readonly ObjectPool _executionPool; private int _rentedContexts; private int _rentedExecutions; diff --git a/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs b/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs index 9f4c747ca08..ac74c02c8ca 100644 --- a/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs +++ b/src/Polly.Core/Hedging/Controller/HedgingExecutionContext.cs @@ -20,14 +20,14 @@ internal sealed class HedgingExecutionContext private readonly List _tasks = new(); private readonly List _executingTasks = new(); - private readonly IObjectPool _executionPool; + private readonly ObjectPool _executionPool; private readonly TimeProvider _timeProvider; private readonly int _maxAttempts; private readonly Action _onReset; private readonly ResilienceProperties _replacedProperties = new(); public HedgingExecutionContext( - IObjectPool executionPool, + ObjectPool executionPool, TimeProvider timeProvider, int maxAttempts, Action onReset) diff --git a/src/Polly.Core/Utils/IObjectPool.cs b/src/Polly.Core/Utils/IObjectPool.cs deleted file mode 100644 index 43cb038cb20..00000000000 --- a/src/Polly.Core/Utils/IObjectPool.cs +++ /dev/null @@ -1,23 +0,0 @@ -namespace Polly.Utils; - -#pragma warning disable CA1716 // Identifiers should not match keywords - -/// -/// Represents a pool of objects. -/// -/// The type of objects in the pool. -internal interface IObjectPool - where T : class -{ - /// - /// Gets an object from the pool. - /// - /// Object instance. - T Get(); - - /// - /// Returns an object to the pool. - /// - /// The object instance to return. - void Return(T obj); -} diff --git a/src/Polly.Core/Utils/ObjectPool.cs b/src/Polly.Core/Utils/ObjectPool.cs index bb735167be4..1c535a96e8f 100644 --- a/src/Polly.Core/Utils/ObjectPool.cs +++ b/src/Polly.Core/Utils/ObjectPool.cs @@ -5,7 +5,7 @@ namespace Polly.Utils; // copied from https://raw.githubusercontent.com/dotnet/aspnetcore/53124ab8cbf152f59120982f1c74e802e7970845/src/ObjectPool/src/DefaultObjectPool.cs -internal sealed class ObjectPool : IObjectPool +internal sealed class ObjectPool where T : class { internal static readonly int MaxCapacity = (Environment.ProcessorCount * 2) - 1; // the - 1 is to account for _fastItem