Skip to content

Commit 33ce7d8

Browse files
Zainullin DamirZainullin Damir
authored andcommitted
++
1 parent 37e30a8 commit 33ce7d8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

include/ipfixprobe/outputPlugin/outputStorage/spinlock.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,13 @@ class Spinlock {
1616
void lock() noexcept
1717
{
1818
BackoffScheme backoffScheme(20, std::numeric_limits<std::size_t>::max());
19-
while (flag.test(std::memory_order_relaxed)
20-
|| flag.test_and_set(std::memory_order_acquire)) {
19+
while (true) {
20+
while (flag.test(std::memory_order_relaxed)) {
21+
backoffScheme.backoff();
22+
}
23+
if (!flag.test_and_set(std::memory_order_acquire)) {
24+
return;
25+
}
2126
backoffScheme.backoff();
2227
}
2328
}

0 commit comments

Comments
 (0)