123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #pragma once
- // 下列 ifdef 块是创建使从 DLL 导出更简单的
- // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 WORKPOOL_EXPORTS
- // 符号编译的。在使用此 DLL 的
- // 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
- // WORKPOOL_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
- // 符号视为是被导出的。
- #ifndef WORKPOOL_EXPORTS
- #ifdef _WIN64
- #ifdef _DEBUG
- #pragma comment(lib, "WorkPoolX64D.lib")
- #else
- #pragma comment(lib, "WorkPoolX64.lib")
- #endif
- #else
- #ifdef _DEBUG
- #pragma comment(lib, "WorkPoolD.lib")
- #else
- #pragma comment(lib, "WorkPool.lib")
- #endif
- #endif
- #endif
- #ifdef WORKPOOL_EXPORTS
- #define WORKPOOL_API __declspec(dllexport)
- #define WORKPOOL_C_API extern "C" __declspec(dllexport)
- #else
- #define WORKPOOL_API __declspec(dllimport)
- #define WORKPOOL_C_API extern "C" __declspec(dllimport)
- #endif
- #include "logger.h"
- #include "DiosThread.h"
- #include "DataBase_IF.h"
- #include "ShareMem_Node.h"
- #define CmdRecalcAll "RecalcAll"
- #define CmdRecalcOne "RecalcOne"
- #define CmdSaveCodeAll "SaveCodeAll"
- class WORKPOOL_API PoolThread : public Work_Thread
- {
- protected:
- HANDLE m_Standby;
- DataBase_IF *m_pDb;
- virtual bool Exec();
- virtual bool OnStartThread();
- virtual bool OnEndThread();
- public:
- PoolThread(void);
- virtual ~PoolThread();
- bool SaveRawData(ShareMem_Node *pNode);
- bool ReqProcess(ResDataObject &obj);
- bool RecalcAllCode(UINT64 StartTime);
- bool RecalcOneCode(const char *pszCode,UINT64 StartTime);
- bool SaveFullData();
- bool GetStandbyStatus();
- HANDLE GetStandbyHandle();
- };
- class WORKPOOL_API WorkPool {
- protected:
- DWORD ThreadCount;
- PoolThread *pThreadList;
- HANDLE *pStandbyList;
- Logger *m_plogger;
- public:
- WorkPool(void);
- virtual ~WorkPool();
- virtual bool CreateWPool(DWORD CountOfThread);
- void CloseWPool();
- bool RunWPool();
- bool StopWPool(DWORD timeout = 5000);
- bool PushReqDataObject(ResDataObject &obj,bool AllThread = true);
- bool PauseThread(DWORD timeout = INFINITE, bool AllThread = true);
- bool ResumeThread(DWORD timeout = INFINITE, bool AllThread = true);
- bool RecalcAllCode(UINT64 StartTime);
- bool RecalcOneCode(const char *pszCode, UINT64 StartTime);
- bool SaveFullData();
- };
|