Function execSqlAsyncFuture

Synopsis

#include <orm_lib/inc/drogon/orm/DbClient.h>

template <typename... Arguments>
std::future< Result > execSqlAsyncFuture(const std::string &sql, Arguments &&... args) noexcept

Description

Async and nonblocking method.

Mentioned in

Source

Lines 118-131 in orm_lib/inc/drogon/orm/DbClient.h.

template <typename... Arguments>
std::future<Result> execSqlAsyncFuture(const std::string &sql,
                                       Arguments &&... args) noexcept
{
    auto binder = *this << sql;
    (void)std::initializer_list<int>{
        (binder << std::forward<Arguments>(args), 0)...};
    std::shared_ptr<std::promise<Result>> prom =
        std::make_shared<std::promise<Result>>();
    binder >> [=](const Result &r) { prom->set_value(r); };
    binder >> [=](const std::exception_ptr &e) { prom->set_exception(e); };
    binder.exec();
    return prom->get_future();
}





Add Discussion as Guest

Log in to DocsForge