Skip to content

Commit

Permalink
demo: try fixing CarterLi#9
Browse files Browse the repository at this point in the history
  • Loading branch information
CarterLi committed Apr 5, 2022
1 parent 9fd2590 commit ae0a512
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions demo/echo_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}

Expand Down
4 changes: 2 additions & 2 deletions demo/file_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
}
}

Expand Down

0 comments on commit ae0a512

Please sign in to comment.