diff --git a/modules/juce_core/threads/juce_ThreadPool.cpp b/modules/juce_core/threads/juce_ThreadPool.cpp index a292bb5de4..40b8eca188 100644 --- a/modules/juce_core/threads/juce_ThreadPool.cpp +++ b/modules/juce_core/threads/juce_ThreadPool.cpp @@ -29,8 +29,8 @@ class ThreadPool::ThreadPoolThread : public Thread { public: - ThreadPoolThread (ThreadPool& p) - : Thread ("Pool"), currentJob (nullptr), pool (p) + ThreadPoolThread (ThreadPool& p, size_t stackSize = 0) + : Thread ("Pool", stackSize), currentJob (nullptr), pool (p) { } @@ -85,11 +85,11 @@ ThreadPoolJob* ThreadPoolJob::getCurrentThreadPoolJob() } //============================================================================== -ThreadPool::ThreadPool (const int numThreads) +ThreadPool::ThreadPool (const int numThreads, size_t threadStackSize) { jassert (numThreads > 0); // not much point having a pool without any threads! - createThreads (numThreads); + createThreads (numThreads, threadStackSize); } ThreadPool::ThreadPool() @@ -103,10 +103,10 @@ ThreadPool::~ThreadPool() stopThreads(); } -void ThreadPool::createThreads (int numThreads) +void ThreadPool::createThreads (int numThreads, size_t threadStackSize) { for (int i = jmax (1, numThreads); --i >= 0;) - threads.add (new ThreadPoolThread (*this)); + threads.add (new ThreadPoolThread (*this, threadStackSize)); for (int i = threads.size(); --i >= 0;) threads.getUnchecked(i)->startThread(); diff --git a/modules/juce_core/threads/juce_ThreadPool.h b/modules/juce_core/threads/juce_ThreadPool.h index c928592ed2..753ab1722c 100644 --- a/modules/juce_core/threads/juce_ThreadPool.h +++ b/modules/juce_core/threads/juce_ThreadPool.h @@ -152,10 +152,14 @@ public: //============================================================================== /** Creates a thread pool. Once you've created a pool, you can give it some jobs by calling addJob(). + @param numberOfThreads the number of threads to run. These will be started immediately, and will run until the pool is deleted. + @param threadStackSize the size of the stack of each thread. If this value + is zero then the default stack size of the OS will + be used. */ - ThreadPool (int numberOfThreads); + ThreadPool (int numberOfThreads, size_t threadStackSize = 0); /** Creates a thread pool with one thread per CPU core. Once you've created a pool, you can give it some jobs by calling addJob(). @@ -309,7 +313,7 @@ private: bool runNextJob (ThreadPoolThread&); ThreadPoolJob* pickNextJobToRun(); void addToDeleteList (OwnedArray&, ThreadPoolJob*) const; - void createThreads (int numThreads); + void createThreads (int numThreads, size_t threadStackSize = 0); void stopThreads(); // Note that this method has changed, and no longer has a parameter to indicate