Skip to content

Commit

Permalink
ThreadPool: Improve consistency with other option style classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Anthony-Nicholls committed Jun 28, 2023
1 parent 04a8900 commit 578d2b9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions modules/juce_core/threads/juce_ThreadPool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
{
Expand Down Expand Up @@ -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);
Expand All @@ -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) }
{
}

Expand Down
6 changes: 4 additions & 2 deletions modules/juce_core/threads/juce_ThreadPool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -215,7 +217,7 @@ class JUCE_API ThreadPool
@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().
Expand Down

0 comments on commit 578d2b9

Please sign in to comment.