How does Rust protect against instruction reordering on Send here? Say you initialize the Mutex and share it with another thread that retrieves the data. What prevents the compiler from doing the cell-assignment later which could make the other thread read uninitialized data?
-
-
-
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.
- 3 more replies
New conversation -
-
-
That is pretty cool.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
Wait why is this Mutex smaller? parking_lot‘s seems to have a single byte of overhead.
-
I think smaller in terms of code size, not data size.
- 1 more reply
New conversation -
-
-
Taking inspiration from parking_lot's WordLock, the mutex could be one word large and have allocation per thread rather than per mutex instance.
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
I'm sometimes wondering why can't Mutext and such be efficient in std?
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
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.