Skip to content

Commit

Permalink
explicit shared_from_this
Browse files Browse the repository at this point in the history
  • Loading branch information
anarthal committed Dec 13, 2023
1 parent 2d31efe commit a158d41
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ class basic_pool_impl : public std::enable_shared_from_this<basic_pool_impl<IoTr
wait_group wait_gp_;
asio::experimental::concurrent_channel<void(error_code)> cancel_chan_;

std::shared_ptr<this_type> shared_from_this_wrapper()
{
// Some compilers get confused without this explicit cast
return static_cast<std::enable_shared_from_this<this_type>*>(this)->shared_from_this();
}

void create_connection()
{
all_conns_.emplace_back(params_, ex_, conn_ex_, shared_st_);
Expand Down Expand Up @@ -272,7 +278,7 @@ class basic_pool_impl : public std::enable_shared_from_this<basic_pool_impl<IoTr
async_run(CompletionToken&& token)
{
return asio::async_compose<CompletionToken, void(error_code)>(
run_op(this->shared_from_this()),
run_op(shared_from_this_wrapper()),
token,
ex_
);
Expand All @@ -293,7 +299,7 @@ class basic_pool_impl : public std::enable_shared_from_this<basic_pool_impl<IoTr
)
{
return asio::async_compose<CompletionToken, void(error_code, ConnectionWrapper)>(
get_connection_op(this->shared_from_this(), timeout, diag),
get_connection_op(shared_from_this_wrapper(), timeout, diag),
token,
ex_
);
Expand Down

0 comments on commit a158d41

Please sign in to comment.