1#ifndef OS_WRAPPER_THREAD_POOL_H_INCLUDED
2#define OS_WRAPPER_THREAD_POOL_H_INCLUDED
11template <
typename T>
class MessageQueue;
42 void startThread(
Runnable* task,
int priority,
bool needsWaiting);
46 void notifyFinished();
47 void setThread(
Thread* t) { m_thread = t; }
48 Thread* getThread()
const {
return m_thread; }
49 EventFlag* getEventFlag()
const {
return m_ev; }
57 TaskRunner(
const TaskRunner&);
58 TaskRunner& operator=(
const TaskRunner&);
138 TaskRunner* m_runner;
234 void* m_threadMemory;
241 const int m_defaultPriority;
242 const char* m_threadName;
244 bool constructMembers(std::size_t maxThreads, std::size_t stackSize);
245 void destroyMembers();
246 void destroyRunners();
247 void destroyThreads();
249 void releaseRunner(TaskRunner* runner);
250 int getDefaultPriority()
const {
return m_defaultPriority; }
STL-like vector container using pre-allocated buffer.
Definition PreallocatedVector.h:26
Abstract class that has functions of common RTOS's event flag.
Definition EventFlag.h:24
Abstract class that has functions of common RTOS's fixed-size memory pool.
Definition FixedMemoryPool.h:23
Class template of message queue.
Definition MessageQueue.h:22
Interface for implementing an active class.
Definition Runnable.h:9
Class to wait for the asynchronous task finished.
Definition ThreadPool.h:73
~WaitGuard()
Destructor of WaitGuard.
Definition ThreadPool.cpp:307
Error wait()
Block the current thread until the asynchronous task finished.
Definition ThreadPool.cpp:321
WaitGuard()
Constructor of WaitGuard.
Definition ThreadPool.cpp:302
Error timedWait(Timeout tmout)
Block the current thread until the asynchronous task finished but only within the limited time.
Definition ThreadPool.cpp:331
Error tryWait()
Query without blocking whether the asynchronous task finished.
Definition ThreadPool.cpp:326
bool isValid() const
Return true if the validity state is valid.
Definition ThreadPool.cpp:339
void release()
Call wait(), release the resource, and turn the valid state to invalid.
Definition ThreadPool.cpp:312
Class of thread pool pattern.
Definition ThreadPool.h:30
Error tryStart(Runnable *task, WaitGuard *waiter=0, int priority=Thread::INHERIT_PRIORITY)
Try to start an asynchronous task without blocking.
Definition ThreadPool.cpp:177
Thread::UncaughtExceptionHandler * getUncaughtExceptionHandler() const
Get the UncaughtExceptionHandler for this ThreadPool.
Definition ThreadPool.cpp:220
Error timedStart(Runnable *task, Timeout tmout, WaitGuard *waiter=0, int priority=Thread::INHERIT_PRIORITY)
Start an asynchronous task with Timeout.
Definition ThreadPool.cpp:182
static void destroy(ThreadPool *p)
Destroy a ThreadPool object.
Definition ThreadPool.cpp:109
Error start(Runnable *task, WaitGuard *waiter=0, int priority=Thread::INHERIT_PRIORITY)
Start an asynchronous task.
Definition ThreadPool.cpp:172
static ThreadPool * create(std::size_t maxThreads, std::size_t stackSize=0U, int defaultPriority=Thread::getNormalPriority(), const char *threadName="")
Create a ThreadPool object.
Definition ThreadPool.cpp:25
const char * getThreadName() const
Get the name of threads.
Definition ThreadPool.cpp:225
void setUncaughtExceptionHandler(Thread::UncaughtExceptionHandler *handler)
Set the UncaughtExceptionHandler for this ThreadPool.
Definition ThreadPool.cpp:212
Interface for handling uncaught exception.
Definition Thread.h:66
Abstract class that has functions of common RTOS's thread.
Definition Thread.h:50
static const int INHERIT_PRIORITY
Use when set the same priority as the caller thread.
Definition Thread.h:77
static int getNormalPriority()
Get the middle priority between the minimum and maximum value.
Definition Thread.cpp:193
Value object for the timeout.
Definition Timeout.h:11
OSWrapper provides abstract C++ interface of common RTOS: thread, mutex, event flag,...
Definition EventFlag.cpp:5
Error
Kinds of errors of the OS objects.
Definition OSWrapperError.h:9