DiSMEC++
|
Local namespace in which we define the counter used to create the unique ids for the hash vector. More...
Functions | |
std::size_t | get_next_id () |
Get the next valid id. More... | |
Local namespace in which we define the counter used to create the unique ids for the hash vector.
we have two options here – either use an atomic counter, so that the results are consistent over all threads, and have the chance that next_id
is not lock-free and thus a potential performance problem, or use thread_local counters. Given that `std::atomic<std::size_t>? should be lock-free on all reasonably modern systems we run this code on, this is what we use.
std::size_t anonymous_namespace{hash_vector.cpp}::get_next_id | ( | ) |
Get the next valid id.
This increments the next_id and returns the old value, in an atomic fashion so that even when called from multiple threads, the return values will be unique.
The counter for the ids. We expect std::size_t
to have at least 64 bits, so that wrap-around is not an issue.
Definition at line 24 of file hash_vector.cpp.
Referenced by dismec::HashVector::update_id().