Skip to content

Components

Components

Pieces of the labs and the cookbook that are usable as they stand, each with the page that explains it and the judge that holds it green under scripts/build_all.sh on every push. All of it is MIT. Copy the file, not the page; the banner at the top of each file says which chapter quotes it, and editing one means editing that chapter in the same commit.

Component File What it is Explained in Judged by
A C handle that frees itself exercises/cookbook/handles.cpp Recipe 7: a unique_ptr alias with the C API's own close function as its deleter, and an open function that returns it — a failed open is a null handle no deleter touches Recipe 7 in Appendix F, Chapter 1 the TU's own main, under the canonical flags
A test framework in forty lines exercises/testlab/tiny_test.h register, check, report — the three jobs of any test framework, with no dependency Chapter 28 buffer_test.cpp, a suite that must go red when the code is broken
A main-thread queue with a deadline on every wait exercises/bridgelab/main_thread_queue.h, with exercises/bridgelab/bridge_core.h and exercises/bridgelab/host.h foreign code posts a job and waits with a timeout; the host drains on its own thread; a frozen command registry and the host-adapter seam Chapter 38 the lab's main.cpp, under ASan/UBSan and again under TSan, every wait bounded
Join, a type-dispatching if constexpr, and Ring<T, N> exercises/templatelab/util.h the three templates every codebase ends up writing Chapter 41 the lab's main.cpp, plus a build that must be refused by name
A formula evaluator over injected objects exercises/exprlab/expr.h and exercises/exprlab/expr.cpp tokens as a variant, a tree behind unique_ptr, recursive descent with a value-or-error at every level, a depth limit, a provider seam Chapter 42 a hand-computed value table, error positions, the depth limit at N and N+1, a German locale where the machine has one
A project skeleton: presets, sanitizer option, clang-format, clang-tidy exercises/skeleton/ Chapter 26's layout as a directory to copy — root, src/, tests/, include/myplugin/, a dev and a release preset Chapter 26 its own CTest under the dev preset; clang-format --dry-run --Werror and clang-tidy in CI
A copy/move-counting type with a CHECK judge exercises/choosing/counted.h the instrument Appendix H prices every signature with; CHECK survives Release where assert does not Appendix H, Chapter 6 passing.cpp and storing.cpp, once more under -fno-elide-constructors
A bump allocator, and the layout that stops false sharing exercises/cost/allocating.cpp one block, a moving pointer and std::align; no Free, which is the trade — plus the padded and unpadded counter pair Appendix L the allocation counter: 501 allocations become 1, and 0 through std::pmr over a stack buffer
An allocation counter exercises/perflab/main.cpp a replaced operator new and delete with a counter — the judge that a timing cannot be Chapter 36 zero allocations per tick, at 50 ticks and at 1000
A Tracer solutions/tracer.cpp a class that prints from every special member function, so a container or a call shows what the compiler chose Chapter 14, Finding 11 in Chapter 25 the predicted output
A refcounted-handle wrapper: adopt and share as named constructors exercises/comlab/ref.h the Rule of Five doing the counting for a COM-shaped API, no bare Retain or Release below it Chapter 35 the vendor's live-object counter at zero, and the sanitizers
Two vendor stand-ins, a refcounted third and a C++-native fourth exercises/fakesdk/, exercises/fakedevice/, exercises/comlab/FakeSDK2.h, exercises/framelab/FakeUi.h error codes and owned payloads; opaque handles and C callbacks; a refcounted 2.0; a framework with parent-owned nodes and its own weak handle — for practising against a vendor shape with no vendor Chapter 17, Chapter 18, Chapter 35, Chapter 44 built-in leak detectors that must report zero
A bounded single-producer, single-consumer ring exercises/deadlinelab/spsc_queue.h two atomic indices with one writer each, release to publish and acquire to consume, padded onto separate cache lines; TryPush and TryPop never wait, and the element type is asserted trivially copyable and the index lock-free — so it is safe from a signal handler too Chapter 43 the lab's main.cpp: order, completeness and zero allocations on the deadline thread, under ASan/UBSan and again under TSan; check_platform_claims.sh for what the relaxed variant does per instruction set
An allocation counter for one thread exercises/deadlinelab/main.cpp Chapter 36's replaced operator new behind a thread_local flag, so the worker may allocate and the deadline thread is judged alone Chapter 43 zero on the deadline thread in both of the lab's phases, the second of which includes a signal handler