setThreadLocalSeed

Sets or resets the _seed of threadLocal!Engine using the given arguments. It is not necessary to call this except if you wish to ensure the PRNG uses a known _seed.

  1. void setThreadLocalSeed(A seed)
    static if(THREAD_LOCAL_STORAGE_AVAILABLE)
    void
    setThreadLocalSeed
    (
    Engine
    A...
    )
    (
    auto ref A seed
    )
    if (
    is(Engine == struct)
    &&
    A.length >= 1
    &&
    is(typeof(
    (
    ref A a
    )
    => Engine(a)
    ))
    )
  2. template setThreadLocalSeed(T, A...)

Examples

import mir.random;

alias rnd = threadLocal!Random;

setThreadLocalSeed!Random(123);
immutable float x = rnd.rand!float;

assert(x != rnd.rand!float);

setThreadLocalSeed!Random(123);
immutable float y = rnd.rand!float;

assert(x == y);

Meta