12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- #include "AuditPlugin.hpp"
- namespace gsd
- {
- /**
- * @description: CreateNew
- * @return {*}
- */
- std::shared_ptr<AuditPlugin> AuditPlugin::getPtr(){
- static std::shared_ptr<AuditPlugin> m_AuditPlugin = nullptr;
- if(m_AuditPlugin == nullptr) m_AuditPlugin = std::shared_ptr<AuditPlugin>(new AuditPlugin);
- return m_AuditPlugin;
- }
- /**
- * @description: 初始化
- * @return {*}
- */
- bool AuditPlugin::Init(){
- if(this->pool == nullptr) this->pool = std::make_shared<ThreadPool>(1,ThreadPool::PRIORITY_HIGHEST, false);
- return true;
- }
- /**
- * @description: 启动任务
- * @return {*}
- */
- bool AuditPlugin::StartTask(){
- if(this->timer == nullptr) this->timer = std::make_shared<toolkit::Timer>(10.0f, [&](){
- this->PluginTaskCheck();
- return true;
- }, nullptr);
- return true;
- }
- /**
- * @description: Destroy
- * @return {*}
- */
- void AuditPlugin::Destroy(){
-
- }
- /**
- * @description: Alive
- * @return {*}
- */
- bool AuditPlugin::Alive(){
- return true;
- }
-
- /**
- * @description: PluginTaskCheck
- * @return {*}
- */
- bool AuditPlugin::PluginTaskCheck(){
- this->map_ = PuginFactory::getPtr()->getMap();
- for(auto iter = this->map_.begin(); iter != this->map_.end(); iter++){
- if(!iter->second()->Alive()) {
- if(this->pool == nullptr) continue;
- auto pluginPtr = iter->second();
- this->pool->async([pluginPtr](){
- pluginPtr->RestPlugin();
- });
- this->pool->start();
- }
- }
- return true;
- }
- } // namespace gsd
|