mirror of
				https://github.com/ciphervance/supercell-wx.git
				synced 2025-10-31 05:20:06 +00:00 
			
		
		
		
	Avoid uncommon race condition with computing a sweep during radar product view destruction
This commit is contained in:
		
							parent
							
								
									f56d7f14bf
								
							
						
					
					
						commit
						bb2d3a92ad
					
				
					 8 changed files with 37 additions and 7 deletions
				
			
		|  | @ -72,7 +72,7 @@ public: | |||
| 
 | ||||
|       SetProduct(product); | ||||
|    } | ||||
|    ~Level2ProductViewImpl() = default; | ||||
|    ~Level2ProductViewImpl() { threadPool_.join(); }; | ||||
| 
 | ||||
|    void | ||||
|    ComputeCoordinates(std::shared_ptr<wsr88d::rda::ElevationScan> radarData); | ||||
|  | @ -82,6 +82,8 @@ public: | |||
| 
 | ||||
|    Level2ProductView* self_; | ||||
| 
 | ||||
|    boost::asio::thread_pool threadPool_ {1u}; | ||||
| 
 | ||||
|    common::Level2Product      product_; | ||||
|    wsr88d::rda::DataBlockType dataBlockType_; | ||||
| 
 | ||||
|  | @ -156,6 +158,11 @@ void Level2ProductView::DisconnectRadarProductManager() | |||
|               nullptr); | ||||
| } | ||||
| 
 | ||||
| boost::asio::thread_pool& Level2ProductView::thread_pool() | ||||
| { | ||||
|    return p->threadPool_; | ||||
| } | ||||
| 
 | ||||
| const std::vector<boost::gil::rgba8_pixel_t>& | ||||
| Level2ProductView::color_table() const | ||||
| { | ||||
|  |  | |||
|  | @ -53,6 +53,8 @@ public: | |||
|           std::shared_ptr<manager::RadarProductManager> radarProductManager); | ||||
| 
 | ||||
| protected: | ||||
|    boost::asio::thread_pool& thread_pool() override; | ||||
| 
 | ||||
|    void ConnectRadarProductManager() override; | ||||
|    void DisconnectRadarProductManager() override; | ||||
|    void UpdateColorTable() override; | ||||
|  |  | |||
|  | @ -41,13 +41,15 @@ public: | |||
|    { | ||||
|       coordinates_.resize(kMaxCoordinates_); | ||||
|    } | ||||
|    ~Level3RadialViewImpl() = default; | ||||
|    ~Level3RadialViewImpl() { threadPool_.join(); }; | ||||
| 
 | ||||
|    void ComputeCoordinates( | ||||
|       std::shared_ptr<wsr88d::rpg::GenericRadialDataPacket> radialData); | ||||
| 
 | ||||
|    Level3RadialView* self_; | ||||
| 
 | ||||
|    boost::asio::thread_pool threadPool_ {1u}; | ||||
| 
 | ||||
|    std::vector<float>        coordinates_ {}; | ||||
|    std::vector<float>        vertices_ {}; | ||||
|    std::vector<std::uint8_t> dataMoments8_ {}; | ||||
|  | @ -73,6 +75,11 @@ Level3RadialView::~Level3RadialView() | |||
|    std::unique_lock sweepLock {sweep_mutex()}; | ||||
| } | ||||
| 
 | ||||
| boost::asio::thread_pool& Level3RadialView::thread_pool() | ||||
| { | ||||
|    return p->threadPool_; | ||||
| } | ||||
| 
 | ||||
| float Level3RadialView::range() const | ||||
| { | ||||
|    return p->range_; | ||||
|  |  | |||
|  | @ -37,6 +37,9 @@ public: | |||
|    Create(const std::string&                            product, | ||||
|           std::shared_ptr<manager::RadarProductManager> radarProductManager); | ||||
| 
 | ||||
| protected: | ||||
|    boost::asio::thread_pool& thread_pool() override; | ||||
| 
 | ||||
| protected slots: | ||||
|    void ComputeSweep() override; | ||||
| 
 | ||||
|  |  | |||
|  | @ -30,7 +30,9 @@ public: | |||
|        latitude_ {}, longitude_ {}, range_ {}, vcp_ {}, sweepTime_ {} | ||||
|    { | ||||
|    } | ||||
|    ~Level3RasterViewImpl() = default; | ||||
|    ~Level3RasterViewImpl() { threadPool_.join(); }; | ||||
| 
 | ||||
|    boost::asio::thread_pool threadPool_ {1u}; | ||||
| 
 | ||||
|    std::vector<float>   vertices_; | ||||
|    std::vector<uint8_t> dataMoments8_; | ||||
|  | @ -56,6 +58,11 @@ Level3RasterView::~Level3RasterView() | |||
|    std::unique_lock sweepLock {sweep_mutex()}; | ||||
| } | ||||
| 
 | ||||
| boost::asio::thread_pool& Level3RasterView::thread_pool() | ||||
| { | ||||
|    return p->threadPool_; | ||||
| } | ||||
| 
 | ||||
| float Level3RasterView::range() const | ||||
| { | ||||
|    return p->range_; | ||||
|  |  | |||
|  | @ -37,6 +37,9 @@ public: | |||
|    Create(const std::string&                            product, | ||||
|           std::shared_ptr<manager::RadarProductManager> radarProductManager); | ||||
| 
 | ||||
| protected: | ||||
|    boost::asio::thread_pool& thread_pool() override; | ||||
| 
 | ||||
| protected slots: | ||||
|    void ComputeSweep() override; | ||||
| 
 | ||||
|  |  | |||
|  | @ -35,9 +35,7 @@ public: | |||
|        radarProductManager_ {radarProductManager} | ||||
|    { | ||||
|    } | ||||
|    ~RadarProductViewImpl() { threadPool_.join(); } | ||||
| 
 | ||||
|    boost::asio::thread_pool threadPool_ {1}; | ||||
|    ~RadarProductViewImpl() {} | ||||
| 
 | ||||
|    bool       initialized_; | ||||
|    std::mutex sweepMutex_; | ||||
|  | @ -123,7 +121,7 @@ void RadarProductView::SelectTime(std::chrono::system_clock::time_point time) | |||
| 
 | ||||
| void RadarProductView::Update() | ||||
| { | ||||
|    boost::asio::post(p->threadPool_, [this]() { ComputeSweep(); }); | ||||
|    boost::asio::post(thread_pool(), [this]() { ComputeSweep(); }); | ||||
| } | ||||
| 
 | ||||
| bool RadarProductView::IsInitialized() const | ||||
|  |  | |||
|  | @ -11,6 +11,7 @@ | |||
| #include <vector> | ||||
| 
 | ||||
| #include <QObject> | ||||
| #include <boost/asio/thread_pool.hpp> | ||||
| 
 | ||||
| namespace scwx | ||||
| { | ||||
|  | @ -66,6 +67,8 @@ public: | |||
|    std::chrono::system_clock::time_point GetSelectedTime() const; | ||||
| 
 | ||||
| protected: | ||||
|    virtual boost::asio::thread_pool& thread_pool() = 0; | ||||
| 
 | ||||
|    virtual void ConnectRadarProductManager()    = 0; | ||||
|    virtual void DisconnectRadarProductManager() = 0; | ||||
|    virtual void UpdateColorTable()              = 0; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Dan Paulat
						Dan Paulat