2025-07-23 01:35:14 +08:00
|
|
|
#ifndef VRTHEADPOOL_H
|
|
|
|
|
#define VRTHEADPOOL_H
|
|
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <deque>
|
|
|
|
|
#include "IVrThreadPool.h"
|
|
|
|
|
#include "VrThread.h"
|
|
|
|
|
|
|
|
|
|
class VrThreadPool : public IVrThreadPool
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
VrThreadPool();
|
|
|
|
|
|
|
|
|
|
// 执行任务
|
|
|
|
|
virtual int ExecTask(ThreadExecFunc fExecFunc, void* pParam);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
// 获取一个可执行的线程
|
|
|
|
|
VrThread* _GetThread();
|
|
|
|
|
|
|
|
|
|
// 任务执行完成回调
|
|
|
|
|
void _ExecFinish(void* pObject);
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
std::mutex m_mutexPool;
|
|
|
|
|
std::vector<VrThread*> m_vetThread;
|
|
|
|
|
std::deque<VrThread*> m_deqRecoveryThread;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif // VRTHEADPOOL_H
|