1
0
mirror of https://github.com/google/comprehensive-rust.git synced 2025-03-20 06:21:09 +02:00

Clarify how MutexGuard is 'thread-safe' (avoiding the vague term) (#2336)

Fixes the last outstanding point of #1640.
This commit is contained in:
Frances Wingerter 2024-09-03 13:43:00 +00:00 committed by GitHub
parent 345e782bdd
commit c223257016
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -30,10 +30,12 @@ Typically because of interior mutability:
## `!Send + Sync`
These types are thread-safe, but they cannot be moved to another thread:
These types are safe to access (via shared references) from multiple threads,
but they cannot be moved to another thread:
- `MutexGuard<T: Sync>`: Uses OS level primitives which must be deallocated on
the thread which created them.
the thread which created them. However, an already-locked mutex can have its
guarded variable read by any thread with which the guard is shared.
## `!Send + !Sync`