Closed anarthal closed 1 month ago
That would look good to me if Chris didn't add partial completion tokens :). This should be legal:
co_await conn.async_prepare_statement(..., with_diagnostics);
In order for that to work, you'll need to
with_diagnostic
a token itself, e.g. constexpr static partial_with_diagnostic with_diagnostic;
And then do this
template <typename... Signatures>
struct async_result<boost::mysql::partial_with_diagnostic, Signatures...>
{
template <typename Initiation, typename RawCompletionToken, typename... Args>
static auto initiate(Initiation&& initiation,
RawCompletionToken&&, Args&&... args)
-> decltype(
async_initiate<
const as_tuple_t<
default_completion_token_t<associated_executor_t<Initiation>>>&,
Signatures...>(
static_cast<Initiation&&>(initiation),
boost::mysql::with_diagnostics_t<
default_completion_token_t<associated_executor_t<Initiation>>>{},
static_cast<Args&&>(args)...))
{
return async_initiate<
const as_tuple_t<
default_completion_token_t<associated_executor_t<Initiation>>>&,
Signatures...>(
static_cast<Initiation&&>(initiation),
boost::mysql::with_diagnostics_t<
default_completion_token_t<associated_executor_t<Initiation>>>{},
static_cast<Args&&>(args)...);
}
};
For that to work your initiations need an associated_executor (executor_type typedef & get_executor function). They should have that anyhow so all of asio's cancel_after
and cancel_at
adaptors/partial tokens work. Some of them grab the executor the same way so this is valid:
co_await conn.async_prepare_statement(... , asio::cancel_after(std::chrono::seconds(5));
Sorry for giving you more work.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 98.71%. Comparing base (
36dc476
) to head (189608a
).
Made with_diagnostics(deferred) the default token for any_connection and connection_pool. throw_on_error is now marked as legacy.
close #329 close #296