What is the Sender abstraction in stdexec?
mainThe Sender abstraction is a foundational model for asynchronous programming in C++, serving as the reference implementation for the std::execution framework proposed for C++26.
Unlike legacy mechanisms (like std::async, futures, or callbacks), the Sender abstraction provides a compositional model that separates the what (the computation) from the where (the execution context/scheduler).
Key benefits include:
- Unified Model: Works across compute, I/O, networking, and UI.
- Zero-Overhead Composition: Uses compile-time plumbing to avoid runtime allocations or reference counting.
- Structured Control: Built-in support for cancellation and error handling.
- Coroutine Integration: Senders can be directly
co_await-ed within coroutines. - Customization: Allows plugging in custom schedulers, adaptors, allocators, and stop tokens.