Automatically Process Your Operations in Bulk With Coroutines - Francesco Zoffoli - CppCon 2021

Learn how to automatically process your operations in bulk using coroutines, a resumable function that can be suspended and resumed at specific points, with Francesco Zoffoli at CppCon 2021.

Key takeaways
  • A coroutine is a resumable function that starts in an executing state and can be suspended and resumed at specific points.
  • A coroutine handle is a non-owning pointer that controls the coroutine.
  • A batch is a collection of coroutines that can be executed concurrently, and a batcher is a class that manages the execution of these coroutines.
  • The co_await keyword is used to suspend and resume the execution of a coroutine.
  • A task is an object that represents a coroutine that has been submitted to an executor for execution.
  • An executor is an object that schedules and executes tasks.
  • The co_return keyword is used to return a value from a coroutine.
  • An awaitable is an object that can be awaited on using the co_await keyword.
  • A promise type is an object that represents a value that will be available at some point in the future.
  • A coroutine can be implemented to use symmetric transfer, where the compiler can remove some allocations.
  • The std::current_exception function can be used to get the current exception in a coroutine.
  • A library implementer can customize the behavior of the coroutine system by implementing specific functions.
  • The await_ready function is used to check if a coroutine is ready to be executed.
  • The maybe_execute function is used to decide whether a coroutine should be executed or not.
  • An exception can be thrown in a coroutine, and caught using the co_return keyword.
  • The co_await keyword can be used with an awaitable to suspend and resume the execution of a coroutine.
  • A batch can be used to store and retrieve a collection of coroutines.
  • An executor can be used to schedule and execute tasks.
  • A coroutine can be implemented to use a promise type to return a value.
  • A batcher can be used to manage the execution of coroutines.