C++ Concurrency and Parallelism — Expanded Project Guides
Generated from:
LEARN_CPP_CONCURRENCY_AND_PARALLELISM.mdThis folder contains deep-dive guides for each project in the C++ concurrency learning path.
Overview
These expanded project guides transform the project summaries from the C++ Concurrency and Parallelism learning path into comprehensive implementation guides. Each guide provides:
- Deep theoretical foundations — Understand concurrency concepts before building
- Solution architecture — See the shape of the solution without being given the code
- Phased implementation — Step-by-step guidance to keep you on track
- Testing strategies — Verify your concurrent code works correctly
- Common pitfalls — Avoid the race conditions and deadlocks others have encountered
- Real-world connections — See how these patterns are used in production systems
Project Index
| # | Project | Difficulty | Time | Key Focus |
|---|---|---|---|---|
| 1 | Multi-Threaded Log Aggregator | Beginner | Weekend | Threading fundamentals, mutex, condition variables |
| 2 | Promise-Based Task Coordinator | Intermediate | 1-2 weeks | Futures, promises, async patterns |
| 3 | Work-Stealing Thread Pool | Advanced | 2-4 weeks | Thread pool design, work scheduling |
| 4 | Spinlock and Read-Write Lock Library | Advanced | 1-2 weeks | Atomics, synchronization primitives |
| 5 | Lock-Free Stack | Expert | 2-4 weeks | Lock-free algorithms, ABA problem |
| 6 | Lock-Free MPMC Queue | Master | 3-4 weeks | Advanced lock-free, cache-friendly design |
| 7 | Parallel Image Processor | Intermediate | 1-2 weeks | Parallel algorithms, execution policies |
| 8 | Parallel Sort Benchmark Suite | Intermediate | 1 week | Performance analysis, parallel algorithms |
| 9 | Coroutine Generator Library | Expert | 2-3 weeks | C++20 coroutines, lazy evaluation |
| 10 | Async Task Framework | Master | 4-6 weeks | Coroutines, async runtime, schedulers |
| 11 | Async File I/O Library | Expert | 2-3 weeks | Coroutines, I/O, thread pool integration |
| 12 | SIMD Math Library | Advanced | 1-2 weeks | Vectorization, std::simd |
| 13 | Audio DSP with SIMD | Advanced | 2-3 weeks | Real-time audio, SIMD processing |
| 14 | Real-Time Game Physics | Expert | 4-6 weeks | Parallel physics, SIMD integration |
| 15 | Actor Model Framework | Master | 4-6 weeks | Message passing, supervision trees |
| 16 | Distributed Task Scheduler | Master | 6-10 weeks | Distributed systems, fault tolerance |
| Capstone | High-Frequency Trading Simulator | Master | 8-12 weeks | All concurrency concepts combined |
Learning Paths
Choose a path based on your goals:
Core Path (Essential Concurrency)
P1 → P2 → P3 → P4
Best for: Building solid multithreading fundamentals
Lock-Free Path (High Performance)
P1 → P4 → P5 → P6
Best for: Systems programming, performance-critical applications
Coroutines Path (Modern Async)
P1 → P2 → P9 → P10 → P11
Best for: Async programming, understanding C++20 coroutines
SIMD Path (Data Parallelism)
P1 → P7 → P12 → P13 → P14
Best for: Performance engineering, games, scientific computing
Full Stack Concurrency (Maximum Depth)
P1 → P3 → P5 → P10 → P15 → Capstone
Best for: Complete mastery, interview preparation
Complete Path (Everything)
P1 through Capstone
Best for: Maximum depth, preparation for HFT/systems work
Dependency Graph
┌─────────────────────────────┐
│ CAPSTONE: HFT Simulator │
│ (Everything Combined) │
└───────────┬─────────────────┘
│
┌─────────────────────────────────┼─────────────────────────────────┐
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ P16: Distrib │ │ P15: Actor │ │ P14: Game │
│ Scheduler │ │ Framework │ │ Physics │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │
└─────────────────────────────────┤ │
│ │
┌───────────────────┼─────────────────────────────────┤
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ P10: Async │ │ P6: Lock-Free │ │ P13: Audio │
│ Task Framewk │ │ MPMC Queue │ │ DSP + SIMD │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │
┌──────────────┤ │ │
│ │ │ │
▼ ▼ ▼ ▼
┌─────────────┐ ┌─────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ P11: Async │ │ P9: Coro │ │ P5: Lock-Free │ │ P12: SIMD │
│ File I/O │ │ Generator │ │ Stack │ │ Math Library │
└─────────────┘ └─────────────┘ └────────┬────────┘ └────────┬────────┘
│ │
│ │
┌────────────────────────────────────┤ │
│ │ │
▼ ▼ ▼
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ P3: Thread │ │ P4: Spinlock │ │ P7: Parallel │
│ Pool │ │ & RW Lock │ │ Image Proc │
└────────┬────────┘ └────────┬────────┘ └────────┬────────┘
│ │ │
│ │ │
└─────────────────┬───────────────┴─────────────────────────────────┤
│ │
▼ ▼
┌─────────────────┐ ┌─────────────────┐
│ P2: Promise │ │ P8: Parallel │
│ Task Coord │ │ Sort Bench │
└────────┬────────┘ └────────┬────────┘
│ │
└─────────────────┬───────────────────────────────┘
│
▼
┌─────────────────┐
│ P1: Log │
│ Aggregator │
└─────────────────┘
START
The Concurrency Hierarchy
These projects follow a natural progression through the concurrency hierarchy:
Level 5: Wait-Free Algorithms ─────────────┐
(P6: MPMC Queue) │
│
Level 4: Lock-Free Data Structures ─────────────┤
(P5: Lock-Free Stack) │
│ Projects 5-6, Capstone
Level 3: Atomics + Memory Ordering ─────────────┤
(P4: Spinlocks) │
│
Level 2: Condition Variables ─────────────┤
(P2: Futures/Promises) │
│ Projects 1-4
Level 1: Threads + Mutexes ─────────────┤
(P1: Log Aggregator) │
(P3: Thread Pool) │
│
Level 0: Single-Threaded ─────────────┘
Orthogonal Tracks:
├── Coroutines (P9, P10, P11)
├── SIMD (P12, P13, P14)
├── Actors (P15)
└── Distributed (P16)
Prerequisites for the Learning Journey
Before starting Project 1, you should have:
- C++ Fundamentals: Comfortable with RAII, move semantics, templates, and the STL
- Command Line: Familiar with Linux/Unix shell, basic compilation
- Debugging: Experience with debuggers (gdb, lldb) and sanitizers
- Conceptual Threading: Basic understanding of what threads are (no prior threading code required)
Recommended but not required:
- Some exposure to memory models and cache coherence
- Understanding of CPU architecture basics
- Experience with any concurrent programming (any language)
Reference Materials
Books (in order of importance)
- “C++ Concurrency in Action, Second Edition” by Anthony Williams
- The definitive C++ concurrency book
- Covers threading, atomics, parallel algorithms
- Referenced in most projects
- “The Art of Multiprocessor Programming” by Herlihy & Shavit
- Theoretical foundations of lock-free programming
- Essential for Projects 5-6 and Capstone
- “Modern X86 Assembly Language Programming” by Daniel Kusswurm
- For understanding SIMD at the hardware level
- Useful for Projects 12-14
- “Designing Data-Intensive Applications” by Martin Kleppmann
- For distributed systems concepts
- Essential for Project 16
Online Resources
- Stanford C++20 Coroutines Tutorial
- Preshing on Programming
- ModernesCpp.com - Excellent C++ concurrency articles
- cppreference.com - Definitive reference
How to Use These Guides
- Read the theoretical foundation first — Don’t jump to implementation
- Study the solution architecture — Understand the “shape” of the solution
- Follow the phased approach — Complete checkpoints before moving on
- Use the testing strategy — Verify concurrent code thoroughly
- Check your understanding — Complete the self-assessment checklist
- Try the extensions — Push yourself further
Project Comparison Table
| Project | Difficulty | Time | Depth | Fun Factor |
|---|---|---|---|---|
| 1. Log Aggregator | ⭐ | Weekend | ⭐⭐ | ⭐⭐⭐ |
| 2. Task Coordinator | ⭐⭐ | 1-2 weeks | ⭐⭐⭐ | ⭐⭐⭐ |
| 3. Thread Pool | ⭐⭐⭐ | 2-4 weeks | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| 4. Spinlock Library | ⭐⭐⭐ | 1-2 weeks | ⭐⭐⭐⭐ | ⭐⭐⭐ |
| 5. Lock-Free Stack | ⭐⭐⭐⭐ | 2-4 weeks | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| 6. Lock-Free Queue | ⭐⭐⭐⭐⭐ | 3-4 weeks | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| 7. Image Processor | ⭐⭐ | 1-2 weeks | ⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| 8. Sort Benchmark | ⭐⭐ | 1 week | ⭐⭐⭐ | ⭐⭐⭐ |
| 9. Generator Library | ⭐⭐⭐⭐ | 2-3 weeks | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| 10. Async Framework | ⭐⭐⭐⭐⭐ | 4-6 weeks | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| 11. Async File I/O | ⭐⭐⭐⭐ | 2-3 weeks | ⭐⭐⭐⭐ | ⭐⭐⭐⭐ |
| 12. SIMD Math | ⭐⭐⭐ | 1-2 weeks | ⭐⭐⭐ | ⭐⭐⭐ |
| 13. Audio DSP | ⭐⭐⭐ | 2-3 weeks | ⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| 14. Game Physics | ⭐⭐⭐⭐ | 4-6 weeks | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| 15. Actor Framework | ⭐⭐⭐⭐⭐ | 4-6 weeks | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| 16. Dist. Scheduler | ⭐⭐⭐⭐⭐ | 6-10 weeks | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
| Capstone: HFT | ⭐⭐⭐⭐⭐ | 8-12 weeks | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐⭐ |
For the original project summaries, see LEARN_CPP_CONCURRENCY_AND_PARALLELISM.md