2 ms·
Cool: erlang:unique_integer([monotonic]) I wish this was a more common API function. Being able to do ordering without having to think about time and conc
by skrebbel 12y ago
Cool:
erlang:unique_integer([monotonic])
I wish this was a more common API function. Being able to do ordering without having to think about time and concurrency is really nice (I know x86 has an interlocked increment that you could just use on an arbitrary global variable, but that means that you're not safe across crashes).
- MCRed 12y agoThis is elixir, but can be called from erlang: https://github.com/nirvana/flaky/ https://github.com/nirvana/flaky/ It gives a unique value from any node in a cluster of nodes running this-- without any coordination-- such that you can guarantee they are sortable in order of creation. (to a small increment of fungibility-- two flakes created on different nodes in the same millisecond might be out of order, but they will be unique and in order with any flakes created in other milliseconds.)