neon-bindings / neon

Rust bindings for writing safe and fast native Node.js modules.
https://www.neon-bindings.com/
Apache License 2.0
7.98k stars 282 forks source link

Fine-tune the Ordering for the atomic usages #1015

Open wang384670111 opened 7 months ago

wang384670111 commented 7 months ago

SeqCst is overly restrictive. I believe that the ordering can be appropriately modified.

COUNTER and NEXT_ID are used for multithreading counting purposes and don’t synchronize with other locals, so using Relaxed ordering is sufficient.

https://github.com/neon-bindings/neon/blob/09fce7935b50cdefb1a3eea38116946f070b077a/crates/neon/src/thread/mod.rs#L115 https://github.com/neon-bindings/neon/blob/09fce7935b50cdefb1a3eea38116946f070b077a/crates/neon/src/lifecycle.rs#L40