/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// @author: Xin Liu <xliux@fb.com>
-#ifndef FOLLY_CONCURRENTSKIPLIST_INL_H_
-#define FOLLY_CONCURRENTSKIPLIST_INL_H_
+#pragma once
#include <algorithm>
#include <atomic>
#include <glog/logging.h>
#include <folly/Memory.h>
-#include <folly/SmallLocks.h>
+#include <folly/MicroSpinLock.h>
#include <folly/ThreadLocal.h>
namespace folly { namespace detail {
}
template<typename NodeAlloc>
- static constexpr bool destroyIsNoOp() {
- return IsArenaAllocator<NodeAlloc>::value &&
- boost::has_trivial_destructor<std::atomic<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) {
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(); }
+ explicit NodeRecycler() : refs_(0), dirty_(false) { lock_.init(); }
+
~NodeRecycler() {
CHECK_EQ(refs(), 0);
if (nodes_) {
// 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) { }
void addRef() { }
void releaseRef() { }
- void add(NodeType* node) { }
+ void add(NodeType* /* node */) {}
NodeAlloc& alloc() { return alloc_; }
};
}} // namespaces
-
-#endif // FOLLY_CONCURRENTSKIPLIST_INL_H_