// sched_yield(), but more portable
std::this_thread::yield();
} else {
- folly::asm_pause();
+ folly::asm_volatile_pause();
}
oldWord = wordPtr->load(std::memory_order_relaxed);
goto retry;
return;
}
}
- asm_pause();
+ asm_volatile_pause();
if (UNLIKELY(++spinCount >= kMaxSpinCount)) {
applyDeferredReaders(state, ctx, slot);
return;
constexpr size_t kPauseLimit = 10000;
for (size_t i = 0; condition(); ++i) {
if (i < kPauseLimit) {
- folly::asm_pause();
+ folly::asm_volatile_pause();
} else {
std::this_thread::yield();
}
asm volatile("or 27,27,27");
#endif
}
-
-inline void asm_pause() {
-#if defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_X64))
- ::_mm_pause();
-#elif defined(__i386__) || FOLLY_X64
- asm("pause");
-#elif FOLLY_A64 || defined(__arm__)
- asm("yield");
-#elif FOLLY_PPC64
- asm("or 31,31,31");
-#endif
-}
}
const int max = 1000;
auto rng = folly::ThreadLocalPRNG();
for (int i = 0; i < max; i++) {
- folly::asm_pause();
+ folly::asm_volatile_pause();
MSLGuard g(v.lock);
int first = v.ar[0];
const int max = 1000;
auto rng = folly::ThreadLocalPRNG();
for (int i = 0; i < max; i++) {
- folly::asm_pause();
+ folly::asm_volatile_pause();
SpinLockGuardImpl<LOCK> g(v->lock);
int first = v->ar[0];
template <typename LOCK>
void trylockTestThread(TryLockState<LOCK>* state, size_t count) {
while (true) {
- folly::asm_pause();
+ folly::asm_volatile_pause();
bool ret = state->lock2.try_lock();
SpinLockGuardImpl<LOCK> g(state->lock1);
if (state->obtained >= count) {
auto oldFailed = state->failed;
while (state->failed == oldFailed && state->obtained < count) {
state->lock1.unlock();
- folly::asm_pause();
+ folly::asm_volatile_pause();
state->lock1.lock();
}