Skip to content

C++ : Asynchronous C++20/23 Programming Practice Using Coroutine and Generator #357

Description

@kimpro82

Project "Caffeine-Flow" ☕🚀

1. Executive Summary & Objective

Modern software engineers run on caffeine, but our codebases rarely reflect this vital dependency. Project "Caffeine-Flow" is a dedicated hands-on practice framework designed to master modern C++ asynchronous programming.

The primary objective is to gain deep, practical proficiency by Using Coroutine and Generator along with Ranges and Monadic Error Handling, building a high-performance, asynchronous beverage supply pipeline. This ensures that developer learning curves are conquered while keeping caffeine levels at an absolute maximum.


2. Technical Stack & Practice Scope

To achieve maximum over-engineering and master modern C++ features, the practice implementation must leverage:

  • Language Standard: C++23 (utilizing modern standard generators and monadic error handling).
  • Core Practice Modules:
    • C++20 Coroutines (co_await, co_yield) for non-blocking hardware control and state transitions.
    • C++23 std::generator for lazy evaluation and streaming large data sets on demand.
    • C++20 std::ranges for declarative filtering and pipeline transformations.
    • C++23 std::expected for safe, exception-free monadic error propagation.
    • C++20 Concepts for robust compile-time type constraints on custom awaitables.

3. Functional Requirements & Architecture

3.1. Asynchronous Task Control (co_await)

  • Implement custom awaitables to simulate non-blocking water boiling and hardware latency without locking the main execution thread.
  • Practice precise control over coroutine_handle and suspension points.

3.2. Lazy Infinite Data Stream (std::generator)

  • Construct an infinite, memory-efficient data stream using C++23 std::generator to yield cups of coffee dynamically only when requested.

3.3. Stream Filtering and Transformation (std::ranges)

  • Apply std::views to filter out sub-par or unwanted beverage parameters declaratively from the generator stream.

3.4. Reactive Error Management (std::expected)

  • Practice modern error handling by returning std::expected through coroutine boundaries, gracefully handling catastrophic hazards like "Grinder on Fire" without try-catch performance penalties.

4. Acceptance Criteria

  • Successfully compile and execute coroutine and generator code under a C++23 compliant compiler (GCC 13+, Clang 16+, MSVC 2022+).
  • Demonstrate a clear understanding of the lifecycle between coroutine_handle, promise_type, and consumer loops.
  • Zero deadlocks caused by blocking I/O or improper suspension handling.
  • Peer code review successfully completed with the --enable-more-espresso practice flag.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions