Slightly different than my previous post about ThreadPoolJobs and statically allocated objects, I’ve run into the following situation.
I’ve got an object that manages a ThreadPool and some ThreadPoolJobs
The destructor of that object cleans up all the running threads
The runJob() method of the various ThreadPoolJobs periodically checks ThreadPoolJob::shouldExit()
shutdownJuce_NonGUI calls Thread::stopAllThreads which makes Thread::threadShouldExit return true. But, from my ThreadPoolJob child classes, I don’t see a way to access that value. The return value from ThreadPoolJob::shouldExit doesn’t change even after the calls to Thread::threadShouldExit.
In an app that calls shutdownJuce_NonGUI before the end of main and statically allocates an instance of that object, the assert in Thread::stopThread fires if one of the ThreadPoolJobs is still running.
Does it make sense to create something similar to the filewide-static runningThreads (juce_Thread.cpp) in juce_ThreadPool.cpp, with a new method similar to like Thread::stopAllThreads? Then shutdownJuce_NonGUI could call that new method and I think the ThreadPoolJobs would cleanly exit.