If you need a reasonably fast Mutex but don't want to pull in the whole parking_lot as a dependency:https://github.com/stjepang/simple-mutex …
Atomic operations use Acquire-Release orderings. No matter how you send data from one thread to another, there is always *something* synchronizing with atomics, be it Arc, Mutex, channel internals, or something else. Rust guarantees this, and you can only cheat with unsafe code.
-
-
Ok, but the cell isn't atomic, so accessing the atomic state protects the cell when doing try_lock? and the ownership system protects when you pass ownership to another thread and do into_inner there? (which does not access the atomic) Thanks, just curious!
-
Exactly, the atomic state is used to protect the cell. When you use simple-mutex from another crate, no matter what you attempt to do through its public safe API, you will always get valid access to inner data.
- 1 more reply
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.