blackbeam / rust-mysql-simple

Mysql client library implemented in rust.
Apache License 2.0
661 stars 144 forks source link

Fine-tune the Ordering for count #367

Closed wang384670111 closed 9 months ago

wang384670111 commented 9 months ago

https://github.com/blackbeam/rust-mysql-simple/blob/e0fbfe41f23e9004a0bd7f997c388591ce07b40b/src/conn/pool/inner.rs#L70-L84

Here count is employed solely for counting purposes, rather than for synchronizing access to other shared variables. While Ordering::SeqCst guarantees program correctness, it can also impact performance. Therefore, using Ordering::Relaxed is sufficient to maintain the program's correctness without adversely affecting its efficiency.