X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=blobdiff_plain;f=folly%2FConcurrentSkipList-inl.h;h=881d05350bb31b77794c5d097a423d20e1687502;hp=122f21c64789e381b288be87378b44e0b6988363;hb=6283c759b82a2a5764ef77c025aee1d40a77a839;hpb=41365ea66d92749ba78f73d60325e5447beb04ab diff --git a/folly/ConcurrentSkipList-inl.h b/folly/ConcurrentSkipList-inl.h index 122f21c6..881d0535 100644 --- a/folly/ConcurrentSkipList-inl.h +++ b/folly/ConcurrentSkipList-inl.h @@ -26,6 +26,7 @@ #include #include #include + #include #include #include @@ -37,9 +38,9 @@ namespace folly { namespace detail { -template class csl_iterator; +template class csl_iterator; -template +template class SkipListNode : private boost::noncopyable { enum : uint16_t { IS_HEAD_NODE = 1, @@ -50,8 +51,11 @@ class SkipListNode : private boost::noncopyable { public: typedef T value_type; - template::value>::type> + template < + typename NodeAlloc, + typename U, + typename = + typename std::enable_if::value>::type> static SkipListNode* create( NodeAlloc& alloc, int height, U&& data, bool isHead = false) { DCHECK(height >= 1 && height < 64) << height; @@ -64,13 +68,13 @@ class SkipListNode : private boost::noncopyable { return node; } - template + template static void destroy(NodeAlloc& alloc, SkipListNode* node) { node->~SkipListNode(); alloc.deallocate(node); } - template + template struct DestroyIsNoOp : std::integral_constant::value && boost::has_trivial_destructor::value> { }; @@ -129,12 +133,14 @@ class SkipListNode : private boost::noncopyable { private: // Note! this can only be called from create() as a placement new. - template + template SkipListNode(uint8_t height, U&& data, bool isHead) : height_(height), data_(std::forward(data)) { spinLock_.init(); setFlags(0); - if (isHead) setIsHeadNode(); + if (isHead) { + setIsHeadNode(); + } // need to explicitly init the dynamic atomic pointer array for (uint8_t i = 0; i < height_; ++i) { new (&skip_[i]) std::atomic(nullptr); @@ -225,10 +231,10 @@ class SkipListRandomHeight { size_t sizeLimitTable_[kMaxHeight]; }; -template +template class NodeRecycler; -template +template class NodeRecycler::value>::type> { public: @@ -249,7 +255,7 @@ class NodeRecycler g(lock_); if (nodes_.get() == nullptr) { - nodes_.reset(new std::vector(1, node)); + nodes_ = std::make_unique>(1, node); } else { nodes_->push_back(node); } @@ -314,7 +320,7 @@ class NodeRecycler +template class NodeRecycler::value>::type> { public: @@ -331,4 +337,5 @@ class NodeRecycler