From 2dc37740ceea2391655a000817079f85f3f95bed Mon Sep 17 00:00:00 2001 From: MingyuChen Date: Sat, 20 Apr 2024 18:02:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86weak=20CAS=E5=85=A8=E9=83=A8=E6=94=B9?= =?UTF-8?q?=E4=B8=BAstrong=20CAS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: MingyuChen --- ylong_runtime/src/executor/queue.rs | 4 ++-- ylong_runtime/src/sync/mpsc/bounded/array.rs | 2 +- ylong_runtime/src/sync/mpsc/unbounded/queue.rs | 2 +- ylong_runtime/src/sync/oneshot.rs | 2 +- ylong_runtime/src/sync/rwlock.rs | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ylong_runtime/src/executor/queue.rs b/ylong_runtime/src/executor/queue.rs index 99dacc2..b77c8e8 100644 --- a/ylong_runtime/src/executor/queue.rs +++ b/ylong_runtime/src/executor/queue.rs @@ -216,7 +216,7 @@ impl InnerBuffer { let res = self .front - .compare_exchange_weak(head, next, AcqRel, Acquire); + .compare_exchange(head, next, AcqRel, Acquire); match res { Ok(_) => break real_pos, Err(actual) => head = actual, @@ -368,7 +368,7 @@ impl InnerBuffer { let res = self.front - .compare_exchange_weak(src_prev_front, src_next_front, AcqRel, Acquire); + .compare_exchange(src_prev_front, src_next_front, AcqRel, Acquire); match res { Ok(_) => break n, Err(actual) => src_prev_front = actual, diff --git a/ylong_runtime/src/sync/mpsc/bounded/array.rs b/ylong_runtime/src/sync/mpsc/bounded/array.rs index db59949..9e44236 100644 --- a/ylong_runtime/src/sync/mpsc/bounded/array.rs +++ b/ylong_runtime/src/sync/mpsc/bounded/array.rs @@ -86,7 +86,7 @@ impl Array { // Compare the index of the node with the tail to avoid senders in different // cycles writing data to the same point at the same time. if (tail >> INDEX_SHIFT) == node_index { - match self.tail.compare_exchange_weak( + match self.tail.compare_exchange( tail, tail.wrapping_add(1 << INDEX_SHIFT), AcqRel, diff --git a/ylong_runtime/src/sync/mpsc/unbounded/queue.rs b/ylong_runtime/src/sync/mpsc/unbounded/queue.rs index 9507fb0..4b0c8da 100644 --- a/ylong_runtime/src/sync/mpsc/unbounded/queue.rs +++ b/ylong_runtime/src/sync/mpsc/unbounded/queue.rs @@ -138,7 +138,7 @@ impl Queue { if index + 1 == CAPACITY && new_block.is_none() { new_block = Some(Box::new(Block::::new())); } - match self.tail.index.compare_exchange_weak( + match self.tail.index.compare_exchange( tail, tail + (1 << INDEX_SHIFT), AcqRel, diff --git a/ylong_runtime/src/sync/oneshot.rs b/ylong_runtime/src/sync/oneshot.rs index 5700afb..f84c378 100644 --- a/ylong_runtime/src/sync/oneshot.rs +++ b/ylong_runtime/src/sync/oneshot.rs @@ -171,7 +171,7 @@ impl Sender { if self .channel .state - .compare_exchange_weak(INIT, SENT, AcqRel, Acquire) + .compare_exchange(INIT, SENT, AcqRel, Acquire) .is_ok() { self.channel.waker.wake(); diff --git a/ylong_runtime/src/sync/rwlock.rs b/ylong_runtime/src/sync/rwlock.rs index ec09bdb..a2ee692 100644 --- a/ylong_runtime/src/sync/rwlock.rs +++ b/ylong_runtime/src/sync/rwlock.rs @@ -138,7 +138,7 @@ impl RwLock { if read_count < 0 { return Err(LockError); } else { - match self.read_count.compare_exchange_weak( + match self.read_count.compare_exchange( read_count, read_count + 1, AcqRel, -- Gitee