Browse Source

ThreadPool: Improve consistency with other option style classes

v7.0.9
Anthony Nicholls 1 year ago
parent
commit
578d2b9d15
2 changed files with 9 additions and 7 deletions
  1. +5
    -5
      modules/juce_core/threads/juce_ThreadPool.cpp
  2. +4
    -2
      modules/juce_core/threads/juce_ThreadPool.h

+ 5
- 5
modules/juce_core/threads/juce_ThreadPool.cpp View File

@@ -25,7 +25,7 @@ namespace juce
struct ThreadPool::ThreadPoolThread : public Thread
{
ThreadPoolThread (ThreadPool& p, const ThreadPoolOptions& options)
ThreadPoolThread (ThreadPool& p, const Options& options)
: Thread { options.threadName, options.threadStackSizeBytes },
pool { p }
{
@@ -94,7 +94,7 @@ ThreadPoolJob* ThreadPoolJob::getCurrentThreadPoolJob()
}
//==============================================================================
ThreadPool::ThreadPool (const ThreadPoolOptions& options)
ThreadPool::ThreadPool (const Options& options)
{
// not much point having a pool without any threads!
jassert (options.numberOfThreads > 0);
@@ -109,9 +109,9 @@ ThreadPool::ThreadPool (const ThreadPoolOptions& options)
ThreadPool::ThreadPool (int numberOfThreads,
size_t threadStackSizeBytes,
Thread::Priority desiredThreadPriority)
: ThreadPool { ThreadPoolOptions{}.withNumberOfThreads (numberOfThreads)
.withThreadStackSizeBytes (threadStackSizeBytes)
.withDesiredThreadPriority (desiredThreadPriority) }
: ThreadPool { Options{}.withNumberOfThreads (numberOfThreads)
.withThreadStackSizeBytes (threadStackSizeBytes)
.withDesiredThreadPriority (desiredThreadPriority) }
{
}


+ 4
- 2
modules/juce_core/threads/juce_ThreadPool.h View File

@@ -200,13 +200,15 @@ struct ThreadPoolOptions
class JUCE_API ThreadPool
{
public:
using Options = ThreadPoolOptions;
//==============================================================================
/** Creates a thread pool based on the provided options.
Once you've created a pool, you can give it some jobs by calling addJob().
@see ThreadPool::ThreadPoolOptions
*/
explicit ThreadPool (const ThreadPoolOptions& options);
explicit ThreadPool (const Options& options);
/** Creates a thread pool based using the default arguments provided by
ThreadPoolOptions.
@@ -215,7 +217,7 @@ public:
@see ThreadPoolOptions
*/
ThreadPool() : ThreadPool { ThreadPoolOptions{} } {}
ThreadPool() : ThreadPool { Options{} } {}
/** Creates a thread pool.
Once you've created a pool, you can give it some jobs by calling addJob().


Loading…
Cancel
Save