Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/geode/basic/uuid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,14 @@ namespace geode
{
uuid::uuid()
{
static constexpr index_t MAX_SAFETY_COUNT = 1000;
static constexpr absl::Duration INITIAL_SLEEP =
absl::Microseconds( 100 );
static constexpr absl::Duration MAX_SLEEP = absl::Milliseconds( 50 );
UUIDv7Generator gen;
bool generated{ false };
for( const auto i : Range{ 10 } )
auto sleep = INITIAL_SLEEP;
for( const auto i : Range{ MAX_SAFETY_COUNT } )
{
geode_unused( i );
if( auto bytes = gen.generate() )
Expand All @@ -250,6 +255,8 @@ namespace geode
generated = true;
break;
}
absl::SleepFor( sleep );
sleep = std::min( sleep * 2., MAX_SLEEP );
}
OPENGEODE_EXCEPTION( generated, "[uuid] could not generate uuid" );
}
Expand Down Expand Up @@ -316,4 +323,4 @@ namespace std
{
return absl::HashOf( uuid.bytes_ );
}
} // namespace std
} // namespace std