26 #if defined(__clang__) 27 #define NO_SANITIZE_ADDRESS __attribute__((no_sanitize_address)) 29 #define NO_SANITIZE_ADDRESS 101 #if defined(__SANITIZE_ADDRESS__) && !defined(__clang__) && \ 102 (defined(__GNUC__) || defined(__GNUG__)) 130 uintptr_t lockptr = (uintptr_t)&
lock_;
136 assert(slot < CHAR_BIT / 2);
138 unsigned offset_bytes = (unsigned)((uintptr_t)&
lock_ - (uintptr_t)
word());
141 unsigned)(
kIsLittleEndian ? offset_bytes * CHAR_BIT + slot * 2 : CHAR_BIT * (
sizeof(
uint32_t) - offset_bytes - 1) + slot * 2);
157 oldWord = wordPtr->load(std::memory_order_relaxed);
159 assert(oldWord &
heldBit(slot));
161 }
while (!wordPtr->compare_exchange_weak(
162 oldWord, newWord, std::memory_order_release, std::memory_order_relaxed));
169 template <
unsigned MaxSpins = 1000,
unsigned MaxYields = 0>
182 template <
unsigned MaxSpins,
unsigned MaxYields>
195 uint32_t oldWord = wordPtr->load(std::memory_order_relaxed);
200 }
while (!wordPtr->compare_exchange_weak(
203 std::memory_order_acquire,
204 std::memory_order_relaxed));
209 template <
unsigned MaxSpins,
unsigned MaxYields>
211 static_assert(MaxSpins + MaxYields < (
unsigned)-1,
"overflow");
215 oldWord = wordPtr->load(std::memory_order_relaxed);
216 if ((oldWord &
heldBit(slot)) == 0 &&
217 wordPtr->compare_exchange_weak(
220 std::memory_order_acquire,
221 std::memory_order_relaxed)) {
Atom< std::uint32_t > Futex
uint32_t heldBit(unsigned slot) const
constexpr auto kIsLittleEndian
—— Concurrent Priority Queue Implementation ——
uint32_t baseShift(unsigned slot) const
static void lockSlowPath(uint32_t oldWord, detail::Futex<> *wordPtr, uint32_t slotHeldBit, unsigned maxSpins, unsigned maxYields)
auto lock(Synchronized< D, M > &synchronized, Args &&...args)
#define NO_SANITIZE_ADDRESS
detail::Futex * word() const
uint32_t waitBit(unsigned slot) const
int futexWake(const Futex *futex, int count, uint32_t wakeMask)