Why does Rust have mutexes and other sychronization primitives, if sharing of mutable state between tasks is not allowed? -


My understanding is that it is not possible to share an unstable state among the tasks in the war, Things are What is their purpose?

"Data is not allowed to share inappropriate data between tasks" was an overdrawing, there was no crime , It is also used in very introductory material on Ruta, and for good reasons. But the truth is that, Jung can only get rid of data races; Not like sharing anything, but only one way Jung wants to become a system programming language in the same sense as C and C ++, so it will not remove some capabilities or performance optimization completely However, it is not normally safe to share temporary memory (data race etc.) so if you want it, you can wrap it in the unsafe Doors must.

Fortunately, some patterns of using shared temporary memory are safe (for example using proper locking discipline) when these patterns are identified and sufficiently It is considered important, so someone writes unsafe code that they consider themselves (or perhaps "proven"), highlight the safe interface in other words : Code using the interface Also can not be in violation of various security requirements of corrosion. For example, while Mutex allows you to access temporary memory from different tasks at different times, it does not allow aliasing between jobs ( I.e. access at the same time), then the data race can be stopped.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -