diff options
author | Thomas Habets <thomas@habets.se> | 2020-04-10 11:40:13 +0100 |
---|---|---|
committer | Marcus Müller <marcus@hostalia.de> | 2020-04-10 16:27:57 +0200 |
commit | 78955a24c6c24f92f7b22ab9223e8e0b60b1dc4b (patch) | |
tree | 09984db7dd2309ebfdb567f3fc3d8c72f42936a0 /gnuradio-runtime/lib | |
parent | 55b6b2724ae872b36dd93c1479a829bb4054bdda (diff) |
runtime: Use nanosecond resolution for default random seed
This exposed some missing forwarding of RNG seed from one object to
another, also fixed in this commit.
Diffstat (limited to 'gnuradio-runtime/lib')
-rw-r--r-- | gnuradio-runtime/lib/math/random.cc | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/gnuradio-runtime/lib/math/random.cc b/gnuradio-runtime/lib/math/random.cc index a25cc1c72e..8b67532207 100644 --- a/gnuradio-runtime/lib/math/random.cc +++ b/gnuradio-runtime/lib/math/random.cc @@ -30,6 +30,7 @@ #include <gnuradio/math.h> #include <gnuradio/random.h> +#include <chrono> #include <cmath> namespace gr { @@ -54,7 +55,9 @@ void random::reseed(unsigned int seed) { d_seed = seed; if (d_seed == 0) { - d_rng.seed(time(nullptr)); + auto now = std::chrono::system_clock::now().time_since_epoch(); + auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(now).count(); + d_rng.seed(ns); } else { d_rng.seed(d_seed); } |