f4b6a3 / uuid-creator

UUID Creator is a Java library for generating Universally Unique Identifiers.
MIT License
431 stars 44 forks source link

Change the DefaultTimestampStrategy to calculate the elapsed time between calls #28

Closed fabiolimace closed 3 years ago

fabiolimace commented 3 years ago

Currently whenever a new time-based UUID is requested, the counter is incremented by one. After the change the counter will accumulate the elapsed time between calls.

fabiolimace commented 3 years ago

Version 3.2.0 released.

fabiolimace commented 3 years ago

Until version 3.1.3, DefaultTimestampStrategy used a counter to fill the lower bits of the timestamp. The counter was incremented by 1 when the method was invoked in the same millisecond. Now this work is done by an accumulator that is increased at each repetition with different values.

Whenever the method is invoked in the same millisecond, the elapsed ticks are added to the accumulator, that is, the 100-nsec interval count since the last call. The method's return is the current milliseconds plus the accumulator value.

TIMESTAMP = MILLISECONDS * 10000 + ACCUMULATOR;

Version 3.2.1 released.

fabiolimace commented 3 years ago

Version 3.2.2 released.