ConcurrentHashMap: Use synchronization/hazptr and hazptr_obj_base_linked
Summary: - Use the hazard pointer library under folly/synchronization. - NodeT derived from hazptr_obj_base_linked. - Bucket heads are hazptr_root-s with dtor that automatically unlinks nodes - Provides support for uncertain removal of NodeT-s both from NodeT and Buckets - As intended, hazptr_cleanup reclaims all unprotected removed objects even if they have not been determined to be retirable at the start of cleanup. Fixes the following: - The pattern of calling h.get_protected(node->next_), when hazptr_holder h is protecting node is unsafe because try_protect (inside get_protected) may fail and we end protecting neither node nor next. This diff uses a different hazptr_holder to protect the next node. A correct pattern is to call h2.get_protected(node->next_) then h.swap(h2); h2.reset(); - The pattern of calling h2.reset(node) then h1.reset() to continue protecting a node already protected by h1 is unsafe because h2's protection may be too late after node was retired. A correct pattern is h2.swap(h1). Reviewed By: djwatson Differential Revision: D7708325 fbshipit-source-id: 617dcfe19410071888abafa32f0e1ada9d123983
Showing
Please register or sign in to comment