| ▲ | galangalalgol 9 hours ago | |||||||||||||||||||||||||||||||
The best practices I adopt for rust avoid the use of mutex whenever possible precisely because of how easy a deadlock is. It turns out it is always possible. There are entire languages the disallow any mutable state, much less shared mutable state. The question becomes how much performance are you willing to sacrifice to avoid the mutex. By starting with no shared mutable state and adding it when something is too slow, you end up with very few mutexes. | ||||||||||||||||||||||||||||||||
| ▲ | adwn 9 hours ago | parent [-] | |||||||||||||||||||||||||||||||
> avoid the use of mutex […] It turns out it is always possible How would you handle the archetypical example of a money transfer between two bank accounts, in which 100 units of money need to be subtracted from one account and atomically added to another account, after checking that the first account contains at least 100 units? | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||