diff --git a/src/squick/plugin/config/class_module.cc b/src/squick/plugin/config/class_module.cc index 0843b004..83d6c6c9 100644 --- a/src/squick/plugin/config/class_module.cc +++ b/src/squick/plugin/config/class_module.cc @@ -17,9 +17,7 @@ ClassModule::ClassModule(IPluginManager *p) { #endif if (!this->mbBackup) { - // IThreadPoolModule *threadPoolModule = pm_->FindModule<IThreadPoolModule>(); - // const int threadCount = threadPoolModule->GetThreadCount(); - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < CONFIG_DATA_THREADS_CAN_BE_USED_CNT; ++i) { ThreadClassModule threadElement; threadElement.used = false; threadElement.classModule = new ClassModule(); @@ -64,6 +62,7 @@ bool ClassModule::Destroy() { return true; } +// Get a free class module for find IClassModule *ClassModule::GetThreadClassModule() { std::thread::id threadID = std::this_thread::get_id(); @@ -73,12 +72,12 @@ IClassModule *ClassModule::GetThreadClassModule() { return mThreadClasses[i].classModule; } } else { + // init for this thread mThreadClasses[i].used = true; mThreadClasses[i].threadID = threadID; return mThreadClasses[i].classModule; } } - return nullptr; } diff --git a/src/squick/plugin/config/element_module.cc b/src/squick/plugin/config/element_module.cc index 70785180..01952434 100644 --- a/src/squick/plugin/config/element_module.cc +++ b/src/squick/plugin/config/element_module.cc @@ -16,7 +16,7 @@ ElementModule::ElementModule(IPluginManager *p) { mbLoaded = false; if (!this->mbBackup) { - for (int i = 0; i < pm_->GetAppCPUCount(); ++i) { + for (int i = 0; i < CONFIG_DATA_THREADS_CAN_BE_USED_CNT; ++i) { ThreadElementModule threadElement; threadElement.used = false; threadElement.elementModule = new ElementModule(this); @@ -84,6 +84,11 @@ bool ElementModule::Destroy() { return true; } +bool ElementModule::Reload(int type) +{ + return true; +} + IElementModule *ElementModule::GetThreadElementModule() { std::thread::id threadID = std::this_thread::get_id(); diff --git a/src/squick/plugin/config/element_module.h b/src/squick/plugin/config/element_module.h index 935611f7..c546503e 100644 --- a/src/squick/plugin/config/element_module.h +++ b/src/squick/plugin/config/element_module.h @@ -19,7 +19,7 @@ #include <thread> class Class; - +#define CONFIG_DATA_THREADS_CAN_BE_USED_CNT 1 class ElementConfigInfo { public: ElementConfigInfo() { @@ -55,6 +55,7 @@ class ElementModule : public IElementModule, MapEx<std::string, ElementConfigInf virtual bool AfterStart() override; virtual bool BeforeDestroy() override; virtual bool Update() override; + virtual bool Reload(int type) override; virtual bool Load() override; virtual bool Save() override;