Skip to content

[guide] A new guide that centers around Send and Sync should be written #18938

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

Closed
Kimundi opened this issue Nov 13, 2014 · 2 comments
Closed

Comments

@Kimundi
Copy link
Member

Kimundi commented Nov 13, 2014

Currently, the only Rust guide that talks about concurrency is the task guide, which talks about spawn, channels, Futures and Arcs and how to use them.

However, Rusts concurrency story is not based on those library types, its based on its ownership and borrowing semantic and the two build-in traits Send and Sync.

A rewritten concurrency guide could start by talking around the two core problems with concurrent/parallel code:

  1. Making sure that objects created on one thread can be safely moved into another thread and then used there. (Examples: global allocator vs thread-local allocator, FFI bindings that need to stay on one thread)
  2. Making sure that objects can be safely accessed from different threads in parallel. (Examples: worker threads with shared memory, global variables)

And then talk about how those two cases are, per definition, covered with the two build-in traits:

  1. Send expresses whether a type can be safely ownership-transferred across thread boundaries
  2. Sync expresses whether a type can be safely accessed through shared references from different threads.

After each of these those two traits got explained, the guide could go into details about language semantics and std library APIs that make use of them, eg task spawning works with Send, Arcs are Send and require Sync on the inner type, while channels are sendable endpoints that can only transfer sendable types, static variables that contain Sync types are safe to access, etc.

@abonander
Copy link
Contributor

Duplicate of #18936? Merge?

@Kimundi
Copy link
Member Author

Kimundi commented Dec 4, 2014

I opened both issues at the same time. #18936 is specifically about the current task/multithreading guide, while this is about a possible new rewrite of such a guide.

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

3 participants