Commit 16837f09 authored by Maged Michael's avatar Maged Michael Committed by Facebook GitHub Bot

hazptr: Improve readability, specialize friends, use specialized aliases

Summary: Use aliases. Reduce the use of the Atom template parameter.

Reviewed By: yfeldblum

Differential Revision: D29206490

fbshipit-source-id: d0637593c48ef150560b4feb47a454afe25ecba6
parent bb47922f
...@@ -81,26 +81,25 @@ namespace folly { ...@@ -81,26 +81,25 @@ namespace folly {
*/ */
template <template <typename> class Atom> template <template <typename> class Atom>
class hazptr_obj { class hazptr_obj {
using ReclaimFnPtr = void (*)(hazptr_obj<Atom>*, hazptr_obj_list<Atom>&); using Obj = hazptr_obj<Atom>;
using ObjList = hazptr_obj_list<Atom>;
using ReclaimFnPtr = void (*)(Obj*, ObjList&);
template <template <typename> class> friend class hazptr_domain<Atom>;
friend class hazptr_domain;
template <typename, template <typename> class, typename> template <typename, template <typename> class, typename>
friend class hazptr_obj_base; friend class hazptr_obj_base;
template <typename, template <typename> class, typename> template <typename, template <typename> class, typename>
friend class hazptr_obj_base_linked; friend class hazptr_obj_base_linked;
template <template <typename> class> friend class hazptr_obj_list<Atom>;
friend class hazptr_obj_list; friend class hazptr_priv<Atom>;
template <template <typename> class> friend class hazptr_detail::linked_list<Obj>;
friend class hazptr_priv; friend class hazptr_detail::shared_head_only_list<Obj, Atom>;
friend class hazptr_detail::linked_list<hazptr_obj<Atom>>; friend class hazptr_detail::shared_head_tail_list<Obj, Atom>;
friend class hazptr_detail::shared_head_only_list<hazptr_obj<Atom>, Atom>;
friend class hazptr_detail::shared_head_tail_list<hazptr_obj<Atom>, Atom>;
static constexpr uintptr_t kTagBit = 1u; static constexpr uintptr_t kTagBit = 1u;
ReclaimFnPtr reclaim_; ReclaimFnPtr reclaim_;
hazptr_obj<Atom>* next_; Obj* next_;
uintptr_t cohort_tag_; uintptr_t cohort_tag_;
public: public:
...@@ -111,19 +110,15 @@ class hazptr_obj { ...@@ -111,19 +110,15 @@ class hazptr_obj {
hazptr_obj() noexcept : next_(this), cohort_tag_(0) {} hazptr_obj() noexcept : next_(this), cohort_tag_(0) {}
hazptr_obj(const hazptr_obj<Atom>& o) noexcept hazptr_obj(const Obj& o) noexcept : next_(this), cohort_tag_(o.cohort_tag_) {}
: next_(this), cohort_tag_(o.cohort_tag_) {}
hazptr_obj(hazptr_obj<Atom>&& o) noexcept hazptr_obj(Obj&& o) noexcept : next_(this), cohort_tag_(o.cohort_tag_) {}
: next_(this), cohort_tag_(o.cohort_tag_) {}
/** Copy operator */ /** Copy operator */
hazptr_obj<Atom>& operator=(const hazptr_obj<Atom>&) noexcept { Obj& operator=(const Obj&) noexcept { return *this; }
return *this;
}
/** Move operator */ /** Move operator */
hazptr_obj<Atom>& operator=(hazptr_obj<Atom>&&) noexcept { return *this; } Obj& operator=(Obj&&) noexcept { return *this; }
/** cohort_tag */ /** cohort_tag */
uintptr_t cohort_tag() { return cohort_tag_; } uintptr_t cohort_tag() { return cohort_tag_; }
...@@ -157,9 +152,9 @@ class hazptr_obj { ...@@ -157,9 +152,9 @@ class hazptr_obj {
friend class hazptr_obj_cohort<Atom>; friend class hazptr_obj_cohort<Atom>;
friend class hazptr_priv<Atom>; friend class hazptr_priv<Atom>;
hazptr_obj<Atom>* next() const noexcept { return next_; } Obj* next() const noexcept { return next_; }
void set_next(hazptr_obj* obj) noexcept { next_ = obj; } void set_next(Obj* obj) noexcept { next_ = obj; }
ReclaimFnPtr reclaim() noexcept { return reclaim_; } ReclaimFnPtr reclaim() noexcept { return reclaim_; }
...@@ -371,7 +366,7 @@ class hazptr_obj_cohort { ...@@ -371,7 +366,7 @@ class hazptr_obj_cohort {
} }
/** reclaim_list */ /** reclaim_list */
void reclaim_list(hazptr_obj<Atom>* obj) { void reclaim_list(Obj* obj) {
while (obj) { while (obj) {
hazptr_obj_list<Atom> children; hazptr_obj_list<Atom> children;
while (obj) { while (obj) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment