File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -262,20 +262,9 @@ uint64_t UuidGen::monotonic_timestamp() {
262262 while (true ) {
263263 uint64_t now = from_unix_timestamp (get_time_since_epoch_ms ());
264264 uint64_t last = last_timestamp_.load ();
265- if (now > last) {
266- if (last_timestamp_.compare_exchange_strong (last, now)) {
267- return now;
268- }
269- } else {
270- uint64_t last_ms = to_milliseconds (last);
271- if (to_milliseconds (now) < last_ms) {
272- return last_timestamp_.fetch_add (1 );
273- }
274- uint64_t candidate = last + 1 ;
275- if (to_milliseconds (candidate) == last_ms &&
276- last_timestamp_.compare_exchange_strong (last, candidate)) {
277- return candidate;
278- }
265+ uint64_t candidate = (now > last) ? now : last + 1 ;
266+ if (last_timestamp_.compare_exchange_strong (last, candidate)) {
267+ return candidate;
279268 }
280269 }
281270}
You can’t perform that action at this time.
0 commit comments