1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-31 17:52:14 +02:00

12 lines
460 B
Markdown
Raw Normal View History

2022-12-21 16:36:30 +01:00
# Shared State
Rust uses the type system to enforce synchronization of shared data. This is
primarily done via two types:
2023-01-19 13:49:41 +00:00
* [`Arc<T>`][1], atomic reference counted `T`: handles sharing between threads and
takes care to deallocate `T` when the last reference is dropped,
* [`Mutex<T>`][2]: ensures mutually exclusive access to the `T` value.
2022-12-21 16:36:30 +01:00
[1]: https://doc.rust-lang.org/std/sync/struct.Arc.html
[2]: https://doc.rust-lang.org/std/sync/struct.Mutex.html