commit e8e2d1bfafdafd3bd7eaa71926efa18eadabda86
parent 70bc8a44955f5542aee066952139a871b885fe91
Author: ling0x <ling0x@users.noreply.github.com>
Date: Wed, 29 Jul 2026 18:28:37 +0100
refactor
Diffstat:
1 file changed, 16 insertions(+), 11 deletions(-)
diff --git a/async_programming/concurrency_primitives.txt b/async_programming/concurrency_primitives.txt
@@ -1,13 +1,13 @@
-# Concurrency Primitives
+Concurrency Primitives
-**Concurrency primitives** in Rust are the fundamental building blocks that
+Concurrency primitives in Rust are the fundamental building blocks that
allow multiple parts of a program to run simultaneously — safely and without
data races. They are the low-level tools you use to coordinate concurrent tasks,
share data between threads, and synchronize execution.
## Why Rust Is Special Here
-Rust's ownership and type system enforce concurrency safety at **compile time**,
+Rust's ownership and type system enforce concurrency safety at compile time,
not at runtime. Many bugs that would silently corrupt data in other languages
become compile errors in Rust, which is why Rust calls its approach "fearless
concurrency".
@@ -15,23 +15,28 @@ concurrency".
## The Core Primitives
-- **Threads** — the most basic primitive;
+- Threads — the most basic primitive;
independent paths of execution that run concurrently, letting you exploit
multi-core processors
[earthly](https://earthly.dev/blog/rust-concurrency-patterns-parallel-programming/)
-- **Channels (`mpsc`)** — typed message-passing pipes with a sender and receiver
+
+- Channels (mpsc) — typed message-passing pipes with a sender and receiver
handle; one thread sends data, another receives it, avoiding shared memory
entirely [news.ycombinator](https://news.ycombinator.com/item?id=7851274)
-- **Mutex (`Mutex<T>`)** — short for _mutual
+
+- Mutex (Mutex<T>) — short for _mutual
exclusion_; only one thread can access the protected data at a time,
preventing data races on shared state
[earthly](https://earthly.dev/blog/rust-concurrency-patterns-parallel-programming/)
-- **Arc (`Arc<T>`)** — _Atomic Reference Counting_;
+
+- Arc (Arc<T>) — _Atomic Reference Counting_;
lets multiple threads share ownership of a value safely
[doc.rust-lang](https://doc.rust-lang.org/book/ch16-03-shared-state.html)
-- **`RwLock<T>`** — like a Mutex, but allows
+
+- RwLock<T> — like a Mutex, but allows
many simultaneous readers or one exclusive writer
-- **Atomic types** — low-level primitives (e.g.,
+
+- Atomic types — low-level primitives (e.g.,
`AtomicUsize`) for lock-free, thread-safe operations on simple values
[web.mit](https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/concurrency.html)
@@ -40,8 +45,8 @@ concurrency".
Rust enforces concurrency rules through two marker traits:
[web.mit](https://web.mit.edu/rust-lang_v1.25/arch/amd64_ubuntu1404/share/doc/rust/html/book/first-edition/concurrency.html)
-- **`Send`** — a type can be transferred (moved) to another thread
-- **`Sync`** — a type can be safely _referenced_ from multiple threads
+- `Send` — a type can be transferred (moved) to another thread
+- `Sync` — a type can be safely _referenced_ from multiple threads
simultaneously
These traits are automatically implemented by the compiler where safe, and