zlacker

[parent] [thread] 5 comments
1. perryi+(OP)[view] [source] 2021-07-21 00:52:37
> also prevents data races in concurrent programs.

I have another neat trick to avoid races. Just write single threaded programs. Whenever you think you need another thread, you either don't need it, or you need another program.

replies(1): >>kaba0+JC
2. kaba0+JC[view] [source] 2021-07-21 07:43:07
>>perryi+(OP)
You do realize that data races can happen between multiple programs as well, when shared resources are used? Which is pretty much a requirement for many things.
replies(1): >>perryi+cA1
◧◩
3. perryi+cA1[view] [source] [discussion] 2021-07-21 14:55:29
>>kaba0+JC
Yes, and rust can't prevent those.
replies(1): >>adwn+bH1
◧◩◪
4. adwn+bH1[view] [source] [discussion] 2021-07-21 15:26:42
>>perryi+cA1
It can prevent data races in memory shared between processes in the same way it can prevent them in memory shared between threads. Data race prevention isn't built into the Rust language, it is constructed using a combination of the borrow checker and the type system.
replies(1): >>perryi+OR1
◧◩◪◨
5. perryi+OR1[view] [source] [discussion] 2021-07-21 16:18:16
>>adwn+bH1
As I understand the borrow checker, it wouldn't detect races that result from the interaction of separate processes, since that would be out of the bounds of the compilation unit. But my knowledge is limited in this, so I maybe wrong.
replies(1): >>static+5N2
◧◩◪◨⬒
6. static+5N2[view] [source] [discussion] 2021-07-21 20:35:32
>>perryi+OR1
Rust has no concept of a process, same as it has no concept of a thread. So you'd build a safe abstraction for sharing memory across processes the same way you do today with threads.
[go to top]