Resolve "Add possibility to get integers" #17

Merged
thorsten merged 8 commits from 9-add-possibility-to-get-integers into main 2024-05-29 09:40:29 +00:00
2 changed files with 8 additions and 1 deletions
Showing only changes of commit 8ade2f5a5d - Show all commits

View File

@ -4,6 +4,8 @@ using System.Numerics;
using System.Threading;
using System.Threading.Channels;
// ReSharper disable RedundantExtendsListEntry
namespace FastRng;
public sealed class MultiChannelRng<TNum> : IRandom<TNum>, IDisposable where TNum : IFloatingPointIeee754<TNum>, IAdditionOperators<TNum, TNum, TNum>

View File

@ -5,6 +5,8 @@ using System.Numerics;
using System.Threading;
using System.Threading.Tasks;
// ReSharper disable RedundantExtendsListEntry
namespace FastRng;
/// <summary>
@ -37,7 +39,10 @@ public sealed class MultiThreadedRng<TNum> : IRandom<TNum>, IDisposable where TN
private const int QUEUE_SIZE_INT = QUEUE_SIZE_FLOAT * 2;
private static readonly TNum CONST_FLOAT_CONVERSION = TNum.CreateChecked(2.328306435454494e-10f);
// ReSharper disable StaticMemberInGenericType
private static readonly object LOCKER = new();
// ReSharper restore StaticMemberInGenericType
// Gets used to stop the producer threads:
private readonly CancellationTokenSource producerTokenSource = new();
@ -197,7 +202,7 @@ public sealed class MultiThreadedRng<TNum> : IRandom<TNum>, IDisposable where TN
while (!cancellationToken.IsCancellationRequested)
{
// A local source buffer of uints:
uint[] bufferSource = null;
uint[] bufferSource;
// Try to get the next source buffer:
while (!this.queueIntegers.TryDequeue(out bufferSource) && !cancellationToken.IsCancellationRequested)