X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2FConcurrentSkipList-inl.h;h=122f21c64789e381b288be87378b44e0b6988363;hb=532b8c01aa05334af612233137a836bfe45c3c78;hp=48e3f63f3d86b107f70ffeba4caefaac98c837c9;hpb=d638ae7a87538e30014a37ba8941f0cec51198a0;p=folly.git diff --git a/folly/ConcurrentSkipList-inl.h b/folly/ConcurrentSkipList-inl.h index 48e3f63f..122f21c6 100644 --- a/folly/ConcurrentSkipList-inl.h +++ b/folly/ConcurrentSkipList-inl.h @@ -1,5 +1,5 @@ /* - * Copyright 2015 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. @@ -16,8 +16,7 @@ // @author: Xin Liu -#ifndef FOLLY_CONCURRENTSKIPLIST_INL_H_ -#define FOLLY_CONCURRENTSKIPLIST_INL_H_ +#pragma once #include #include @@ -42,11 +41,12 @@ template class csl_iterator; template class SkipListNode : private boost::noncopyable { - enum { + enum : uint16_t { IS_HEAD_NODE = 1, MARKED_FOR_REMOVAL = (1 << 1), FULLY_LINKED = (1 << 2), }; + public: typedef T value_type; @@ -60,7 +60,7 @@ class SkipListNode : private boost::noncopyable { height * sizeof(std::atomic); auto* node = static_cast(alloc.allocate(size)); // do placement new - new (node) SkipListNode(height, std::forward(data), isHead); + new (node) SkipListNode(uint8_t(height), std::forward(data), isHead); return node; } @@ -71,16 +71,15 @@ class SkipListNode : private boost::noncopyable { } template - static constexpr bool destroyIsNoOp() { - return IsArenaAllocator::value && - boost::has_trivial_destructor::value; - } + struct DestroyIsNoOp : std::integral_constant::value && + boost::has_trivial_destructor::value> { }; // copy the head node to a new head node assuming lock acquired SkipListNode* copyHead(SkipListNode* node) { DCHECK(node != nullptr && height_ > node->height_); setFlags(node->getFlags()); - for (int i = 0; i < node->height_; ++i) { + for (uint8_t i = 0; i < node->height_; ++i) { setSkip(i, node->skip(i)); } return this; @@ -119,13 +118,13 @@ class SkipListNode : private boost::noncopyable { bool isHeadNode() const { return getFlags() & IS_HEAD_NODE; } void setIsHeadNode() { - setFlags(getFlags() | IS_HEAD_NODE); + setFlags(uint16_t(getFlags() | IS_HEAD_NODE)); } void setFullyLinked() { - setFlags(getFlags() | FULLY_LINKED); + setFlags(uint16_t(getFlags() | FULLY_LINKED)); } void setMarkedForRemoval() { - setFlags(getFlags() | MARKED_FOR_REMOVAL); + setFlags(uint16_t(getFlags() | MARKED_FOR_REMOVAL)); } private: @@ -231,7 +230,7 @@ class NodeRecycler; template class NodeRecycler()>::type> { + !NodeType::template DestroyIsNoOp::value>::type> { public: explicit NodeRecycler(const NodeAlloc& alloc) : refs_(0), dirty_(false), alloc_(alloc) { lock_.init(); } @@ -317,7 +316,7 @@ class NodeRecycler class NodeRecycler()>::type> { + NodeType::template DestroyIsNoOp::value>::type> { public: explicit NodeRecycler(const NodeAlloc& alloc) : alloc_(alloc) { } @@ -333,5 +332,3 @@ class NodeRecycler