F-Stack / f-stack

F-Stack is an user space network development kit with high performance based on DPDK, FreeBSD TCP/IP stack and coroutine API.
http://www.f-stack.org
Other
3.81k stars 890 forks source link

co_await support #597

Open unicomp21 opened 3 years ago

unicomp21 commented 3 years ago

I'm unclear on the coroutine support. Does f-stack support co_await (c++ 20), similar to asio?

https://github.com/chriskohlhoff/asio/blob/7fe18ba1b3e2bfddb2ef8dd83883b4545d8444bc/asio/include/asio/co_spawn.hpp#L73

Also, is there a websocket implementation using fstack?

jfb8856606 commented 3 years ago

You can see here for coroutine support, and the demo.

unicomp21 commented 3 years ago

Sorry, I must be confused. Can't see co_await anywhere.

jfb8856606 commented 3 years ago

F-Stack support coroutine, but not co_await.

unicomp21 commented 3 years ago

Why isn't there co_await support?

unicomp21 commented 3 years ago

Is there a way to do something like promises w/ microthread? Is there documentation or examples for how to use microthread?

jfb8856606 commented 3 years ago

Why isn't there co_await support?

Because co_await is officially defined by the ISO/IEC 14882:2020(C++20), but F-Stack's has been released for years and has supported coroutine with micro thread.

Is there a way to do something like promises w/ microthread? Is there documentation or examples for how to use microthread?

app/micro_thread can achieve synchronous programming and asynchronous execution.

A simple demo program is implemented use microthread in F-Stack, see demo. More documentation of microthread can see it's original repository. There are detailed comments in the code file, but the problem is that the comments are Chinese.

jfb8856606 commented 3 years ago

If no one submit pull requeset that use co_await to support coroutine, we will not modify it ourselves.

WoolenWang commented 3 years ago

micro_thread is a little hard for many people to learn. but it is a good implement.