diff --git a/demo/echo_server.cpp b/demo/echo_server.cpp index 4c6aa6f..a6f9685 100644 --- a/demo/echo_server.cpp +++ b/demo/echo_server.cpp @@ -21,7 +21,7 @@ int runningCoroutines = 0; uio::task<> accept_connection(uio::io_service& service, int serverfd) { while (int clientfd = co_await service.accept(serverfd, nullptr, nullptr)) { - // [=, &service](int clientfd) -> task<> { + [](uio::io_service& service, int clientfd) -> uio::task<> { fmt::print("sockfd {} is accepted; number of running coroutines: {}\n", clientfd, ++runningCoroutines); #if USE_SPLICE @@ -63,7 +63,7 @@ uio::task<> accept_connection(uio::io_service& service, int serverfd) { co_await service.close(clientfd); fmt::print("sockfd {} is closed; number of running coroutines: {}\n", clientfd, --runningCoroutines); - // }(clientfd); + }(service, clientfd); } } diff --git a/demo/file_server.cpp b/demo/file_server.cpp index ee8b1d7..e6b8ede 100644 --- a/demo/file_server.cpp +++ b/demo/file_server.cpp @@ -103,7 +103,7 @@ uio::task<> accept_connection(uio::io_service& service, int serverfd, int dirfd) while (int clientfd = co_await service.accept(serverfd, nullptr, nullptr)) { // Start worker coroutine to handle new requests - [=, &service](int clientfd) -> task<> { + [](uio::io_service& service, int dirfd, int clientfd) -> task<> { ++runningCoroutines; auto start = std::chrono::high_resolution_clock::now(); try { @@ -121,7 +121,7 @@ uio::task<> accept_connection(uio::io_service& service, int serverfd, int dirfd) clientfd, std::chrono::high_resolution_clock::now() - start); --runningCoroutines; - }(clientfd); + }(service, dirfd, clientfd); } }