Template Function sequant::fetch_and_increment

Function Documentation

template<std::integral T>
T sequant::fetch_and_increment(std::atomic<T> &atomic, T increment = 1)

Takes in the given atomic counter, fetches the current value and increments it by the specified amount. This is done in a thread-safe manner that prevents data races and hence it is guaranteed that the returned value will be unique across all threads of the program.