mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-30 22:20:04 +00:00
Asynchronous threads should execute in thread pools owned by parents
- Fixes #51
This commit is contained in:
parent
6000abdeb3
commit
a268ca04e6
3 changed files with 61 additions and 49 deletions
|
|
@ -13,13 +13,14 @@
|
|||
#include <scwx/qt/util/file.hpp>
|
||||
#include <scwx/qt/view/radar_product_view_factory.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
#include <scwx/util/threads.hpp>
|
||||
#include <scwx/util/time.hpp>
|
||||
|
||||
#include <regex>
|
||||
|
||||
#include <backends/imgui_impl_opengl3.h>
|
||||
#include <backends/imgui_impl_qt.hpp>
|
||||
#include <boost/asio/post.hpp>
|
||||
#include <boost/asio/thread_pool.hpp>
|
||||
#include <boost/uuid/random_generator.hpp>
|
||||
#include <fmt/format.h>
|
||||
#include <imgui.h>
|
||||
|
|
@ -123,6 +124,8 @@ public:
|
|||
common::Level2Product
|
||||
GetLevel2ProductOrDefault(const std::string& productName) const;
|
||||
|
||||
boost::asio::thread_pool threadPool_ {1u};
|
||||
|
||||
boost::uuids::uuid uuid_;
|
||||
|
||||
std::shared_ptr<MapContext> context_;
|
||||
|
|
@ -939,7 +942,8 @@ void MapWidgetImpl::RadarProductManagerConnect()
|
|||
}
|
||||
|
||||
// Load file
|
||||
scwx::util::async(
|
||||
boost::asio::post(
|
||||
threadPool_,
|
||||
[=, this]()
|
||||
{
|
||||
if (group == common::RadarProductGroup::Level2)
|
||||
|
|
@ -973,26 +977,26 @@ void MapWidgetImpl::RadarProductManagerDisconnect()
|
|||
void MapWidgetImpl::InitializeNewRadarProductView(
|
||||
const std::string& colorPalette)
|
||||
{
|
||||
scwx::util::async(
|
||||
[=, this]()
|
||||
{
|
||||
auto radarProductView = context_->radar_product_view();
|
||||
boost::asio::post(threadPool_,
|
||||
[=, this]()
|
||||
{
|
||||
auto radarProductView = context_->radar_product_view();
|
||||
|
||||
std::string colorTableFile =
|
||||
manager::SettingsManager::palette_settings()
|
||||
.palette(colorPalette)
|
||||
.GetValue();
|
||||
if (!colorTableFile.empty())
|
||||
{
|
||||
std::unique_ptr<std::istream> colorTableStream =
|
||||
util::OpenFile(colorTableFile);
|
||||
std::shared_ptr<common::ColorTable> colorTable =
|
||||
common::ColorTable::Load(*colorTableStream);
|
||||
radarProductView->LoadColorTable(colorTable);
|
||||
}
|
||||
std::string colorTableFile =
|
||||
manager::SettingsManager::palette_settings()
|
||||
.palette(colorPalette)
|
||||
.GetValue();
|
||||
if (!colorTableFile.empty())
|
||||
{
|
||||
std::unique_ptr<std::istream> colorTableStream =
|
||||
util::OpenFile(colorTableFile);
|
||||
std::shared_ptr<common::ColorTable> colorTable =
|
||||
common::ColorTable::Load(*colorTableStream);
|
||||
radarProductView->LoadColorTable(colorTable);
|
||||
}
|
||||
|
||||
radarProductView->Initialize();
|
||||
});
|
||||
radarProductView->Initialize();
|
||||
});
|
||||
|
||||
if (map_ != nullptr)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue