Asynchronous query execution now depends on my own mostly C++ based parallel
execution framework instead of the QMetaObject::invokeMethod.
This commit is contained in:
parent
2432be9d72
commit
4dc55288b5
2 changed files with 6 additions and 10 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,6 @@ private:
|
|||
std::unique_ptr<QueryExplainModel> explainModel;
|
||||
|
||||
Pgsql::Canceller queryCancel;
|
||||
std::future<Pgsql::Result> queryFuture;
|
||||
std::future<std::unique_ptr<ExplainRoot>> explainFuture;
|
||||
|
||||
struct {
|
||||
|
|
@ -74,6 +73,7 @@ private:
|
|||
// } queryState;
|
||||
|
||||
void processNotice(const PGresult *result);
|
||||
void query_ready(Pgsql::Result res);
|
||||
private slots:
|
||||
|
||||
void startConnect();
|
||||
|
|
@ -81,7 +81,6 @@ private slots:
|
|||
void performQuery();
|
||||
void performExplain();
|
||||
void socket_activate_connect(int socket);
|
||||
void query_ready();
|
||||
void explain_ready();
|
||||
void cancel_query();
|
||||
void receiveNotice(Pgsql::ErrorDetails notice);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue