Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ambiguous explanation of Sync in the book #28458

Closed
critiqjo opened this issue Sep 17, 2015 · 0 comments
Closed

Ambiguous explanation of Sync in the book #28458

critiqjo opened this issue Sep 17, 2015 · 0 comments

Comments

@critiqjo
Copy link

When a type T implements Sync, it indicates to the compiler that something of this type has no possibility of introducing memory unsafety when used from multiple threads concurrently.

The term "used" should be elaborated: "when used by immutable reference from ..."
It will not occur to a reader that a primitive type implements Sync.

For example, sharing immutable data with an atomic reference count is threadsafe. Rust provides a type like this, Arc<T>, and it implements Sync, so it is safe to share between threads.

This might leave an impression that usize does not implement Sync but when wrapped with Arc, Arc<usize> will have Sync!! (This really was my impression until recently!).
Besides, saying Arc<T> implements Sync itself is incorrect -- it should say "Arc<T> implements Sync if and only if T implements Sync", or better, don't mention Arc at all...

Please word this section more carefully, so that confusion is eliminated in future...
Ref: section 4.6

Manishearth added a commit to Manishearth/rust that referenced this issue Sep 20, 2015
…labnik

Fixes rust-lang#28458

Details about `Arc` may be too soon to be described together with `Sync`... Tell me what you think.

r? @steveklabnik
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants