unordered_base: Improve reliability by stotko · Pull Request #25 · stotko/stdgpu (original) (raw)
In case of inserting the same value multiple times in parallel (see unit test), this operation may be performed more than once which leads to duplicates within the container. Although the actual insertion process is already properly guarded by a lock and double-check mechanism, speculation and cache issues due to operation reordering may occur and make a thread believe that the value is not yet inserted (value and link set, but occupancy status still unset). Workaround this by updating the link to the newly created values after its occupancy status has been set.
Furthermore, revert the loop timeout workaround (#3) and replace it back to a while loop.