mirror of
https://github.com/ciphervance/supercell-wx.git
synced 2025-10-29 23:10:06 +00:00
Run NTP client in the background
This commit is contained in:
parent
63e6ba7709
commit
88d968a533
6 changed files with 54 additions and 1 deletions
|
|
@ -109,6 +109,7 @@ set(HDR_MANAGER source/scwx/qt/manager/alert_manager.hpp
|
|||
source/scwx/qt/manager/radar_product_manager_notifier.hpp
|
||||
source/scwx/qt/manager/resource_manager.hpp
|
||||
source/scwx/qt/manager/settings_manager.hpp
|
||||
source/scwx/qt/manager/task_manager.hpp
|
||||
source/scwx/qt/manager/text_event_manager.hpp
|
||||
source/scwx/qt/manager/thread_manager.hpp
|
||||
source/scwx/qt/manager/timeline_manager.hpp
|
||||
|
|
@ -126,6 +127,7 @@ set(SRC_MANAGER source/scwx/qt/manager/alert_manager.cpp
|
|||
source/scwx/qt/manager/radar_product_manager_notifier.cpp
|
||||
source/scwx/qt/manager/resource_manager.cpp
|
||||
source/scwx/qt/manager/settings_manager.cpp
|
||||
source/scwx/qt/manager/task_manager.cpp
|
||||
source/scwx/qt/manager/text_event_manager.cpp
|
||||
source/scwx/qt/manager/thread_manager.cpp
|
||||
source/scwx/qt/manager/timeline_manager.cpp
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include <scwx/qt/manager/radar_product_manager.hpp>
|
||||
#include <scwx/qt/manager/resource_manager.hpp>
|
||||
#include <scwx/qt/manager/settings_manager.hpp>
|
||||
#include <scwx/qt/manager/task_manager.hpp>
|
||||
#include <scwx/qt/manager/thread_manager.hpp>
|
||||
#include <scwx/qt/settings/general_settings.hpp>
|
||||
#include <scwx/qt/types/qt_types.hpp>
|
||||
|
|
@ -121,6 +122,7 @@ int main(int argc, char* argv[])
|
|||
// Initialize application
|
||||
scwx::qt::config::RadarSite::Initialize();
|
||||
scwx::qt::config::CountyDatabase::Initialize();
|
||||
scwx::qt::manager::TaskManager::Initialize();
|
||||
scwx::qt::manager::SettingsManager::Instance().Initialize();
|
||||
scwx::qt::manager::ResourceManager::Initialize();
|
||||
|
||||
|
|
@ -181,6 +183,7 @@ int main(int argc, char* argv[])
|
|||
// Shutdown application
|
||||
scwx::qt::manager::ResourceManager::Shutdown();
|
||||
scwx::qt::manager::SettingsManager::Instance().Shutdown();
|
||||
scwx::qt::manager::TaskManager::Shutdown();
|
||||
|
||||
// Shutdown AWS SDK
|
||||
Aws::ShutdownAPI(awsSdkOptions);
|
||||
|
|
|
|||
29
scwx-qt/source/scwx/qt/manager/task_manager.cpp
Normal file
29
scwx-qt/source/scwx/qt/manager/task_manager.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include <scwx/qt/manager/task_manager.hpp>
|
||||
#include <scwx/network/ntp_client.hpp>
|
||||
#include <scwx/util/logger.hpp>
|
||||
|
||||
namespace scwx::qt::manager::TaskManager
|
||||
{
|
||||
|
||||
static const std::string logPrefix_ = "scwx::qt::manager::task_manager";
|
||||
static const auto logger_ = scwx::util::Logger::Create(logPrefix_);
|
||||
|
||||
static std::shared_ptr<network::NtpClient> ntpClient_ {};
|
||||
|
||||
void Initialize()
|
||||
{
|
||||
logger_->debug("Initialize");
|
||||
|
||||
ntpClient_ = network::NtpClient::Instance();
|
||||
|
||||
ntpClient_->Start();
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
{
|
||||
logger_->debug("Shutdown");
|
||||
|
||||
ntpClient_->Stop();
|
||||
}
|
||||
|
||||
} // namespace scwx::qt::manager::TaskManager
|
||||
9
scwx-qt/source/scwx/qt/manager/task_manager.hpp
Normal file
9
scwx-qt/source/scwx/qt/manager/task_manager.hpp
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
#pragma once
|
||||
|
||||
namespace scwx::qt::manager::TaskManager
|
||||
{
|
||||
|
||||
void Initialize();
|
||||
void Shutdown();
|
||||
|
||||
} // namespace scwx::qt::manager::TaskManager
|
||||
|
|
@ -26,7 +26,9 @@ public:
|
|||
bool error();
|
||||
std::chrono::system_clock::duration time_offset() const;
|
||||
|
||||
void Start();
|
||||
void Start();
|
||||
void Stop();
|
||||
|
||||
void Open(std::string_view host, std::string_view service);
|
||||
void OpenCurrentServer();
|
||||
void Poll();
|
||||
|
|
|
|||
|
|
@ -191,6 +191,14 @@ void NtpClient::Start()
|
|||
}
|
||||
}
|
||||
|
||||
void NtpClient::Stop()
|
||||
{
|
||||
p->enabled_ = false;
|
||||
p->socket_.cancel();
|
||||
p->pollTimer_.cancel();
|
||||
p->threadPool_.join();
|
||||
}
|
||||
|
||||
void NtpClient::Open(std::string_view host, std::string_view service)
|
||||
{
|
||||
p->Open(host, service);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue