Use async_op_base::invoke

This commit is contained in:
Vinnie Falco
2019-02-16 15:09:34 -08:00
parent f41363c60c
commit 2e62f25701
7 changed files with 30 additions and 81 deletions
+6 -14
View File
@@ -302,21 +302,13 @@ async_echo(
// directly invoke the completion handler otherwise it could
// lead to unfairness, starvation, or stack overflow. Therefore,
// if cont == false (meaning, that the call stack still includes
// the frame of the initiating function) then use `net::post`
// to cause us to be called again after the initiating function
// returns. The function `bind_handler` works similarly to
// `std::bind`, allowing bound arguments to be passed to our
// completion handler during the dispatch, but also takes care
// of forwarding the allocator and executor customization points
// in the returned call wrapper.
// the frame of the initiating function) then we need to use
// `net::post` to cause us to be called again after the initiating
// function. The function `async_op_base::invoke` takes care of
// calling the final completion handler, using post if the
// first argument is false, otherwise invoking it directly.
if(! cont)
yield net::post(beast::bind_handler(std::move(*this), ec));
// The function `async_op_base::invoke` takes care of calling
// the final completion handler.
this->invoke_now(ec);
this->invoke(cont, ec);
}
}
};