Skip to content

Commit 37e30a8

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

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

include/ipfixprobe/outputPlugin/outputStorage/spinlock.hpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#pragma once
22

3+
#include "backoffScheme.hpp"
4+
35
#include <atomic>
46
#include <cstddef>
57
#include <cstdint>
@@ -13,9 +15,10 @@ class Spinlock {
1315
public:
1416
void lock() noexcept
1517
{
18+
BackoffScheme backoffScheme(20, std::numeric_limits<std::size_t>::max());
1619
while (flag.test(std::memory_order_relaxed)
1720
|| flag.test_and_set(std::memory_order_acquire)) {
18-
std::this_thread::yield();
21+
backoffScheme.backoff();
1922
}
2023
}
2124

0 commit comments

Comments
 (0)