How tango-tango/cask works
This project is a C++ header-only library (with a few source files) designed to build asynchronous and event-driven programs using reactive and functional programming ideas. Its main purpose is to provide lazy, composable constructs—namely Task and Observable—to help users build cooperative, highly concurrent applications even on single-threaded environments. The library is built with C++17 and supports various building blocks such as fibers, schedulers, pools, and deferred operations.
Project’s Main Components
• Task: Represents the lazy, asynchronous computation. Label its core functions (e.g., eval, flatMap, map, etc.).
• Observable: Models reactive streams and event flows, offering operations like filter, flatMap, and take.
• Execution and Concurrency Infrastructure:
• Scheduler: Illustrate the different scheduler types provided (e.g., BenchScheduler, SingleThreadScheduler, and WorkStealingScheduler) which run the event loop.
• Fiber: Represent the fiber components (CurrentFiber, FiberOp, FiberValue, etc.) that make cooperative multitasking possible.
• Supporting Components:
• Deferred & Promises: Show that these modules support asynchronous operations.
• MVar, Pool, Resource, List, and Queue: Include these as auxiliary components that handle state, resource management, and concurrency control.
• Build and Integration:
• Although primarily a header-only library, note the separation of public API (in the include folder) and core implementation (in the src folder). Include a block representing Meson build system integration.
• Testing Infrastructure:
• Optionally, note the test modules as a verification layer, which indicates how each component is tested through unit tests in the test directory.
Relationships and Data Flow
• That Observables can depend on or compose with Tasks and vice versa.
• Interdependency between the Scheduler and helper modules (like the pool or deferred operations) that work behind the scenes to manage concurrency.
• That components like MVar and Queue are used within the Observable implementations for managing state and backpressure.
Architectural Patterns and Design Principles
• Functional Composition: Clearly show that Tasks and Observables use monadic operations (map, flatMap, filter, etc.) to compose asynchronous operations.
• Lazy Evaluation: Use annotations to note that these constructs do not execute until explicitly run, which is essential for testability and dependency injection.
• Concurrency & Cooperative Multitasking: Illustrate the role of fibers and various schedulers, showing how they abstract away the low-level concurrency details.
Final Checklist
• Component (Task, Observable, Scheduler, Fiber, etc.) is accurately labeled.
• Notes on architectural patterns such as lazy evaluation, monadic composition, and dependency injection to highlight design decisions.