/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
class HashFcn, class EqualFcn, class Allocator>
AtomicHashArray<KeyT, ValueT, HashFcn, EqualFcn, Allocator>::
AtomicHashArray(size_t capacity, KeyT emptyKey, KeyT lockedKey,
- KeyT erasedKey, double maxLoadFactor, size_t cacheSize)
- : capacity_(capacity), maxEntries_(size_t(maxLoadFactor * capacity_ + 0.5)),
+ KeyT erasedKey, double _maxLoadFactor, size_t cacheSize)
+ : capacity_(capacity),
+ maxEntries_(size_t(_maxLoadFactor * capacity_ + 0.5)),
kEmptyKey_(emptyKey), kLockedKey_(lockedKey), kErasedKey_(erasedKey),
kAnchorMask_(nextPowTwo(capacity_) - 1), numEntries_(0, cacheSize),
numPendingEntries_(0, cacheSize), isFull_(0), numErases_(0) {
// another thread now does ++numPendingEntries_, we expect it
// to pass the isFull_.load() test above. (It shouldn't insert
// a new entry.)
- FOLLY_SPIN_WAIT(
- isFull_.load(std::memory_order_acquire) != NO_PENDING_INSERTS
- && numPendingEntries_.readFull() != 0
- );
+ detail::atomic_hash_spin_wait([&] {
+ return
+ (isFull_.load(std::memory_order_acquire) != NO_PENDING_INSERTS) &&
+ (numPendingEntries_.readFull() != 0);
+ });
isFull_.store(NO_PENDING_INSERTS, std::memory_order_release);
if (relaxedLoadKey(*cell) == kEmptyKey_) {
}
DCHECK(relaxedLoadKey(*cell) != kEmptyKey_);
if (kLockedKey_ == acquireLoadKey(*cell)) {
- FOLLY_SPIN_WAIT(
- kLockedKey_ == acquireLoadKey(*cell)
- );
+ detail::atomic_hash_spin_wait([&] {
+ return kLockedKey_ == acquireLoadKey(*cell);
+ });
}
const KeyT thisKey = acquireLoadKey(*cell);
}; // aha_iterator
} // namespace folly
-
-#undef FOLLY_SPIN_WAIT