diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2019-08-26 07:22:19 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2019-08-26 07:22:19 +0000 |
commit | 342e8e9753386b3e3e3d9a823723df63b8971308 (patch) | |
tree | 27969ec412e91fce6d2d27bdf09522c35bc624cf /vespalib | |
parent | 78133f8c95b11b460aa4fd9ad89bd00bb716c6f8 (diff) |
Avoid calling time(nullptr)
Diffstat (limited to 'vespalib')
-rw-r--r-- | vespalib/src/vespa/vespalib/util/random.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/vespalib/src/vespa/vespalib/util/random.cpp b/vespalib/src/vespa/vespalib/util/random.cpp index 0f29e398ca6..50ff41e3407 100644 --- a/vespalib/src/vespa/vespalib/util/random.cpp +++ b/vespalib/src/vespa/vespalib/util/random.cpp @@ -5,6 +5,7 @@ #include <cstring> #include <ctime> #include <unistd.h> +#include <chrono> namespace vespalib { @@ -30,7 +31,7 @@ RandomGen::RandomGen() : _state(0) { unsigned long seed = getpid(); - seed ^= time(0); + seed ^= std::chrono::duration_cast<std::chrono::nanoseconds>(std::chrono::steady_clock::now().time_since_epoch()).count(); char hn[32]; memset(hn, 0, sizeof(hn)); gethostname(hn, 32); |