Added option to be deterministic
This commit is contained in:
parent
29a913843a
commit
b26ba9ea90
@ -55,33 +55,37 @@ namespace FastRng.Double
|
||||
var ticks = now.Ticks;
|
||||
this.mW = (uint) (ticks >> 16);
|
||||
this.mZ = (uint) (ticks % 4294967296);
|
||||
this.StartProducerThreads();
|
||||
this.StartProducerThreads(deterministic: false);
|
||||
}
|
||||
|
||||
public MultiThreadedRng(uint seedU)
|
||||
{
|
||||
this.mW = seedU;
|
||||
this.mZ = 362436069;
|
||||
this.StartProducerThreads();
|
||||
this.StartProducerThreads(deterministic: true);
|
||||
}
|
||||
|
||||
public MultiThreadedRng(uint seedU, uint seedV)
|
||||
{
|
||||
this.mW = seedU;
|
||||
this.mZ = seedV;
|
||||
this.StartProducerThreads();
|
||||
this.StartProducerThreads(deterministic: true);
|
||||
}
|
||||
|
||||
private void StartProducerThreads()
|
||||
private void StartProducerThreads(bool deterministic = false)
|
||||
{
|
||||
this.producerRandomUint[0] = new Thread(() => this.RandomProducerUint(this.channelRandomUint.Writer, this.producerTokenSource.Token)) {IsBackground = true};
|
||||
this.producerRandomUint[1] = new Thread(() => this.RandomProducerUint(this.channelRandomUint.Writer, this.producerTokenSource.Token)) {IsBackground = true};
|
||||
this.producerRandomUint[0].Start();
|
||||
|
||||
if(!deterministic)
|
||||
this.producerRandomUint[1].Start();
|
||||
|
||||
this.producerRandomUniformDistributedDouble[0] = new Thread(() => this.RandomProducerUniformDistributedDouble(this.channelRandomUint.Reader, channelRandomUniformDistributedDouble.Writer, this.producerTokenSource.Token)) {IsBackground = true};
|
||||
this.producerRandomUniformDistributedDouble[1] = new Thread(() => this.RandomProducerUniformDistributedDouble(this.channelRandomUint.Reader, channelRandomUniformDistributedDouble.Writer, this.producerTokenSource.Token)) {IsBackground = true};
|
||||
this.producerRandomUniformDistributedDouble[0].Start();
|
||||
|
||||
if(!deterministic)
|
||||
this.producerRandomUniformDistributedDouble[1].Start();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user