progschj / ThreadPool

A simple C++11 Thread Pool implementation
zlib License
7.64k stars 2.21k forks source link

*edit* Nvm, my own fault #16

Closed JherNifol closed 9 years ago

JherNifol commented 9 years ago
std::shared_ptr<ThreadPool> _pool;
_pool = std::make_shared<ThreadPool>(4);

I'm new to c++ and haven't quite figured out what the issue with trying to do it like this is yet. The threads do manage to get into the block for

if (this->stop && this->tasks.empty())
    return;

But creating the threadpool this way leaves them waiting or deadlocked afterwards.

Will continue trying to figure it out tomorrow (good learning experience for myself)

edit nvm my own fault in my test project, works fine lol

yxbh commented 9 years ago

Then what was the actual cause?

JherNifol commented 9 years ago

I had the definition of the shared_ptr outside the main function, but not inside an class/object essentially:

std::shared_ptr<ThreadPool> _pool;
int main()
{
}

Lol -puts down the Guinness- Sorry