poor performance on arm-a7

This commit is contained in:
mutouyun 2018-12-13 11:50:26 +08:00
parent b6248ad5dc
commit 7a7426a8b8
2 changed files with 5 additions and 8 deletions

View File

@ -38,8 +38,8 @@ struct alignas(std::max_align_t) elem_array_head {
}
auto acquire(void) {
for (unsigned k = 0; lc_.exchange(1, std::memory_order_acquire); ++k) {
yield(k);
while (lc_.exchange(1, std::memory_order_acquire)) {
std::this_thread::yield();
}
return index_of(wt_.load(std::memory_order_relaxed));
}
@ -107,7 +107,7 @@ public:
void* acquire(void) {
elem_t* el = elem(base_t::acquire());
// check all consumers have finished reading
for (unsigned k = 0;; ++k) {
while(1) {
uint_t<32> expected = 0;
if (el->head_.rc_.compare_exchange_weak(
expected,
@ -115,7 +115,7 @@ public:
std::memory_order_release)) {
break;
}
yield(k);
std::this_thread::yield();
}
return el->data_;
}

View File

@ -4,7 +4,6 @@
#include <cstdint>
#include <limits>
#include <thread>
#include <chrono>
namespace ipc {
@ -87,9 +86,7 @@ inline void yield(unsigned k) {
else
if (k < 16) { IPC_LOCK_PAUSE_(); }
else
if (k < 32) { std::this_thread::yield(); }
else
{ std::this_thread::sleep_for(std::chrono::milliseconds(1)); }
{ std::this_thread::yield(); }
}
} // namespace ipc