Skip to content

Latest commit

 

History

History

1_8_thread_safety

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Step 1.8: Thread safety

Estimated time: 1 day

Rust has Send and Sync marker traits which are fundamental for concurrency and thread safety story in Rust and represent one of fearless concurrency corner stones (which allow to avoid data races at compile time).

For better understanding Send/Sync purpose, design, limitations and use cases, read through the following articles:

Task

Implement the following types, which meet conditions:

  1. OnlySync is Sync, but !Send.
  2. OnlySend is Send, but !Sync.
  3. SyncAndSend is both Sync and Send.
  4. NotSyncNotSend is both !Sync and !Send.

All inner details of implementation are on your choice.

Play with these types from multiple threads to see how compile time fearless concurrency works in practice.

Questions

After completing everything above, you should be able to answer (and understand why) the following questions:

  • What does "fearless concurrency" mean in Rust? With which mechanisms does Rust fulfill this guarantee exactly?
  • Why do Send and Sync exist at all? How is it related to interior mutability?