Concurrency, Async, and Waiting: Fifteen Guides on Threads, Coroutines, and Waking Up
Fifteen guides about work that happens at the same time: threads that wait and wake, coroutines that suspend and resume, and the calls that tell a program something changed.
Written November 11, 2026 · Tested with GCC 13 · 5 min read
- What this page is
- Threads, pools, and parallel work — 5 guides
- Coroutines and async — 7 guides
- Waiting and waking — 3 guides
What this page is
An index of the fifteen guides on the site about concurrency, async work, and waiting. Each line states what the guide builds, proves, or measures, in the guide's own words, and links to the guide, which carries the full code, the compiler output, and the measured numbers.
Threads, pools, and parallel work — 5 guides
- How Fast Do std::latch and std::barrier Wake Threads? Measured — 9 to 68 Times Faster Than a Condition Variable — On the same Linux box, std::latch wakes a waiting thread in 364 nanoseconds where a mutex and condition_variable take 4,342, 11.9 times slower at 2 threads, 68.1 times at 8. std::barrier beats a hand-rolled condition-variable barrier by 1.4 to 1.8 times per phase. The published latency tables assert both numbers without measuring either.
- How Fast Does std::jthread Actually Stop? Measured Shutdown Latency — A std::jthread worker that polls its stop token every 100 ms takes a median 46 to 73 ms to stop after request_stop. The same worker waiting on a condition variable stops in about 0.10 ms. Measured on GCC 13 and Clang 18.
- Rust Lazy Statics, Measured: OnceLock vs LazyLock vs lazy_static — and the 2x Claim That Does Not Reproduce — Three ways to build a lazy static in Rust, measured on the same box: steady-state access and contended first init, three reps each. OnceLock is 1.24x faster than lazy_static, not 2 times.
- Go errgroup Worker Pool: The Race the Compiler Won't Catch — Build a bounded errgroup worker pool in Go, watch the race detector fail it with five data races, fix it with one mutex, and learn the SetLimit ceiling, the cancellation timing, and the deadlock trap.
- GNU Parallel Is Slower Than Serial: xargs -P vs GNU Parallel vs Serial, Measured — GNU Parallel, the tool built for parallelism, is slower than a serial loop at every job count on short jobs, and floors at about 0.61 seconds on the heavy arm while xargs keeps scaling to 11.90 times.
Coroutines and async — 7 guides
- C++20 Coroutine Pitfalls: Three Fixtures, Three Compilers, Same Answer — Three small coroutine programs, each run on GCC 13, GCC 16, and Clang 18 at C++20 with byte-identical output: eager versus lazy start, frame destruction on an early exit, and a lazy task that runs nothing until resumed.
- C++20 Coroutines to C++23 std::generator: Hand-Rolled Machinery, Then the Standard Type — Write a coroutine generator from scratch with a promise type, Task, and Generator, then replace it with C++23 std::generator and pipe it through ranges views, tested on GCC 13 and GCC 14, with the GCC 13 failure and the single-pass crash shown.
- What Does std::generator Cost, Measured? — Summing 10 million values costs 0.024 seconds through std::generator and 0.014 through a plain loop on GCC 14, 1.6 to 1.8 times, while a views::iota pipeline ties the loop at zero allocations, and a second pass over a consumed generator is undefined behavior that segfaults on this libstdc++.
- C++20 Coroutines + io_uring: A co_await File Read That Actually Runs — A hand-rolled C++20 coroutine reads a file through io_uring with no coroutine library: one pump, 36 bytes, content verified. liburing 2.16 built from source, GCC 13.3.0, and the two fixes the build needed.
- Tokio Backpressure: Bounded Channels and Semaphore-Limited HTTP Fan-Out — Bound a Tokio pipeline at both ends: a bounded mpsc channel that parks the sender, and a semaphore whose placement decides whether 50 tasks exist or 5 do, tested with Tokio 1.53.2 and Rust 1.99.1.
- Testing Cancellation with Go's synctest Bubble: 5 Seconds in 0.00 — A 5-second deadline fires at exactly 5 seconds of virtual time and 0.00 seconds of real time inside a synctest bubble. This guide tests an errgroup pool's cancellation deterministically, explains what the bubble does and does not fake, and shows the race-detector sanity check on the same pool.
- The future nobody kept — A short C++ program with a bug: the future nobody kept. The answer, the observed output, the fix, and the lesson are in this tutorial.
Waiting and waking — 3 guides
- epoll vs poll vs select, Measured: Where the Crossover Actually Is — One wait call over 10,000 idle file descriptors costs poll 0.30 ms and epoll 0.0003 ms. Wake latency ties at 10 fds and differs 30-fold at 10,000. Measured on Linux with 30 reps per cell, plus the ready-first control and the 511-pipe select ceiling.
- Waking a Thread: pipe vs eventfd vs signalfd, Measured — Pipe, eventfd, and signalfd all wake a blocked thread in ~0.04 ms. The difference is 1,000 events: pipe keeps all 1,000, eventfd counts them, signalfd keeps one.
- inotify vs Polling: Measured Wake Latency, Queue Overflow, and the Non-Recursive Trap — A blocked inotify read wakes in about 0.087 milliseconds. A 10 millisecond stat poller takes about 6.1 milliseconds on median, and a 100 millisecond poller about 40.9 milliseconds. The queue holds exactly 16,384 events before it overflows, and a directory watch never sees a grandchild change.
Also on the site
- Modern C++ Guides: C++20 and C++23, Built and Run — the nineteen Modern C++ guides, including six of the coroutine and synchronization guides above.
- Measured Comparisons: 30 Head-to-Head Guides, November 9–10, 2026 — the full measured series, including nine of the guides above.
Related guides on this site
Keep Exploring
Paste a [Service] section and get a plain-language verdict on every sandboxing setting it finds.
Paste sshd -G output and get a hardening verdict on the values your server actually runs.
Paste a server block and get WebSocket, TLS, HSTS, and proxy-header verdicts.
Paste a systemd timer expression and get the specific reason it fails, the normalized form, and the past-date traps the built-in check hides.
The full sysadmin hub \u2014 systemd, cgroups, file tools, and measured Linux comparisons.