Intro to C++ Coroutines: Concept -- Ilya Doroshenko

Coroutine.pngThe time has come, fellow devs. We are on our way to uncover the newest concept of C++ language – Coroutines.

Intro to C++ Coroutines: Concept

By Ilya Doroshenko

From the article:

The newest concept of C++ language, Coroutines, is already used by several programming languages, like

  • C# async tasks and yield iterables, forming LINQ base;
  • JS with awaitables, replacing the old way of making consecutive calls, that was hard to understand did a lot of code identation for cases that required a lot of async execution;
  • Python with synchronous generator
  • etc.

They were introduced in the recent C++20 standard. However, instead of handy classes such as Task<> and std::generator<> we received a complex and low-level toolkit to make our own promises and futures. Only C++23 gave us our first usable coroutine type (std::generator<>). It seems like the C++ committee followed the quote: “give a man a fish and you feed him for a day; teach a man to fish and you feed him for a lifetime”.

Today we will discuss what is needed to understand coroutines, and in the later chapters we will make our own little coroutine.

Add a Comment

Comments are closed.

Comments (0)

There are currently no comments on this entry.