New ReadMostlySharedPtr implementation
authorAndrii Grynenko <andrii@fb.com>
Thu, 26 Nov 2015 04:03:55 +0000 (20:03 -0800)
committerfacebook-github-bot-4 <folly-bot@fb.com>
Thu, 26 Nov 2015 04:20:34 +0000 (20:20 -0800)
commit596aa8952f0afec207e876bd99dcb4f4841a9aef
tree86aa1507e14d066ba326dd76ae75a7838b6ff109
parent7ee590edb5176f7ab8dfe7c219b3512c4b00e03f
New ReadMostlySharedPtr implementation

Summary: This changes ReadMostlySharedPtr API to have 3 types: MainPtr, WeakPtr, SharedPtr. MainPtr and SharedPtr are equivalents of std::shared_ptr, and WeakPtr is an equivalent of std::weak_ptr. The only difference is that it can only be a single MainPtr, and while it's alive copying SharedPtr/WeakPtr or WeakPtr doesn't require atomic operations (and thus can be more performant than std::shared_ptr). Unlike original ReadMostlySharedPtr API, there're no thread-safety guarantees between reset() and getShared() for ReadMostlySharedPtr.

ReadMostlySharedPtr can work with different RefCount implementations. This diff introduces RCURefCount (which is currently using liburcu) and TLRefCount.

Reviewed By: djwatson

Differential Revision: D2683572

fb-gh-sync-id: a7a03af4b1cf5f81a613368c6eebe70b2eaef064
15 files changed:
folly/Makefile.am
folly/Random.cpp
folly/ReadMostlySharedPtr.h [deleted file]
folly/ThreadLocal.h
folly/experimental/RCURefCount.h [new file with mode: 0644]
folly/experimental/RCUUtils.cpp [new file with mode: 0644]
folly/experimental/RCUUtils.h [new file with mode: 0644]
folly/experimental/ReadMostlySharedPtr.h [new file with mode: 0644]
folly/experimental/TLRefCount.h [new file with mode: 0644]
folly/experimental/test/ReadMostlySharedPtrBenchmark.cpp [new file with mode: 0644]
folly/experimental/test/ReadMostlySharedPtrTest.cpp [new file with mode: 0644]
folly/experimental/test/RefCountBenchmark.cpp [new file with mode: 0644]
folly/experimental/test/RefCountTest.cpp [new file with mode: 0644]
folly/test/ReadMostlySharedPtrBenchmark.cpp [deleted file]
folly/test/ReadMostlySharedPtrTest.cpp [deleted file]