in tso-server/src/main/java/org/apache/omid/tso/WorldClockOracleImpl.java [130:156]
public long next() {
long currentMsFirstTimestamp = System.currentTimeMillis() * MAX_TX_PER_MS;
lastTimestamp += CommitTable.MAX_CHECKPOINTS_PER_TXN;
// Return the next timestamp in case we are still in the same millisecond as the previous timestamp was.
if (lastTimestamp >= currentMsFirstTimestamp) {
return lastTimestamp;
}
if (currentMsFirstTimestamp >= maxTimestamp) { // Intentional race to reduce synchronization overhead in every access to maxTimestamp
while (maxAllocatedTime <= currentMsFirstTimestamp) { // Waiting for the interval allocation
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
continue;
}
}
assert (maxAllocatedTime > maxTimestamp);
maxTimestamp = maxAllocatedTime;
}
lastTimestamp = currentMsFirstTimestamp;
return lastTimestamp;
}