~smspillaz/folly/folly-git-master

« back to all changes in this revision

Viewing changes to folly/synchronization/test/HazptrTest.cpp

  • Committer: Facebook Github Bot
  • Author(s): Maged Michael
  • Date: 2018-07-18 17:51:27 UTC
  • Revision ID: git-v1:bc809fb478378c4e6233a80cb75a36d14238447c
hazptr: Add function to reclaim linked objects without checking hazard pointers.

Summary:
Add unlink_and_reclaim member function to hazptr_obj_base_linked, as an alternative to unlink() that reclaims the object if its link count is zero without checking hazard pointers.
It is useful in destructors of data structures when it is guaranteed that objects are not protected by hazard pointers (e,.g., destructor of ConcurrentHashMap).

Reviewed By: yfeldblum

Differential Revision: D8864019

fbshipit-source-id: 618eeded45a1f8b9503569d1ceca9994ca6e317f

Show diffs side-by-side

added added

removed removed

Lines of Context:
300
300
    ++num;
301
301
    auto obj = new NodeRC<false, Atom>(0, nullptr);
302
302
    obj->acquire_link_safe();
 
303
    obj->unlink_and_reclaim_unchecked();
 
304
  }
 
305
  {
 
306
    ++num;
 
307
    auto obj = new NodeRC<false, Atom>(0, nullptr);
 
308
    obj->acquire_link_safe();
303
309
    hazptr_root<NodeRC<false, Atom>> root(obj);
304
310
  }
305
311
  ASSERT_EQ(c_.ctors(), num);