42 #ifndef LIBPMEMOBJ_ATOMIC_BACKOFF_HPP
43 #define LIBPMEMOBJ_ATOMIC_BACKOFF_HPP
57 class atomic_backoff {
63 static const int32_t LOOPS_BEFORE_YIELD = 16;
67 __pause(int32_t delay)
69 for (; delay > 0; --delay) {
72 #elif __GNUC__ && (__i386__ || __x86_64__)
74 __builtin_ia32_pause();
83 atomic_backoff(
const atomic_backoff &) =
delete;
87 atomic_backoff &operator=(
const atomic_backoff &) =
delete;
93 atomic_backoff() : count(1)
100 atomic_backoff(
bool) : count(1)
111 if (count <= LOOPS_BEFORE_YIELD) {
118 std::this_thread::yield();
129 if (count < LOOPS_BEFORE_YIELD) {