65 void setJobName (
const String& newName);
98 bool isRunning() const noexcept {
return isActive; }
114 void signalJobShouldExit();
137 std::atomic<bool> shouldStop {
false }, isActive {
false }, shouldBeDeleted {
false };
138 ListenerList<Thread::Listener, Array<Thread::Listener*, CriticalSection>> listeners;
140 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (ThreadPoolJob)
159 return withMember (*
this, &ThreadPoolOptions::threadName, newThreadName);
167 return withMember (*
this, &ThreadPoolOptions::numberOfThreads, newNumberOfThreads);
173 return withMember (*
this, &ThreadPoolOptions::threadStackSizeBytes, newThreadStackSizeBytes);
179 return withMember (*
this, &ThreadPoolOptions::desiredThreadPriority, newDesiredThreadPriority);
182 String threadName {
"Pool" };
184 size_t threadStackSizeBytes { Thread::osDefaultStackSize };
233 size_t threadStackSizeBytes = Thread::osDefaultStackSize,
279 bool deleteJobWhenFinished);
289 void addJob (std::function<
void()> job);
309 bool interruptIfRunning,
310 int timeOutMilliseconds);
323 bool removeAllJobs (
bool interruptRunningJobs,
324 int timeOutMilliseconds,
328 int getNumJobs() const noexcept;
331 int getNumThreads() const noexcept;
358 int timeOutMilliseconds) const;
363 void moveJobToFront (const
ThreadPoolJob* jobToMove) noexcept;
368 StringArray getNamesOfAllJobs (
bool onlyReturnActiveJobs) const;
374 struct ThreadPoolThread;
381 bool runNextJob (ThreadPoolThread&);
388 void removeAllJobs (
bool,
int,
bool);
390 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (
ThreadPool)
static int getNumCpus() noexcept
bool isRunning() const noexcept
bool shouldExit() const noexcept
virtual JobStatus runJob()=0
virtual bool isJobSuitable(ThreadPoolJob *job)=0
ThreadPoolOptions withThreadName(String newThreadName) const
ThreadPoolOptions withNumberOfThreads(int newNumberOfThreads) const
ThreadPoolOptions withDesiredThreadPriority(Thread::Priority newDesiredThreadPriority) const
ThreadPoolOptions withThreadStackSizeBytes(size_t newThreadStackSizeBytes) const