Asynchronous threads should execute in thread pools owned by parents

- Fixes #51
This commit is contained in:
Dan Paulat 2023-06-21 23:33:16 -05:00
parent 6000abdeb3
commit a268ca04e6
3 changed files with 61 additions and 49 deletions

View file

@ -28,8 +28,9 @@
#include <scwx/common/products.hpp>
#include <scwx/common/vcp.hpp>
#include <scwx/util/logger.hpp>
#include <scwx/util/threads.hpp>
#include <boost/asio/post.hpp>
#include <boost/asio/thread_pool.hpp>
#include <QDesktopServices>
#include <QFileDialog>
#include <QMessageBox>
@ -134,6 +135,8 @@ public:
void UpdateRadarSite();
void UpdateVcp();
boost::asio::thread_pool threadPool_ {1u};
MainWindow* mainWindow_;
QMapLibreGL::Settings settings_;
map::MapProvider mapProvider_;
@ -429,7 +432,8 @@ void MainWindow::on_actionGitHubRepository_triggered()
void MainWindow::on_actionCheckForUpdates_triggered()
{
scwx::util::async(
boost::asio::post(
p->threadPool_,
[this]()
{
if (!p->updateManager_->CheckForUpdates(main::kVersionString_))
@ -544,7 +548,8 @@ void MainWindowImpl::AsyncSetup()
// Check for updates
if (generalSettings.update_notifications_enabled().GetValue())
{
scwx::util::async(
boost::asio::post(
threadPool_,
[this]() { updateManager_->CheckForUpdates(main::kVersionString_); });
}
}