-
Notifications
You must be signed in to change notification settings - Fork 159
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new feature needed : suport coroutine for co_yield c++20 #305
Comments
Would you mind giving more context about what you need to implement? |
I have a websocket server eventloop (just one thread for all user, all client sockets, just like node.js) , when the eventloop recieved user's request, it will select data from cliclhouse and response . one eventloop loops again and again to deal users sockets. (I just call them first loop, second loop ... ) if one user's return data is huge , the other users will be blocked because of one eventloop for all sockets. so I hope coroutine can help me . for example: if a user's return data from clickhouse is large , the return data can be seperated for several parts to response one by one. after the first part sent back to the user in first loop, the clickhouse select will be coyeild, and then jump to deal the other's request, after first loop end, the eventloop run the second loop. in second loop, the clickhouse select result will be resumed to send next parts of the return data for this user untill all parts be sent. in coroutine generator, the deal function should have a coroutine return type : std::generator but here is a lumbda in client.Select( {} ); and I dont kown how to difine the generator. If you have time, you can refer this: int intn = 10;
std::generator<int> g_int = [&]() -> std::generator<int> {
for (int i = 0; i < intn; i++) co_yield i;
}();
size_t count_int = 0;
auto it_int = g_int.begin();
for (int i = 0; i < 30; ++i) {
if (it_int == g_int.end()) break;
decltype(auto) m_int = *it_int;
it_int++;
printf("%d ---- int !!\n", m_int);
} thank you ! |
A good idea |
The checklist :
@Enmk Please give me your advice, thanks |
Due to network interaction repeatedly in one requset-response, the async interfaces will use coroutine inside. |
I don't think that health checks (of CH server, I assume) and load balancing (aside from #310) should be implemented in this library. Also, sine one Perhaps one might want to implement some sort of |
please do not use asio coroutines/ your own coroutines, instead provide callback api, which may be used with any coroutines |
The text was updated successfully, but these errors were encountered: