We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc3a5f7 commit a7381d5Copy full SHA for a7381d5
src/thread.h
@@ -48,8 +48,8 @@ class Spinlock {
48
Spinlock() { lock = 1; } // Init here to workaround a bug with MSVC 2013
49
void acquire() {
50
while (lock.fetch_sub(1, std::memory_order_acquire) != 1)
51
- for (int cnt = 0; lock.load(std::memory_order_relaxed) <= 0; ++cnt)
52
- if (cnt >= 10000) std::this_thread::yield(); // Be nice to hyperthreading
+ while (lock.load(std::memory_order_relaxed) <= 0)
+ std::this_thread::yield(); // Be nice to hyperthreading
53
}
54
void release() { lock.store(1, std::memory_order_release); }
55
};
0 commit comments