From 5d0256982b4b23ccdc43227b1ce4bb1b88379190 Mon Sep 17 00:00:00 2001 From: hogliux Date: Thu, 27 Oct 2016 16:21:00 +0100 Subject: [PATCH] Added a method to ThreadPool to query the number of threads assigned to the pool --- modules/juce_core/threads/juce_ThreadPool.cpp | 5 +++++ modules/juce_core/threads/juce_ThreadPool.h | 6 ++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/modules/juce_core/threads/juce_ThreadPool.cpp b/modules/juce_core/threads/juce_ThreadPool.cpp index f57359c629..a292bb5de4 100644 --- a/modules/juce_core/threads/juce_ThreadPool.cpp +++ b/modules/juce_core/threads/juce_ThreadPool.cpp @@ -148,6 +148,11 @@ int ThreadPool::getNumJobs() const return jobs.size(); } +int ThreadPool::getNumThreads() const +{ + return threads.size(); +} + ThreadPoolJob* ThreadPool::getJob (const int index) const { const ScopedLock sl (lock); diff --git a/modules/juce_core/threads/juce_ThreadPool.h b/modules/juce_core/threads/juce_ThreadPool.h index 8d67a01076..c928592ed2 100644 --- a/modules/juce_core/threads/juce_ThreadPool.h +++ b/modules/juce_core/threads/juce_ThreadPool.h @@ -246,10 +246,12 @@ public: int timeOutMilliseconds, JobSelector* selectedJobsToRemove = nullptr); - /** Returns the number of jobs currently running or queued. - */ + /** Returns the number of jobs currently running or queued. */ int getNumJobs() const; + /** Returns the number of threads assigned to this thread pool. */ + int getNumThreads() const; + /** Returns one of the jobs in the queue. Note that this can be a very volatile list as jobs might be continuously getting shifted