Table of Contents

Class RandomStreamFactoryState

Namespace
Mrg32k3a.NET
Assembly
Mrg32k3a.NET.dll

A transferable snapshot of everything a RandomStreamFactory needs in order to resume: its seed, and how many streams it has already handed out.

public sealed class RandomStreamFactoryState
Inheritance
RandomStreamFactoryState
Inherited Members

Remarks

The type is a plain mutable object with a parameterless constructor and public properties, so any general purpose serializer can handle it. The library deliberately takes no serialization dependency, which means the property names are used verbatim unless the caller applies a naming policy of their own.

Saving a run means saving this snapshot as well as the streams the factory has handed out. Without it a reloaded run starts its factory over at the first stream, which hands out streams that are already in use and gives two workers the same values.

Version identifies the shape of the snapshot. FromState(RandomStreamFactoryState) accepts only CurrentVersion and rejects every other value.

Fields

CurrentVersion

The snapshot version this build writes.

public const int CurrentVersion = 1

Field Value

int

Properties

CreatedStreamCount

Gets or sets the number of streams the factory has handed out.

public long CreatedStreamCount { get; set; }

Property Value

long

Remarks

It is a count rather than an index, so the restored factory's next stream is the one at this position in its ordering, the same one CreateStreamAt(long, string?) builds for this value.

Seed

Gets or sets the seed of the factory, six unsigned integers.

public uint[] Seed { get; set; }

Property Value

uint[]

Remarks

This is the start of the factory's first stream, not of its next one. The default is six zeros, which breaks the seed rules and is rejected, so a snapshot has to be filled in before it can be restored.

Version

Gets or sets the snapshot version.

public int Version { get; set; }

Property Value

int