diff --git a/src/SUMMARY.md b/src/SUMMARY.md index cbee8c01..a4073433 100644 --- a/src/SUMMARY.md +++ b/src/SUMMARY.md @@ -131,6 +131,8 @@ - [The Rust runtime](runtime.md) +- [Concurrency](concurrency.md) + - [Appendices](appendices.md) - [Grammar summary](grammar.md) - [Macro Follow-Set Ambiguity Formal Specification](macro-ambiguity.md) diff --git a/src/concurrency.md b/src/concurrency.md new file mode 100644 index 00000000..e796e9cb --- /dev/null +++ b/src/concurrency.md @@ -0,0 +1,10 @@ +r[concurrency] +# Concurrency + +r[concurrency.intro] +Rust provides language and library features for writing [concurrent programs]. These features are designed to prevent [data races] --- situations in which multiple threads access the same memory without proper synchronization, with at least one of the accesses modifying that memory. + +This chapter describes the traits, types, and concepts that Rust uses to express and enforce safe concurrency. + +[concurrent programs]: glossary.md#concurrent-program +[data races]: glossary.md#data-race diff --git a/src/glossary.md b/src/glossary.md index fa5edee2..89a9215f 100644 --- a/src/glossary.md +++ b/src/glossary.md @@ -50,6 +50,10 @@ Combinators are higher-order functions that apply only functions and earlier defined combinators to provide a result from its arguments. They can be used to manage control flow in a modular fashion. +### Concurrent program + +A concurrent program is a program that can perform multiple tasks or processes at the same time, possibly overlapping in execution. + ### Crate A crate is the unit of compilation and linking. There are different [types of @@ -60,6 +64,10 @@ may be made visible to other crates by marking them as public in the crate root, including through [paths] of public modules. [More][crate]. +### Data race + +A data race occurs when multiple threads attempt to access the same shared memory location concurrently. + ### Dispatch Dispatch is the mechanism to determine which specific version of code is actually run when it involves polymorphism. Two major forms of dispatch are static dispatch and dynamic dispatch. Rust supports dynamic dispatch through the use of [trait objects][type.trait-object].