From fecbf53a0b2bd76b1dc6760f162ffffea92333aa Mon Sep 17 00:00:00 2001 From: wang384670111 <384670111@qq.com> Date: Tue, 9 Jan 2024 23:34:44 +0800 Subject: [PATCH] modify memory ordering --- crates/neon/src/lifecycle.rs | 2 +- crates/neon/src/thread/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/neon/src/lifecycle.rs b/crates/neon/src/lifecycle.rs index 0a08ef922..bdc7d9e20 100644 --- a/crates/neon/src/lifecycle.rs +++ b/crates/neon/src/lifecycle.rs @@ -37,7 +37,7 @@ impl InstanceId { fn next() -> Self { static NEXT_ID: AtomicU32 = AtomicU32::new(0); - let next = NEXT_ID.fetch_add(1, Ordering::SeqCst).checked_add(1); + let next = NEXT_ID.fetch_add(1, Ordering::Relaxed).checked_add(1); match next { Some(id) => Self(id), None => panic!("u32 overflow ocurred in Lifecycle InstanceId"), diff --git a/crates/neon/src/thread/mod.rs b/crates/neon/src/thread/mod.rs index 96b4adfaf..64e99bf0c 100644 --- a/crates/neon/src/thread/mod.rs +++ b/crates/neon/src/thread/mod.rs @@ -112,7 +112,7 @@ use crate::lifecycle::LocalCell; static COUNTER: AtomicUsize = AtomicUsize::new(0); fn next_id() -> usize { - COUNTER.fetch_add(1, Ordering::SeqCst) + COUNTER.fetch_add(1, Ordering::Relaxed) } /// A JavaScript thread-local container that owns its contents, similar to