1#ifndef OS_WRAPPER_THREAD_H_INCLUDED
2#define OS_WRAPPER_THREAD_H_INCLUDED
53 : m_runnable(r), m_uncaughtExceptionHandler(0) {}
116 static void sleep(
unsigned long millis);
292 void handleException(
const char* msg);
Interface for implementing an active class.
Definition Runnable.h:9
Interface for handling uncaught exception.
Definition Thread.h:66
virtual ~UncaughtExceptionHandler()
Definition Thread.h:68
virtual void handle(Thread *t, const char *msg)=0
Handle uncaught exception thrown in the Thread.
Abstract class that has functions of common RTOS's thread.
Definition Thread.h:50
virtual bool isFinished() const =0
Return true if this thread is in the FINISHED state.
void threadMain()
Common thread main method.
Definition Thread.cpp:125
static int getMaxPriority()
Get the maximum value of RTOS's thread priority.
Definition Thread.cpp:181
static int getPriorityHigherThan(int basePriority, int d)
Get the thread priority of RTOS higher than basePriority by d.
Definition Thread.cpp:211
virtual Error wait()=0
Block the current thread until this thread transits to the FINISHED state.
UncaughtExceptionHandler * getUncaughtExceptionHandler() const
Get the UncaughtExceptionHandler for this Thread.
Definition Thread.cpp:98
virtual void * getNativeHandle()=0
Get the native handle of RTOS's thread.
virtual void start()=0
Transit this thread to the READY state.
static void sleep(unsigned long millis)
Sleep the current thread while the time that is set by argument.
Definition Thread.cpp:163
static const int INHERIT_PRIORITY
Use when set the same priority as the caller thread.
Definition Thread.h:77
virtual int getPriority() const =0
Get this thread priority.
static int getHighestPriority()
Get the highest thread priority of RTOS.
Definition Thread.cpp:199
static void destroy(Thread *t)
Destroy a Thread object.
Definition Thread.cpp:156
static UncaughtExceptionHandler * getDefaultUncaughtExceptionHandler()
Get the default UncaughtExceptionHandler.
Definition Thread.cpp:88
static int getLowestPriority()
Get the lowest thread priority of RTOS.
Definition Thread.cpp:205
virtual std::size_t getStackSize() const =0
Get the stack size of this thread.
virtual ~Thread()
Definition Thread.h:54
virtual const char * getName() const =0
Get the object's name.
virtual void setName(const char *name)=0
Set the object's name.
static int getMinPriority()
Get the minimum value of RTOS's thread priority.
Definition Thread.cpp:187
static Thread * getCurrentThread()
Get the current running Thread object.
Definition Thread.cpp:175
static Thread * create(Runnable *r, int priority=INHERIT_PRIORITY, std::size_t stackSize=0U, void *stackAddress=0, const char *name="")
Create a Thread object.
Definition Thread.cpp:147
virtual Error tryWait()=0
Query without blocking whether this thread is in the FINISHED state.
static void setDefaultUncaughtExceptionHandler(UncaughtExceptionHandler *handler)
Set the default UncaughtExceptionHandler for all the Thread.
Definition Thread.cpp:83
static int getNormalPriority()
Get the middle priority between the minimum and maximum value.
Definition Thread.cpp:193
virtual void setPriority(int priority)=0
Change this thread priority.
virtual int getInitialPriority() const =0
Get this thread priority when this thread was created.
void setUncaughtExceptionHandler(UncaughtExceptionHandler *handler)
Set the UncaughtExceptionHandler for this Thread.
Definition Thread.cpp:93
Thread(Runnable *r)
Definition Thread.h:52
static void yield()
Transit the current thread from the RUNNING state to the READY state to give other thread the RUNNING...
Definition Thread.cpp:169
virtual Error timedWait(Timeout tmout)=0
Block the current thread until this thread transits to the FINISHED state but only within the limited...
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
void registerThreadFactory(ThreadFactory *factory)
Register the ThreadFactory.
Definition Thread.cpp:75