rlei / nonblockinghashmap

Non-blocking hash map in Rust
42 stars 4 forks source link

resize() needs to limit the threads that may try to allocate newkvs #6

Closed rlei closed 5 years ago

rlei commented 5 years ago

There may be multiple threads trying to call resize() and allocate their own new hash table (newkvs) before CAS it to the CHM._newkvs field, and only one will eventually succeed. Others allocation of the new (double sized) hash table will simply be a wasted effort.

The Java NBHM implementation limits the number of the threads that may try to allocate to 2. We should also port this.