OnceCallback: Callback Design Lessons from Chromium
This directory systematically covers the design of modern C++ callback systems by implementing a Chromium-style OnceCallback component. The content is divided into two learning paths:
Complete Beginner Tutorial (full/)
Tailored for readers with no prior experience, starting with a review of fundamental C++ features and gradually guiding them to a complete component implementation.
Prerequisites (7 articles):
- OnceCallback Prerequisites Quick Reference: C++11/14/17 Core Features Review
- OnceCallback Prerequisites (Part 1): Function Types and Template Partial Specialization
- OnceCallback Prerequisites (Part 2): std::invoke and the Uniform Calling Convention
- OnceCallback Prerequisites (Part 3): Advanced Lambda Features
- OnceCallback Prerequisites (Part 4): Concepts and requires Constraints
- OnceCallback Prerequisites (Part 5): std::move_only_function (C++23)
- OnceCallback Prerequisites (Part 6): Deducing this (C++23)
Hands-on Practice (6 articles):
- OnceCallback in Practice (Part 1): Motivation and API Design
- OnceCallback in Practice (Part 2): Building the Core Skeleton
- OnceCallback in Practice (Part 3): Implementing bind_once
- OnceCallback in Practice (Part 4): Cancellation Token Design
- OnceCallback in Practice (Part 5): then Chaining
- OnceCallback in Practice (Part 6): Testing and Performance Comparison
Advanced Design Guide (hands_on/)
Tailored for readers experienced with C++ templates, providing a quick walkthrough of the design motivation, implementation strategies, and test verification.