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;
182 String threadName {
"Pool" };
184 size_t threadStackSizeBytes { Thread::osDefaultStackSize };
233 size_t threadStackSizeBytes = Thread::osDefaultStackSize,
279 bool deleteJobWhenFinished);
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;
388 void removeAllJobs (
bool,
int,
bool);
Holds a resizable array of primitive or copy-by-value objects.
An array designed for holding objects.
A special array for holding a list of strings.
static int getNumCpus() noexcept
Returns the number of logical CPU cores.
A task that is executed by a ThreadPool object.
JobStatus
These are the values that can be returned by the runJob() method.
bool isRunning() const noexcept
Returns true if this job is currently running its runJob() method.
bool shouldExit() const noexcept
Returns true if something is trying to interrupt this job and make it stop.
virtual JobStatus runJob()=0
Performs the actual work that this job needs to do.
A callback class used when you need to select which ThreadPoolJob objects are suitable for some kind ...
virtual bool isJobSuitable(ThreadPoolJob *job)=0
Should return true if the specified thread matches your criteria for whatever operation that this obj...
A set of threads that will run a list of jobs.
ThreadPool()
Creates a thread pool based using the default arguments provided by ThreadPoolOptions.
Used to receive callbacks for thread exit calls.
Priority
The different runtime priorities of non-realtime threads.
Allows threads to wait for events triggered by other threads.
Object withMember(Object copy, Member OtherObject::*member, Other &&value)
Copies an object, sets one of the copy's members to the specified value, and then returns the copy.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
A set of threads that will run a list of jobs.
ThreadPoolOptions withThreadName(String newThreadName) const
The name to give each thread in the pool.
ThreadPoolOptions withNumberOfThreads(int newNumberOfThreads) const
The number of threads to run.
ThreadPoolOptions withDesiredThreadPriority(Thread::Priority newDesiredThreadPriority) const
The desired priority of each thread in the pool.
ThreadPoolOptions withThreadStackSizeBytes(size_t newThreadStackSizeBytes) const
The size of the stack of each thread in the pool.