Asynchronous query execution now depends on my own mostly C++ based parallel

execution framework instead of the QMetaObject::invokeMethod.
This commit is contained in:
Eelke Klein 2016-12-30 10:25:48 +01:00
parent 2432be9d72
commit 4dc55288b5
2 changed files with 6 additions and 10 deletions

View file

@ -148,18 +148,15 @@ void MainWindow::performQuery()
queryCancel = std::move(connection->getCancel());
QString command = ui->queryEdit->toPlainText();
queryFuture = std::async(std::launch::async, [this,command]()-> Pgsql::Result
std::thread([this,command]()
{
auto res = connection->query(command);
QMetaObject::invokeMethod(this, "query_ready", Qt::QueuedConnection); // queues on main thread
return res;
});
auto res = std::make_shared<Pgsql::Result>(connection->query(command));
QueueTask([this, res]() { query_ready(std::move(*res)); });
}).detach();
}
void MainWindow::query_ready()
void MainWindow::query_ready(Pgsql::Result dbres)
{
pg::Result dbres(std::move(queryFuture.get()));
if (dbres) {
auto st = dbres.resultStatus();
if (st == PGRES_TUPLES_OK) {