最近写代码的时候图省事大量使用new、delete,后来抽空再git上面搜索了排名靠前的内存池和线程池的C++实现。
1)内存池:https://github.com/cacay/MemoryPool
比较了几种内存池的实现方式,发现该方法效率很高、值得赞一个。
2)线程池:https://github.com/progschj/ThreadPool/blob/master/ThreadPool.h
代码写的非常溜(一水的C++11标准实现),就是看着太费力了,百度了大量的东东,才勉强看懂,具体细节可以参考:
【基于c++11的100行实现简单线程池:https://blog.youkuaiyun.com/gcola007/article/details/78750220】