Closed cloud9370 closed 6 years ago
I found that thread_pool destructor was executed after Scheduler destructor. That makes the thread_pool.stop(true) execute after Scheduler desctructor.
Thanks for the report. I pushed a fix. Previously, the tasks variable was destructed before the thread pool. The manager thread could attempt to access tasks while looping for the final time, but tasks would be destroyed already. Just switched their ordering.
I just tried your example.cpp and modified the sleep time from 10 minutes to 10 seconds in main thread. That made my program crash on manage_task method while program ended.
I use std::cerr to show the execute order, then I found that destructor called and manage_task called after destructor. That made program crashed.
I'm using VS2017 to build program. Please check this problem. Thanks.