3 ms·
Make the stack data const or wrap it in a mutex. That is what you end up having to do internally in Rust anyway, or being more sophisticated and having page loc
by zanny 11y ago
Make the stack data const or wrap it in a mutex. That is what you end up having to do internally in Rust anyway, or being more sophisticated and having page locks.
- steveklabnik 11y agoYou can safely pass mutable pointers to stack data to scoped threads.
- zanny 11y agoWhich requires the language to perform some kind of synchronization around the data access or you will have races between threads. Just because you don't have to be explicit about it doesn't mean you don't need to have some mechanism to handle it somewhere, its just automatic instead.
- steveklabnik 11y agoIt does not, actually, if you're accessing disjointed parts of your data: http://aturon.github.io/crossbeam-doc/crossbeam/struct.Scope.html#method.spawn http://aturon.github.io/crossbeam-doc/crossbeam/struct.Scope...