I have many thread processing events. I want to assign a nanosecond timestamp for each event. However, this must be a unique identifier. Thus, in the odd case, when two events arrive so that they will be assigned the same timestamp, I want one of them to be increased by one nanosecond. Given that real accuracy is not at the nanosecond level, this is good as far as the nature of the system’s temporary system.
In one thread, this is a trivial problem. But after a few threads, it gets more complicated. Performance is absolutely important, so the idea of naive synchronization on a typical type of type of identifier generator seems to block too much.
Is there any approach that resolves this with minimal or no blockage?
source share