28 lines
541 B
C++
28 lines
541 B
C++
#pragma once
|
|
|
|
namespace f8
|
|
{
|
|
|
|
class ThreadPool
|
|
{
|
|
public:
|
|
class Context
|
|
{
|
|
public:
|
|
virtual bool* Terminated() = 0;
|
|
virtual list_head* GetWorkList() = 0;
|
|
virtual void Wait(int ms) = 0;
|
|
};
|
|
|
|
void Init(int thread_num, std::function<void(Context*)> cb);
|
|
void UnInit();
|
|
void Start();
|
|
void PostMsg(int key, list_head* node);
|
|
|
|
private:
|
|
class WorkerThread;
|
|
std::vector<std::shared_ptr<WorkerThread>> threads_;
|
|
};
|
|
|
|
}
|