Open
Description
See prior discussion on IRLO here.
Send and Sync are defined in the 'nomicon as:
- A type is Send if it is safe to send it to another thread.
- A type is Sync if it is safe to share between threads (T is Sync if and only if &T is Send).
I'm reasonably happy that the definition for Sync is clear and unambiguous, however Send feels less obvious.
I think the definition of Send we had in that thread is:
A type is Send if it is safe to transfer ownership or give an exclusive reference to any other thread.
I ended up changing that sentence less than I expected because it's technically correct but not very useful, I think explaining what unsafe code is allowed to do would help clarify.
Some examples of things that this definition allows unsafe code to do with non-Send types:
- Store them on the stack of a different thread
- Read and write to them on any thread
- Match on a
Wrapper<T>
and extract the T (as long as it's careful to avoid drop, panic, etc)
Metadata
Metadata
Assignees
Labels
No labels