From 8e6ae4220b9351d1fb1dc30940a7c88e6de6894a Mon Sep 17 00:00:00 2001 From: mutouyun Date: Sat, 9 Jan 2021 21:42:56 +0800 Subject: [PATCH] =?UTF-8?q?mmb=20force=5Fpush=20=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E7=AB=9E=E4=BA=89=E6=97=B6=EF=BC=8C=E5=BA=94=E8=AF=A5=E5=9C=A8?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E5=90=8E=E5=85=88=E6=AD=A3=E5=B8=B8push?= =?UTF-8?q?=E4=B8=80=E6=AC=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libipc/prod_cons.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/libipc/prod_cons.h b/src/libipc/prod_cons.h index 735abbc..d5684fa 100755 --- a/src/libipc/prod_cons.h +++ b/src/libipc/prod_cons.h @@ -376,9 +376,14 @@ struct prod_cons_impl> { } // just compare & exchange if (el->rc_.compare_exchange_weak( - cur_rc, inc_mask(epoch | (cur_rc & ep_mask)) | static_cast(cc), std::memory_order_relaxed) && - epoch_.compare_exchange_weak(epoch, epoch, std::memory_order_acq_rel)) { - break; + cur_rc, inc_mask(epoch | (cur_rc & ep_mask)) | static_cast(cc), std::memory_order_relaxed)) { + if (epoch == epoch_.load(std::memory_order_acquire)) { + break; + } + else if (push(wrapper, std::forward(f), elems)) { + return true; + } + epoch = epoch_.fetch_add(ep_incr, std::memory_order_release) + ep_incr; } ipc::yield(k); }