apache / opendal

Apache OpenDAL: One Layer, All Storage.
https://opendal.apache.org
Apache License 2.0
3.44k stars 481 forks source link

research: How to support async API for C binding? #1741

Open Xuanwo opened 1 year ago

Xuanwo commented 1 year ago

So far, I have no idea on how to support async API in C, we need some research and help from community.

https://en.cppreference.com/w/cpp/thread/async https://www.boost.org/doc/libs/1_76_0/doc/html/boost_asio.html

messense commented 1 year ago

We can probably learn from hyper: https://github.com/hyperium/hyper/tree/master/src/ffi

nasen23 commented 1 year ago

Is c binding being worked on? I think I could get my hands on some harder work. Please assign this to me if no one else is working on it. It might take quite some time though🥹.

Xuanwo commented 1 year ago

Go ahead and have fun! Maybe we can start with blocking api first.

xyjixyjixyji commented 1 year ago

It seems hyper let async task returns a Future, and used push_executors to push them to the executors, which further poll the task until completion.

Looks like a minimal async runtime in C 🤣 🤣 🤣 , anyone interested could check this for more details.

I think now maybe the C binding could be developed in the following order, and we still have plenty of time to think about our implementation of async operation.

  1. Focus on the memory operator first, making it full-fledged.
  2. Support other services, but only for blocking services.
  3. Support the async operations.

Any ideas?