This is an automated email from the ASF dual-hosted git repository.

guangmingchen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brpc.git


The following commit(s) were added to refs/heads/master by this push:
     new 9a1a9b2b fix mpsc queue cur enqueue node to atomic exhange (#2739)
9a1a9b2b is described below

commit 9a1a9b2b44a42bf85ffc26b8e87d7f914c1bf721
Author: Yang,Liming <liming.y...@139.com>
AuthorDate: Thu Aug 22 17:58:06 2024 +0800

    fix mpsc queue cur enqueue node to atomic exhange (#2739)
---
 src/butil/containers/mpsc_queue.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/src/butil/containers/mpsc_queue.h 
b/src/butil/containers/mpsc_queue.h
index f9e1d780..6db50f28 100644
--- a/src/butil/containers/mpsc_queue.h
+++ b/src/butil/containers/mpsc_queue.h
@@ -129,13 +129,12 @@ bool MPSCQueue<T, Alloc>::DequeueImpl(T* data) {
     if (_cur_dequeue_node) {
         node = _cur_dequeue_node;
     } else {
-        node = _cur_enqueue_node.load(memory_order_relaxed);
+        node = _cur_enqueue_node.exchange(NULL, memory_order_relaxed);
     }
     if (!node) {
         return false;
     }
 
-    _cur_enqueue_node.store(NULL, memory_order_relaxed);
     if (data) {
         auto mem = (T* const)node->data_mem;
         *data = std::move(*mem);


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to