Skip to content

research: async support for cpp binding #3156

@silver-ymz

Description

@silver-ymz

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions