MCPcopy Create free account
hub / github.com/Codesire-Deng/co_context / server

Function server

example/redis_echo_MT.cpp:19–26  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17}
18
19task<> server() {
20 acceptor ac{inet_address{port}};
21 uint32_t turn = 0;
22 for (int sockfd; (sockfd = co_await ac.accept()) >= 0;) {
23 worker[turn].co_spawn(reply(co_context::socket{sockfd}));
24 turn = (turn + 1) % worker_num;
25 }
26}
27
28int main() {
29 balancer.co_spawn(server());

Callers 1

mainFunction · 0.70

Calls 3

acceptMethod · 0.80
replyFunction · 0.70
co_spawnMethod · 0.45

Tested by

no test coverage detected