void * ServeThread(void * vargp) { Pthread_detach(pthread_self()); while (1) { int connfd = sbuf_remove(&ClientPool); fprintf(stderr, "Thread %llu handling request %d.\n", (unsigned long long int)pthread_self(), connfd); ServeClient(connfd); Close(connfd); fprintf(stderr, "Thread %llu's request %d ended.\n", (unsigned long long int)pthread_self(), connfd); } }
task Server() { Tcp::Listener s; for (;;) ServeClient(co_await s.Accept()); }