1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- #ifndef _BASECALCULATETHREAD_H_
- #define _BASECALCULATETHREAD_H_
- #include "spdlog/spdlog.h"
- #include "GlobalVariable.h"
- class BaseCalculateThread
- {
- public:
- BaseCalculateThread(CalculateThreadInfo_t& threadInfo);
- virtual ~BaseCalculateThread() = default;
- /**
- * @brief 线程任务函数,创建线程时会调用此函数
- */
- virtual void threadTask();
- /* 获取线程信息 */
- CalculateThreadInfo_t getThreadInfo() { return m_threadInfo; }
- /* 停止线程 */
- void stopThread();
-
- protected:
- /**
- * @brief 线程运行函数,子类需要实现此函数
- */
- virtual void task() = 0;
- /* 初始化数据 */
- virtual bool initData() = 0;
- /* 清理数据 */
- virtual void clearData() = 0;
-
- protected:
- std::shared_ptr<spdlog::logger> m_logger = nullptr; /* 日志记录器 */
- std::string m_logBase; /* 日志基础信息 */
- std::atomic_bool m_isRunning = true; /* 线程运行标志 */
- std::atomic_bool m_isStop = false; /* 线程停止标志 */
- CalculateThreadInfo_t m_threadInfo; /* 线程信息 */
- };
- #endif // _BASECALCULATETHREAD_H_
|