Skip to content

Commit

Permalink
Use net::bind_executor instead net::post
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackarain committed Jan 27, 2024
1 parent 825753e commit c7f784d
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions proxy/include/proxy/proxy_server.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3415,19 +3415,18 @@ R"x*x*x(<html>
[this, p = p]
(auto&& handler) mutable
{
auto bound_handler = net::bind_executor(
net::get_associated_executor(handler),
std::move(handler)
);

std::thread(
[this, p = p, handler = std::move(handler)]() mutable
[this, p = p, bound_handler = std::move(bound_handler)]() mutable
{
boost::system::error_code ec;
auto hash = file_hash(p, ec);

auto ex = net::get_associated_executor(handler);

net::post(ex,
[handler = std::move(handler), ec, hash]() mutable
{
handler(ec, hash);
});
bound_handler(ec, hash);
}
).detach();
}, token);
Expand Down

0 comments on commit c7f784d

Please sign in to comment.