Coder Social home page Coder Social logo

netlib's People

Contributors

miaoshuai avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

netlib's Issues

thread_pool的一个可能小bug

在博客中看到作者的开源库连接和介绍,其中ThreadPool的构造函数对于成员threads_默认构造为:
ThreadPool::ThreadPool(int threadNumber)
:threadNumber_(threadNumber),
running_(true),
threads_(threadNumber_)
而在start函数中通过vector的push_back()进行添加:
threads_.push_back(std::make_sharedstd::thread(std::bind(&ThreadPool::threadWork, this)));
这样就会导致threads_实际上有预期的2倍大小,且前半为NULL,进一步,在对象析构或者停止时:
for (auto t : threads_)
{
t->join(); //循环等待线程终止
}
就会导致对空数据操作而引发异常。
建议构造函数更换为:
ThreadPool::ThreadPool(int threadNumber)
:threadNumber_(threadNumber),
running_(true),
threads_(NULL)
以上是我在test中发现的问题,仅供参考。

有一些问题?

1 usleep(500); 这个时间是如何评估的?
发现注释掉这个后,append 1W线程,也会直接结束(stop也不管用)。

2 有一些停止不了,阻塞死主线程的情况。
例如,初始化的pool的大小 大于 append的任务数,就会阻塞死在 等待锁/等有任务?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.