Fix some memory_order parameters in AtomicHashMap
Summary: Herb Sutter noticed an error in the AHM find pseudo-code at the C++ conference, and the error is in the real implementation too. We should be using memory_order_acquire, because we need the load of the key to happen before any subsequent loads of the value itself. Our implementation is conservative for a memory_order_relaxed load (we generate the same code as if it were memory_order_acquire---i.e. a compiler barrier but no memory barriers), so this should not change the generated code. Correctness is a good idea, though (when we upgrade to gcc 4.7's atomics it might not be as conservative). Also, erase was doing three loads when one is enough. ... also fixes an exception safety bug in insert. (Phew.) Test Plan: Ran the AHM unit tests, debug and opt. Reviewed By: andrei.alexandrescu@fb.com FB internal diff: D485744
Showing
Please register or sign in to comment