Bootstrap

c++手写线程池

#ifndef THREADPOOL_H
#define THREADPOOL_H

#include <mutex>
#include <condition_variable>
#include <queue>
#include <thread>
#include <functional>
class ThreadPool {
   
public:
    //explicit声明显示类构造函数
    //make_shared 创建Pool以及其的智能指针
    explicit ThreadPool(size_t threadCount = 8): pool_(std::make_shared<Pool>()) {
   

            assert(threadCount > 0);//断言一下threadCount参数>0,否则直接返回异常
            for(size_t i = 0; i < threadCount; i+
;