# threadpool **Repository Path**: awmking/threadpool ## Basic Information - **Project Name**: threadpool - **Description**: 线程池分配空闲的线程,处理用户提交的任务。 - **Primary Language**: C++ - **License**: AGPL-3.0 - **Default Branch**: master - **Homepage**: https://gitee.com/awmking - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-08-29 - **Last Updated**: 2022-06-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: threadpool ## README # 项目名称:基于 Linux 多任务处理线程池 # 平台工具 > vscode 远程 linux 开发,cmake 构建项目工程,linux shell 一键编译脚本 # 项目描述 > 1、线程需要使用 list 容器存储 thread > > 2、使用 queue 容器存储用户提交的任务,为了统一接收用户提交的任务,使用了继承中的多态, 因此使用智能指针 share_ptr 表示任务,存放到 queue 中。 > > 3、取出任务,使用互斥锁 mutex 控制任务队列,不会产生竞态条件。 > > 4、条件变量 cond,控制线程的行为,queue 中无任务时,线程阻塞某一条件下,queue 中有任 务时,满足条件,得到通知。 > > 5、用户使用方式:继承线程池提供的抽象类,重写其方法,供用户自定义任务。 # 备注 > 1、在root下运行threadpool_code中的go.sh文件。 > > 2、编译的时候链接两个库 > g++ test.cc -lthreadpool -lpthread