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

https://cppcon.org/
https://github.com/CppCon/CppCon2020
---
Performing bulk operations is more efficient than performing multiple single operations in many scenarios: memory allocations, I/O, IPC, etc.
At the same time, code that performs operations in bulk requires extra bookkeeping and boilerplate compared to equivalent code which operates on each individual item.
In this talk, we'll see how C++20 coroutines let us get the performance gains of executing operations in bulk, without the maintenance burden.

Often it’s easier to write code that executes on an item at a time rather than on multiple items: it’s easier to write an if condition than to call std::erase_if, it’s easier to call a function than calling std::transform.
When operating on an item at a time, it is also possible to use exceptions for error handling.
Once we change our code to operate on batches of items, the logic often looks completely different from the original one.

Could we keep our code as if we were processing an item at a time, but calling functions on multiple items behind the scenes?
What if we could aggregate all the arguments to a function into a collection, execute the function with the collection of arguments, and redistribute the results to each caller in a completely transparent way?

This talk will show how such a system could be implemented using coroutines.
It will show step by step how to implement a task and awaitable object which can suspend a function in a synchronous context and resume it once the underlying bulk operation has completed, and how to schedule such tasks.

Have you heard of coroutines but haven’t seen an application of them yet?
Did you read about all the new customization points introduced but haven’t still realized how to make use of them?
Are you looking for a practical and interesting use case for coroutines?
This talk is for you!
Join us to learn about a new way of creating powerful abstractions in modern C++.

---
Francesco Zoffoli

Francesco Zoffoli is a professional Software Engineer currently working for Facebook, building monitoring systems. Author of the book "C++ Fundamentals", passionate about programming languages and maintainable software, he has been using C++ throughout his career and personal projects. C++ is his language of choice due to its expressivity, especially its metaprogramming capabilities.

---
Videos Recorded & Edited by Digital Medium: http://online.digital-medium.co.uk

The CppCon YouTube Channel Is Sponsored By:
JetBrains : http://jb.gg/cpptools
SonarSource: https://www.sonarsource.com/

Filed under: Science & Technology

No comment yet, add your voice below!


Add a Comment