| 238 | namespace geode |
| 239 | { |
| 240 | uuid::uuid() |
| 241 | { |
| 242 | static constexpr index_t MAX_SAFETY_COUNT = 1000; |
| 243 | static constexpr absl::Duration INITIAL_SLEEP = |
| 244 | absl::Microseconds( 100 ); |
| 245 | static constexpr absl::Duration MAX_SLEEP = absl::Milliseconds( 50 ); |
| 246 | UUIDv7Generator gen; |
| 247 | bool generated{ false }; |
| 248 | auto sleep = INITIAL_SLEEP; |
| 249 | for( const auto i : Range{ MAX_SAFETY_COUNT } ) |
| 250 | { |
| 251 | geode_unused( i ); |
| 252 | if( auto bytes = gen.generate() ) |
| 253 | { |
| 254 | bytes_ = bytes.value(); |
| 255 | generated = true; |
| 256 | break; |
| 257 | } |
| 258 | absl::SleepFor( sleep ); |
| 259 | sleep = std::min( sleep * 2., MAX_SLEEP ); |
| 260 | } |
| 261 | OpenGeodeBasicException::check_exception( generated, nullptr, |
| 262 | OpenGeodeException::TYPE::internal, |
| 263 | "[uuid] could not generate uuid" ); |
| 264 | } |
| 265 | |
| 266 | uuid::uuid( std::string_view string ) |
| 267 | { |
no test coverage detected