1#ifndef STDCPP_OS_WRAPPER_STDCPP_THREAD_FACTORY_H_INCLUDED
2#define STDCPP_OS_WRAPPER_STDCPP_THREAD_FACTORY_H_INCLUDED
8#include <condition_variable>
9#include <unordered_map>
25 std::condition_variable m_condStarted;
26 std::condition_variable m_condFinished;
28 bool m_endThreadRequested;
29 std::thread::id m_threadId;
46 virtual void setName(
const char* name);
47 virtual const char*
getName()
const;
54 std::thread::id
getId()
const {
return m_threadId; }
64 virtual void sleep(
unsigned long millis);
67 virtual int getMaxPriority()
const;
68 virtual int getMinPriority()
const;
69 virtual int getHighestPriority()
const;
70 virtual int getLowestPriority()
const;
75 virtual StdCppThread* createStdCppThread(
OSWrapper::Runnable* r,
int priority, std::size_t stackSize,
const char* name);
77 std::unordered_map<std::thread::id, OSWrapper::Thread*> m_threadIdMap;
78 std::recursive_mutex m_mutex;
Interface for implementing an active class.
Definition Runnable.h:9
Definition ThreadFactory.h:11
Abstract class that has functions of common RTOS's thread.
Definition Thread.h:50
Value object for the timeout.
Definition Timeout.h:11
Definition StdCppThreadFactory.h:15
void beginThread()
Definition StdCppThreadFactory.cpp:41
virtual OSWrapper::Error timedWait(OSWrapper::Timeout tmout)
Block the current thread until this thread transits to the FINISHED state but only within the limited...
Definition StdCppThreadFactory.cpp:83
virtual bool isFinished() const
Return true if this thread is in the FINISHED state.
Definition StdCppThreadFactory.cpp:97
std::mutex m_mutex
Definition StdCppThreadFactory.h:23
virtual void start()
Transit this thread to the READY state.
Definition StdCppThreadFactory.cpp:63
const char * m_name
Definition StdCppThreadFactory.h:20
virtual void * getNativeHandle()
Get the native handle of RTOS's thread.
Definition StdCppThreadFactory.cpp:156
void endThread()
Definition StdCppThreadFactory.cpp:51
std::size_t m_stackSize
Definition StdCppThreadFactory.h:19
std::thread::id getId() const
Definition StdCppThreadFactory.h:54
virtual OSWrapper::Error tryWait()
Query without blocking whether this thread is in the FINISHED state.
Definition StdCppThreadFactory.cpp:78
virtual int getPriority() const
Get this thread priority.
Definition StdCppThreadFactory.cpp:135
virtual OSWrapper::Error wait()
Block the current thread until this thread transits to the FINISHED state.
Definition StdCppThreadFactory.cpp:73
virtual int getInitialPriority() const
Get this thread priority when this thread was created.
Definition StdCppThreadFactory.cpp:141
int m_priority
Definition StdCppThreadFactory.h:17
std::thread m_thread
Definition StdCppThreadFactory.h:22
virtual void setPriority(int priority)
Change this thread priority.
Definition StdCppThreadFactory.cpp:115
virtual const char * getName() const
Get the object's name.
Definition StdCppThreadFactory.cpp:109
virtual void setName(const char *name)
Set the object's name.
Definition StdCppThreadFactory.cpp:103
virtual std::size_t getStackSize() const
Get the stack size of this thread.
Definition StdCppThreadFactory.cpp:147
virtual ~StdCppThread()
Definition StdCppThreadFactory.h:36
int m_initialPriority
Definition StdCppThreadFactory.h:18
Definition StdCppThreadFactory.h:13
virtual ~StdCppThreadFactory()
Definition StdCppThreadFactory.h:59
StdCppThreadFactory()
Definition StdCppThreadFactory.cpp:163
Error
Kinds of errors of the OS objects.
Definition OSWrapperError.h:9
Implementation of OSWrapper for standard C++11 using std::thread.
Definition StdCppEventFlagFactory.cpp:6