Skip to content

Commit 0f1c909

Browse files
committed
fix(UUID): switch to Abseil random generator
1 parent dde82b6 commit 0f1c909

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/geode/basic/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ add_geode_library(
8080
Bitsery::bitsery
8181
PRIVATE_DEPENDENCIES
8282
Async++
83+
absl::random_random
8384
absl::time
8485
spdlog::spdlog_header_only
8586
MINIZIP::minizip-ng

src/geode/basic/uuid.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,10 @@
2424
#include <geode/basic/uuid.h>
2525

2626
#include <iomanip>
27-
#include <random>
2827
#include <sstream>
2928

29+
#include <absl/random/random.h>
30+
3031
namespace
3132
{
3233
size_t decode( char ch )
@@ -51,12 +52,12 @@ namespace geode
5152
{
5253
uuid::uuid()
5354
{
54-
static thread_local std::random_device rd;
55-
static thread_local std::uniform_int_distribution< uint64_t > dist(
55+
static thread_local absl::BitGen gen;
56+
static thread_local absl::uniform_int_distribution< uint64_t > dist(
5657
0u, ~0u );
5758

58-
ab = dist( rd );
59-
cd = dist( rd );
59+
ab = dist( gen );
60+
cd = dist( gen );
6061

6162
ab = ( ab & 0xFFFFFFFFFFFF0FFFULL ) | 0x0000000000004000ULL;
6263
cd = ( cd & 0x3FFFFFFFFFFFFFFFULL ) | 0x8000000000000000ULL;

0 commit comments

Comments
 (0)