Minor feature request: ThreadPool::getNumThreads() const


#1

Hi,

would it be possible to add a method like getNumThreads() to the ThreadPool class, which returns the number of threads in the thread pool?

Something like this

    /** Returns the number of threads in the thread pool.
    */
    int ThreadPool::getNumThreads() const
    {
        return threads.size();
    }

This would help me to fine-tune the ParallelFor() and ParallelInvoke() methods in Squeeze (currently I’m creating up to as many thread pool jobs as cores are available, which is unnecessary if the thread pool doesn’t contain as many threads).

What do you think? :slight_smile:

Regards,

Uli


#2

Thanks! I’ve added it to the develop branch.


#3

Very cool, thanks a lot! :slight_smile:

I’m looking forward to use it as soon as it’s available on the GitHub repository.