Rockermankind / pthreadpool

Use cpp11 to create a thread pool with pthread library

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

实现线程池基本思路:

  1. 架构:
    • 事件处理器(工作线程)
    • 事件分发器(主线程)
    • 任务队列
  2. 工作流程:
    • 首先,pthread_create创建多个事件处理器,绑定的函数是类中静态函数,并且传入this指针(此对象,为了调用动态函数对象function)
    • 然后,将到来的事件插入任务队列,其中任务队列的插入和删除都需要锁控制(共享变量)
    • 最后,运行时动态调用对象中的工作函数

About

Use cpp11 to create a thread pool with pthread library


Languages

Language:C++ 95.6%Language:CMake 4.4%