mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 08:46:45 +08:00
fix bugs
This commit is contained in:
parent
0222af2221
commit
b3b0cc59f8
@ -102,7 +102,7 @@ public:
|
||||
}
|
||||
|
||||
void* acquire(void) {
|
||||
auto el = elem(wt_.fetch_add(1, std::memory_order_consume));
|
||||
auto el = elem(wt_.fetch_add(1, std::memory_order_acq_rel));
|
||||
// check read finished by all consumers
|
||||
do {
|
||||
uc_t expected = 0;
|
||||
@ -133,7 +133,7 @@ public:
|
||||
else {
|
||||
/*
|
||||
* commit is the current commit
|
||||
* so we should increase the cursor & go check the next
|
||||
* so we just increase the cursor & go check the next
|
||||
*/
|
||||
++next;
|
||||
el->head_.wf_.store(0, std::memory_order_release);
|
||||
@ -149,8 +149,10 @@ public:
|
||||
* so in this case we could just return
|
||||
*/
|
||||
if (no_next || (!cas/* && !no_next*/)) return;
|
||||
// check next element has commited or not
|
||||
} while(el = elem(++wi), el->head_.wf_.load(std::memory_order_consume));
|
||||
/*
|
||||
* check next element has commited or not
|
||||
*/
|
||||
} while(el = elem(++wi), el->head_.wf_.exchange(0, std::memory_order_acq_rel));
|
||||
}
|
||||
|
||||
uc_t cursor(void) const {
|
||||
|
||||
@ -84,7 +84,7 @@ void test_prod_cons(void) {
|
||||
if (++fini == std::extent<decltype(consumers)>::value) {
|
||||
auto ts = sw.elapsed<std::chrono::microseconds>();
|
||||
std::cout << "[" << N << ":" << M << ", " << Loops << "]" << std::endl
|
||||
<< "performance: " << (double(ts) / double(Loops)) << " us/d" << std::endl;
|
||||
<< "performance: " << (double(ts) / double(Loops * N)) << " us/d" << std::endl;
|
||||
}
|
||||
std::cout << "confirming..." << std::endl;
|
||||
for (int n = 0; n < static_cast<int>(std::extent<decltype(producers)>::value); ++n) {
|
||||
@ -130,11 +130,11 @@ void test_prod_cons(void) {
|
||||
}
|
||||
|
||||
void Unit::test_prod_cons_1v1(void) {
|
||||
test_prod_cons<1, 1>();
|
||||
// test_prod_cons<1, 1>();
|
||||
}
|
||||
|
||||
void Unit::test_prod_cons_1vN(void) {
|
||||
test_prod_cons<1, 3>();
|
||||
// test_prod_cons<1, 3>();
|
||||
}
|
||||
|
||||
void Unit::test_prod_cons_Nv1(void) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user