RandomUtil
using System;
using System.Runtime.CompilerServices;
using System.Threading;
namespace Polly.Utils
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
internal sealed class RandomUtil
{
private readonly ThreadLocal<Random> _random;
public static readonly RandomUtil Instance = new RandomUtil(null);
public RandomUtil(int? seed)
{
_random = new ThreadLocal<Random>(delegate {
if (seed.HasValue)
return new Random(seed.Value);
return new Random();
});
}
public double NextDouble()
{
return _random.Value.NextDouble();
}
}
}