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>
}
}
-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,
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);
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,
// 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);