1
0
Fork 0

seed srand with current UUID timestamp

This commit is contained in:
Kevin Matz 2021-08-22 12:10:50 -04:00
parent 922deb81da
commit 00a32ea2f9
1 changed files with 1 additions and 2 deletions

View File

@ -28,7 +28,6 @@
#include <cstdlib>
#include <sstream>
#include <iomanip>
#include <ctime>
namespace UUID {
@ -380,7 +379,7 @@ uint16_t uuid::uuid1(uint64_t node, uint16_t clock_seq)
void uuid::uuid4() {
type_ = RFC4122;
version_ = RAND;
std::srand(std::time(nullptr));
std::srand(now_());
timestamp_ = std::rand();
timestamp_ |= (uint64_t)std::rand() << 32;
clock_seq_ = std::rand();