diff --git a/src/Microsoft.Extensions.ML/PredictionEnginePoolPolicy.cs b/src/Microsoft.Extensions.ML/PredictionEnginePoolPolicy.cs
index 1048ad10c8..7804af5158 100644
--- a/src/Microsoft.Extensions.ML/PredictionEnginePoolPolicy.cs
+++ b/src/Microsoft.Extensions.ML/PredictionEnginePoolPolicy.cs
@@ -2,26 +2,22 @@
// 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;
-using System.Collections.Generic;
-using System.Linq;
using Microsoft.Extensions.ObjectPool;
using Microsoft.ML;
namespace Microsoft.Extensions.ML
{
///
- /// for
+ /// for
/// which is responsible for creating pooled objects, and when to return objects to the pool.
///
internal class PredictionEnginePoolPolicy
- : IPooledObjectPolicy>
+ : PooledObjectPolicy>
where TData : class
where TPrediction : class, new()
{
private readonly MLContext _mlContext;
private readonly ITransformer _model;
- private readonly List _references;
///
/// Initializes a new instance of .
@@ -34,21 +30,13 @@ public PredictionEnginePoolPolicy(MLContext mlContext, ITransformer model)
{
_mlContext = mlContext;
_model = model;
- _references = new List();
}
///
- public PredictionEngine Create()
- {
- var engine = _mlContext.Model.CreatePredictionEngine(_model);
- _references.Add(new WeakReference(engine));
- return engine;
- }
+ public override PredictionEngine Create() =>
+ _mlContext.Model.CreatePredictionEngine(_model);
///
- public bool Return(PredictionEngine obj)
- {
- return _references.Any(x => x.Target == obj);
- }
+ public override bool Return(PredictionEngine obj) => true;
}
}
\ No newline at end of file