finds.dev← search

// the find

chenshuo/recipes

★ 1,911 · C++ · BSD-3-Clause · updated Dec 2024

Some code snippets for sharing

A collection of standalone C++ (and some Java/Python) code snippets by Chen Shuo, author of the muduo network library. The most valuable parts are the step-by-step reactor pattern implementation and the production-grade async double-buffered logger. It reads as a companion to his book on Linux multi-threaded server programming.

The reactor/ directory builds an event loop from scratch across numbered snapshots (s00 through s04+), with .diff files between steps — unusually honest pedagogy that shows the reasoning, not just the destination. The datetime module includes LaTeX derivations of the date calculation math alongside the C++ implementation, which is exactly the kind of documentation that normally lives only in the author's head. The faketcp implementation — TCP over TUN devices in userspace — is a rare working example of the concept that most blog posts only gesture at. The async double-buffered logger is real production code pulled from muduo, demonstrating a practical high-throughput logging technique with benchmarks to back it up.

There is no unified build system: some directories use Makefile, some use hand-rolled build.sh scripts, one (benchmark/) uses Bazel — you will spend time untangling dependencies before anything compiles. Half the code implicitly depends on muduo being installed and available, which is not documented anywhere obvious. The Java and Python subtrees feel like leftovers from a course or talk; they are largely disconnected from the C++ material and add noise without adding value. The repo has not seen meaningful additions since around 2018 despite the 2024 last-push date, so anything touching modern C++ (moves, ranges, coroutines) is absent.

View on GitHub →

// want more like this?

We dig through GitHub every week and send a few repos picked for what you actually care about — each with an honest take like this one.

Get finds in your inbox → Search again →