futures-rs icon indicating copy to clipboard operation
futures-rs copied to clipboard

Fine-tune the Ordering for num_senders

Open wang384670111 opened this issue 1 year ago • 0 comments

https://github.com/rust-lang/futures-rs/blob/aafe554b02cbac19d396512b36bce8b688a18115/futures-channel/src/mpsc/mod.rs#L283

As mentioned in the comments, num_senders is used only for counting purposes, not for synchronizing access to other shared variables. While SeqCst guarantees the correctness of the program, it can also affect the performance. Therefore, using Relaxed is sufficient to maintain the correctness of the program without affecting its efficiency.

https://github.com/rust-lang/futures-rs/commit/ed3b268225c7c532a4b222adfe077c4e8ce0f24d Could you please explain the reasoning behind the need to switch to seqcst?

wang384670111 avatar Mar 02 '24 15:03 wang384670111