Interface如下

struct Job
{
    
void (*func)(void*);
    
void *para;
};

class ThreadPool:noncopyable
{
public:
    
static SetNumThreads(size_t NThread);    //MUST called before Instance()

    
static ThreadPool& Instance();
    
    boost::shared_ptr
<Event> SubmitJob(const Job& job);
    
    
void WaitAllJobDone();

    
//make as public JUST FOR pass VC6 compile!
    ThreadPool();
    
~ThreadPool();
    
private:
    
static void JobThread( void * pThis );
    
    
bool m_exit;
    std::vector
<unsigned long> m_threads;
    
    
struct JobData
    {
        Job job;
        boost::shared_ptr
<Event> event;
    };

    std::list
<JobData> m_JobQueue;
    Mutex m_jobMutex;
    
static size_t m_numThread;

};

相关文章:

  • 2021-11-30
  • 2021-08-11
  • 2021-05-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-12
猜你喜欢
  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-21
  • 2022-01-03
  • 2021-06-24
相关资源
相似解决方案