For example, many functions in ASIO is callback-style (e.g. async_read_some()
), and NVIDIA stdexec or Facebook libunifex is based on Senders model (std::execution
).
How to make callback-style function and Senders model work together?
For example, many functions in ASIO is callback-style (e.g. async_read_some()
), and NVIDIA stdexec or Facebook libunifex is based on Senders model (std::execution
).
How to make callback-style function and Senders model work together?
Copyright © 2021 Jogjafile Inc.
Saying Asio async functions are "callback style" is probably not a fair summarization.
The "handler" is actually a Completion Token:
It is true that the callback signature is kind of the "smallest common denominator" on which all the other behaviors are built. For this to work it is important to realize that handlers can be stateful (and move-only).
I'm not acquainted with the senders model. Given concrete code that I can run and test locally, I might be able to draw up a custom completion token that does the integration.
Mind you, when I see the actual form that code takes, the conclusion might be that it's easier to integrate things on the level of event loops. This is often the way to integrate in e.g. game engines or GUI frameworks.