Commit d807e4c1 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by facebook-github-bot-9

Use static const keys in AtomicHashArray::Config.

Summary: [Folly] Use static const keys in AtomicHashArray::Config.

From https://github.com/facebook/folly/pull/264/, MSVC may have a hard time with certain expressions. D2284130 factored them out as `static constexpr` members, but Clang had a hard time with that in HPHP. This adds a test case that triggers the same failure to the Folly build. Not quite sure how this impacts MSVC though.

Reviewed By: @Gownta

Differential Revision: D2304346
parent c40f1cf4
......@@ -23,6 +23,19 @@
namespace folly {
template <class KeyT, class ValueT,
class HashFcn, class EqualFcn, class Allocator>
const KeyT AtomicHashArray<KeyT, ValueT, HashFcn, EqualFcn, Allocator>::Config::
kEmptyKey = (KeyT)-1;
template <class KeyT, class ValueT,
class HashFcn, class EqualFcn, class Allocator>
const KeyT AtomicHashArray<KeyT, ValueT, HashFcn, EqualFcn, Allocator>::Config::
kLockedKey = (KeyT)-2;
template <class KeyT, class ValueT,
class HashFcn, class EqualFcn, class Allocator>
const KeyT AtomicHashArray<KeyT, ValueT, HashFcn, EqualFcn, Allocator>::Config::
kErasedKey = (KeyT)-3;
// AtomicHashArray private constructor --
template <class KeyT, class ValueT,
class HashFcn, class EqualFcn, class Allocator>
......
......@@ -128,9 +128,15 @@ class AtomicHashArray : boost::noncopyable {
int entryCountThreadCacheSize;
size_t capacity; // if positive, overrides maxLoadFactor
constexpr Config() : emptyKey((KeyT)-1),
lockedKey((KeyT)-2),
erasedKey((KeyT)-3),
private:
static const KeyT kEmptyKey;
static const KeyT kLockedKey;
static const KeyT kErasedKey;
public:
constexpr Config() : emptyKey(kEmptyKey),
lockedKey(kLockedKey),
erasedKey(kErasedKey),
maxLoadFactor(0.8),
growthFactor(-1),
entryCountThreadCacheSize(1000),
......
......@@ -63,7 +63,7 @@ class AtomicLinkedList {
* Note: list must be empty on destruction.
*/
~AtomicLinkedList() {
assert(head_ == nullptr);
assert(empty());
}
bool empty() const {
......
......@@ -191,3 +191,7 @@ TEST(Aha, InsertErase_i64_str) {
testMap<int64_t, string>();
testMap<int64_t, string, MmapAllocator<char>>();
}
TEST(Aha, Create_cstr_i64) {
auto obj = AtomicHashArray<const char*, int64_t>::create(12);
}
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