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