martinus / robin-hood-hashing

Fast & memory efficient hashtable based on robin hood hashing for C++11/14/17/20
https://gitter.im/martinus/robin-hood-hashing
MIT License
1.5k stars 142 forks source link

Questions about Thread Safety #104

Closed symisc closed 3 years ago

symisc commented 3 years ago

Hi,

Does robin-hood works fine with multiple, concurrent readers threads and a single writer thread, all synchronized by std::shared_lock mutex?

martinus commented 3 years ago

Yes, this should work. All const operations are threadsafe can be called in parallel, but no concurrent non-const method must be called.

symisc commented 3 years ago

so to resume: table.find() is thread safe while table['elem'] = 'val' is not?

martinus commented 3 years ago

yes. Note that Iterators and refereces will be invalidated when you modify the table.