Commit 42c52025 authored by Christopher Dykes's avatar Christopher Dykes Committed by Facebook Github Bot

Get ConcurrentSkipList functional

Summary:
MSVC was getting thoroughly confused while trying to eval the constexpr function, so switch it to a template instead.
MSVC was also failing to wrap it's head around what a NodeRecycler is, so delay its resolution via typename.

Reviewed By: yfeldblum

Differential Revision: D3478755

fbshipit-source-id: f687f4538fb12ef8eee525557f4cc988a09e714d
parent 047e9e39
...@@ -70,10 +70,9 @@ class SkipListNode : private boost::noncopyable { ...@@ -70,10 +70,9 @@ class SkipListNode : private boost::noncopyable {
} }
template<typename NodeAlloc> template<typename NodeAlloc>
static constexpr bool destroyIsNoOp() { struct DestroyIsNoOp : std::integral_constant<bool,
return IsArenaAllocator<NodeAlloc>::value && IsArenaAllocator<NodeAlloc>::value &&
boost::has_trivial_destructor<SkipListNode>::value; boost::has_trivial_destructor<SkipListNode>::value> { };
}
// copy the head node to a new head node assuming lock acquired // copy the head node to a new head node assuming lock acquired
SkipListNode* copyHead(SkipListNode* node) { SkipListNode* copyHead(SkipListNode* node) {
...@@ -230,7 +229,7 @@ class NodeRecycler; ...@@ -230,7 +229,7 @@ class NodeRecycler;
template<typename NodeType, typename NodeAlloc> template<typename NodeType, typename NodeAlloc>
class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if< class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if<
!NodeType::template destroyIsNoOp<NodeAlloc>()>::type> { !NodeType::template DestroyIsNoOp<NodeAlloc>::value>::type> {
public: public:
explicit NodeRecycler(const NodeAlloc& alloc) explicit NodeRecycler(const NodeAlloc& alloc)
: refs_(0), dirty_(false), alloc_(alloc) { lock_.init(); } : refs_(0), dirty_(false), alloc_(alloc) { lock_.init(); }
...@@ -316,7 +315,7 @@ class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if< ...@@ -316,7 +315,7 @@ class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if<
// to save on ConcurrentSkipList size. // to save on ConcurrentSkipList size.
template<typename NodeType, typename NodeAlloc> template<typename NodeType, typename NodeAlloc>
class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if< class NodeRecycler<NodeType, NodeAlloc, typename std::enable_if<
NodeType::template destroyIsNoOp<NodeAlloc>()>::type> { NodeType::template DestroyIsNoOp<NodeAlloc>::value>::type> {
public: public:
explicit NodeRecycler(const NodeAlloc& alloc) : alloc_(alloc) { } explicit NodeRecycler(const NodeAlloc& alloc) : alloc_(alloc) { }
......
...@@ -195,7 +195,7 @@ class ConcurrentSkipList { ...@@ -195,7 +195,7 @@ class ConcurrentSkipList {
//=================================================================== //===================================================================
~ConcurrentSkipList() { ~ConcurrentSkipList() {
/* static */ if (NodeType::template destroyIsNoOp<NodeAlloc>()) { /* static */ if (NodeType::template DestroyIsNoOp<NodeAlloc>::value) {
// Avoid traversing the list if using arena allocator. // Avoid traversing the list if using arena allocator.
return; return;
} }
......
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