aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/DaemonManager.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2019-06-25 14:02:40 -0500
committerluigi1111 <luigi1111w@gmail.com>2019-06-25 14:02:40 -0500
commit036b3b56c543ea603c168c2e17405f8ca290ea40 (patch)
tree39c1456c1faec86e1d745e39c8d1883f3de281e0 /src/daemon/DaemonManager.cpp
parent3c3848633ee01c78a3dc7602912087cad25e49fc (diff)
parentbe7810c5a877898d792cc7d4406dc05c3280b38f (diff)
downloadmonzero-gui-036b3b56c543ea603c168c2e17405f8ca290ea40.tar.gz
monzero-gui-036b3b56c543ea603c168c2e17405f8ca290ea40.tar.xz
monzero-gui-036b3b56c543ea603c168c2e17405f8ca290ea40.zip
Merge pull request #2229
be7810c qt: implement FutureScheduler, always await async code to complete (xiphon)
Diffstat (limited to 'src/daemon/DaemonManager.cpp')
-rw-r--r--src/daemon/DaemonManager.cpp28
1 files changed, 11 insertions, 17 deletions
diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp
index 136e72bd..ecbe1784 100644
--- a/src/daemon/DaemonManager.cpp
+++ b/src/daemon/DaemonManager.cpp
@@ -131,19 +131,12 @@ bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const
}
// Start start watcher
- QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::startWatcher, nettype);
- QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>();
- connect(watcher, &QFutureWatcher<bool>::finished,
- this, [this, watcher]() {
- QFuture<bool> future = watcher->future();
- watcher->deleteLater();
- if(future.result())
+ m_scheduler.run([this, nettype] {
+ if (startWatcher(nettype))
emit daemonStarted();
else
emit daemonStartFailure();
});
- watcher->setFuture(future);
-
return true;
}
@@ -155,17 +148,12 @@ bool DaemonManager::stop(NetworkType::Type nettype)
qDebug() << message;
// Start stop watcher - Will kill if not shutting down
- QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::stopWatcher, nettype);
- QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>();
- connect(watcher, &QFutureWatcher<bool>::finished,
- this, [this, watcher]() {
- QFuture<bool> future = watcher->future();
- watcher->deleteLater();
- if(future.result()) {
+ m_scheduler.run([this, nettype] {
+ if (stopWatcher(nettype))
+ {
emit daemonStopped();
}
});
- watcher->setFuture(future);
return true;
}
@@ -330,6 +318,7 @@ QVariantMap DaemonManager::validateDataDir(const QString &dataDir) const
DaemonManager::DaemonManager(QObject *parent)
: QObject(parent)
+ , m_scheduler(this)
{
// Platform depetent path to monerod
@@ -344,3 +333,8 @@ DaemonManager::DaemonManager(QObject *parent)
m_has_daemon = false;
}
}
+
+DaemonManager::~DaemonManager()
+{
+ m_scheduler.shutdownWaitForFinished();
+}