Saturday, 24 August 2013

How to get a timestamp that is guaranteed to differ every time it's fetched?

How to get a timestamp that is guaranteed to differ every time it's fetched?

To generate global unique ids, I need something like a timestamp of their
creation. But those ids can be generate directly after each other in
source code. So the time with milliseconds isn't accurate enough and could
unintentionally produce equal ids.
Thefore I need a timestamp exact enough that it differs every time it is
fetched. I though about CPU cycles, but I don't know if there is a way to
get this information.

No comments:

Post a Comment