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
8 changes: 4 additions & 4 deletions IdGen/IdGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,12 @@ public bool TryCreateId(out long id)
/// <exception cref="SequenceOverflowException">Thrown when sequence overflows.</exception>
private long CreateIdImpl(out Exception exception)
{
// Determine "timeslot" and make sure it's >= last timeslot (if any)
var ticks = GetTicks();
var timestamp = ticks & MASK_TIME;

lock (_genlock)
{
// Determine "timeslot" and make sure it's >= last timeslot (if any)
var ticks = GetTicks();
var timestamp = ticks & MASK_TIME;

if (timestamp < _lastgen || ticks < 0)
{
exception = new InvalidSystemClockException($"Clock moved backwards or wrapped around. Refusing to generate id for {_lastgen - timestamp} ticks");
Expand Down