Skip to content

NextId Method ​

Definition ​

  • Namespace: JASE
  • Assembly: JASE.IdGenerator.dll

long NextId() ​

csharp
long NextId()

Generates the next ordered identifier.

Returns ​

A 64-bit identifier composed as:


(timestampRelMs << 22) | (nodeId << 12) | sequence

Remarks ​

The returned value uses the following layout (most-significant to least-significant):


┌─────────────────────────────────────┬─────────────────┬─────────────────┐
│ Timestamp (41 bits, ms since epoch) │ Node (10 bits)  │ Seq (12 bits)   │
└─────────────────────────────────────┴─────────────────┴─────────────────┘

In WallClock, generation may block if the system clock moves backwards or if more than 4096 IDs are requested within the same millisecond.

In LogicalClock, generation avoids blocking by advancing a bounded logical timestamp; decoded timestamps may be slightly ahead of real UTC time.