Make misc:unique_timestamp not overflow microsecond part.

This should fix issue #2860
This commit is contained in:
Paweł Chmielowski 2019-04-16 10:24:28 +02:00
parent c96a925fde
commit 3706e35b86
1 changed files with 3 additions and 2 deletions

View File

@ -483,5 +483,6 @@ get_dir(Type) ->
%% Generates erlang:timestamp() that is guaranteed to unique
-spec unique_timestamp() -> erlang:timestamp().
unique_timestamp() ->
{MS, S, _} = erlang:timestamp(),
{MS, S, erlang:unique_integer([positive, monotonic])}.
Time = erlang:system_time(microsecond),
UI = erlang:unique_integer([positive, monotonic]),
usec_to_now(Time + UI).