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());
|
queryCancel = std::move(connection->getCancel());
|
||||||
|
|
||||||
QString command = ui->queryEdit->toPlainText();
|
QString command = ui->queryEdit->toPlainText();
|
||||||
queryFuture = std::async(std::launch::async, [this,command]()-> Pgsql::Result
|
std::thread([this,command]()
|
||||||
{
|
{
|
||||||
auto res = connection->query(command);
|
auto res = std::make_shared<Pgsql::Result>(connection->query(command));
|
||||||
QMetaObject::invokeMethod(this, "query_ready", Qt::QueuedConnection); // queues on main thread
|
QueueTask([this, res]() { query_ready(std::move(*res)); });
|
||||||
return res;
|
}).detach();
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::query_ready()
|
void MainWindow::query_ready(Pgsql::Result dbres)
|
||||||
{
|
{
|
||||||
pg::Result dbres(std::move(queryFuture.get()));
|
|
||||||
if (dbres) {
|
if (dbres) {
|
||||||
auto st = dbres.resultStatus();
|
auto st = dbres.resultStatus();
|
||||||
if (st == PGRES_TUPLES_OK) {
|
if (st == PGRES_TUPLES_OK) {
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,6 @@ private:
|
||||||
std::unique_ptr<QueryExplainModel> explainModel;
|
std::unique_ptr<QueryExplainModel> explainModel;
|
||||||
|
|
||||||
Pgsql::Canceller queryCancel;
|
Pgsql::Canceller queryCancel;
|
||||||
std::future<Pgsql::Result> queryFuture;
|
|
||||||
std::future<std::unique_ptr<ExplainRoot>> explainFuture;
|
std::future<std::unique_ptr<ExplainRoot>> explainFuture;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
|
@ -74,6 +73,7 @@ private:
|
||||||
// } queryState;
|
// } queryState;
|
||||||
|
|
||||||
void processNotice(const PGresult *result);
|
void processNotice(const PGresult *result);
|
||||||
|
void query_ready(Pgsql::Result res);
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
void startConnect();
|
void startConnect();
|
||||||
|
|
@ -81,7 +81,6 @@ private slots:
|
||||||
void performQuery();
|
void performQuery();
|
||||||
void performExplain();
|
void performExplain();
|
||||||
void socket_activate_connect(int socket);
|
void socket_activate_connect(int socket);
|
||||||
void query_ready();
|
|
||||||
void explain_ready();
|
void explain_ready();
|
||||||
void cancel_query();
|
void cancel_query();
|
||||||
void receiveNotice(Pgsql::ErrorDetails notice);
|
void receiveNotice(Pgsql::ErrorDetails notice);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue