In cpp side, I come up with following ways:
std: C++11 provides std::async and std::future, C++20 provides coroutine. We can expose API compatible with the standard library. Cons: Maybe we need to limit cpp version to at least c++20.
asio: We have used Boost as a dependency. So we can integrate asio runtime to expose our async API. This is the most common way and does not require importing more dependencies.
- Other async library: There is other popular async library, e.x.
libevent, libuv.
- Custom async runtime: We can expose a small async runtime similar to
tokio, like hyper C API. This provides maximum flexibility and performance.
Solutions of some popular cloud sdk:
Gcp use std, but havn't completed until now.
AWS and Azure use custom async runtime.
I prefer to use std, because it provides more flexibility than asio。And compared with custom runtime, std is easier to use and less expensive to learn.
I plan to make async operations as an option and default to on. If users can't accept high version, they can just use c++11 with our sync API.
About rust side, cxx's native async support is still on the way. It plans to support std. Currently, it recommends to use synchronous channel to expose async operation.
In cpp side, I come up with following ways:
std: C++11 providesstd::asyncandstd::future, C++20 providescoroutine. We can expose API compatible with the standard library. Cons: Maybe we need to limit cpp version to at least c++20.asio: We have usedBoostas a dependency. So we can integrate asio runtime to expose our async API. This is the most common way and does not require importing more dependencies.libevent,libuv.tokio, likehyperC API. This provides maximum flexibility and performance.Solutions of some popular cloud sdk:
Gcpusestd, but havn't completed until now.AWSandAzureuse custom async runtime.I prefer to use
std, because it provides more flexibility thanasio。And compared with custom runtime,stdis easier to use and less expensive to learn.I plan to make async operations as an option and default to on. If users can't accept high version, they can just use c++11 with our sync API.
About rust side,
cxx's native async support is still on the way. It plans to supportstd. Currently, it recommends to use synchronouschannelto expose async operation.