13 #ifndef LIBPMEMOBJ_ATOMIC_BACKOFF_HPP
14 #define LIBPMEMOBJ_ATOMIC_BACKOFF_HPP
28 class atomic_backoff {
34 static const int32_t LOOPS_BEFORE_YIELD = 16;
38 __pause(int32_t delay)
40 for (; delay > 0; --delay) {
43 #elif __GNUC__ && (__i386__ || __x86_64__)
45 __builtin_ia32_pause();
54 atomic_backoff(
const atomic_backoff &) =
delete;
58 atomic_backoff &operator=(
const atomic_backoff &) =
delete;
64 atomic_backoff() : count(1)
71 atomic_backoff(
bool) : count(1)
82 if (count <= LOOPS_BEFORE_YIELD) {
89 std::this_thread::yield();
100 if (count < LOOPS_BEFORE_YIELD) {
Persistent memory namespace.
Definition: allocation_flag.hpp:15