▲ | shadowgovt 5 days ago | ||||||||||||||||
It's not the runtime; it's how the borrow-checker interoperates with threads. This is an aesthetics argument more than anything else, but I don't think the type theory around threads and memory safety in Rust is as "cooked" as single-thread borrow checking. The type assertions necessary around threads just get verbose and weird. I expect with more time (and maybe a new paradigm after we've all had more time to use Rust) this is a solvable problem, but I personally shy away from Rust for multi-threaded applications because I don't want to please the type-checker. | |||||||||||||||||
▲ | pornel 4 days ago | parent [-] | ||||||||||||||||
You know that Rust supports scoped threads? For the borrow checker, they behave like same-thread closures. Borrow checking is orthogonal to threads. You may be referring to the difficulty satisfying the 'static liftime (i.e. temporary references are not allowed when spawning a thread that may live for an arbitrarily long time). If you just spawn an independent thread, there's no guarantee that your code will reach join(), so there's no guarantee that references won't be dangling. The scoped threads API catches panics and ensures the thread will always finish before references given to it expire. | |||||||||||||||||
|