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

Fix AtomicHashArray::defaultConfig SIOF.

Summary: [Folly] Fix AtomicHashArray::defaultConfig SIOF.

May fix https://github.com/facebook/folly/issues/300.

Reviewed By: @paulbiss

Differential Revision: D2343162
parent 98af46c5
......@@ -23,19 +23,6 @@
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>
......@@ -257,12 +244,6 @@ erase(KeyT key_in) {
}
}
template <class KeyT, class ValueT,
class HashFcn, class EqualFcn, class Allocator>
const typename AtomicHashArray<KeyT, ValueT,
HashFcn, EqualFcn, Allocator>::Config
AtomicHashArray<KeyT, ValueT, HashFcn, EqualFcn, Allocator>::defaultConfig;
template <class KeyT, class ValueT,
class HashFcn, class EqualFcn, class Allocator>
typename AtomicHashArray<KeyT, ValueT,
......
......@@ -128,23 +128,19 @@ class AtomicHashArray : boost::noncopyable {
int entryCountThreadCacheSize;
size_t capacity; // if positive, overrides maxLoadFactor
private:
static const KeyT kEmptyKey;
static const KeyT kLockedKey;
static const KeyT kErasedKey;
public:
Config() : emptyKey(kEmptyKey),
lockedKey(kLockedKey),
erasedKey(kErasedKey),
// Cannot have constexpr ctor because some compilers rightly complain.
Config() : emptyKey((KeyT)-1),
lockedKey((KeyT)-2),
erasedKey((KeyT)-3),
maxLoadFactor(0.8),
growthFactor(-1),
entryCountThreadCacheSize(1000),
capacity(0) {}
};
static const Config defaultConfig;
static SmartPtr create(size_t maxSize, const Config& = defaultConfig);
// Cannot have pre-instantiated const Config instance because of SIOF.
static SmartPtr create(size_t maxSize, const Config& c = Config());
iterator find(KeyT k) {
return iterator(this, findInternal(k).idx);
......
......@@ -22,11 +22,6 @@
namespace folly {
template <class KeyT, class ValueT,
class HashFcn, class EqualFcn, class Allocator>
const typename AtomicHashMap<KeyT, ValueT, HashFcn, EqualFcn, Allocator>::Config
AtomicHashMap<KeyT, ValueT, HashFcn, EqualFcn, Allocator>::defaultConfig;
// AtomicHashMap constructor -- Atomic wrapper that allows growth
// This class has a lot of overhead (184 Bytes) so only use for big maps
template <typename KeyT, typename ValueT,
......
......@@ -191,8 +191,7 @@ class AtomicHashMap : boost::noncopyable {
// The constructor takes a finalSizeEst which is the optimal
// number of elements to maximize space utilization and performance,
// and a Config object to specify more advanced options.
static const Config defaultConfig;
explicit AtomicHashMap(size_t finalSizeEst, const Config& = defaultConfig);
explicit AtomicHashMap(size_t finalSizeEst, const Config& c = Config());
~AtomicHashMap() {
const int numMaps = numMapsAllocated_.load(std::memory_order_relaxed);
......
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