CppELib 1.7.0
Loading...
Searching...
No Matches
StdCppOSWrapper::StdCppThreadFactory::StdCppThread Class Reference

#include <StdCppThreadFactory.h>

Public Member Functions

 StdCppThread (OSWrapper::Runnable *r, int priority, std::size_t stackSize, const char *name)
 
virtual ~StdCppThread ()
 
void beginThread ()
 
void endThread ()
 
virtual void start ()
 Transit this thread to the READY state.
 
virtual OSWrapper::Error wait ()
 Block the current thread until this thread transits to the FINISHED state.
 
virtual OSWrapper::Error tryWait ()
 Query without blocking whether this thread is in the FINISHED state.
 
virtual OSWrapper::Error timedWait (OSWrapper::Timeout tmout)
 Block the current thread until this thread transits to the FINISHED state but only within the limited time.
 
virtual bool isFinished () const
 Return true if this thread is in the FINISHED state.
 
virtual void setName (const char *name)
 Set the object's name.
 
virtual const char * getName () const
 Get the object's name.
 
virtual void setPriority (int priority)
 Change this thread priority.
 
virtual int getPriority () const
 Get this thread priority.
 
virtual int getInitialPriority () const
 Get this thread priority when this thread was created.
 
virtual std::size_t getStackSize () const
 Get the stack size of this thread.
 
virtual void * getNativeHandle ()
 Get the native handle of RTOS's thread.
 
std::thread::id getId () const
 
- Public Member Functions inherited from OSWrapper::Thread
void setUncaughtExceptionHandler (UncaughtExceptionHandler *handler)
 Set the UncaughtExceptionHandler for this Thread.
 
UncaughtExceptionHandlergetUncaughtExceptionHandler () const
 Get the UncaughtExceptionHandler for this Thread.
 

Protected Attributes

int m_priority
 
int m_initialPriority
 
std::size_t m_stackSize
 
const char * m_name
 
std::thread m_thread
 
std::mutex m_mutex
 

Additional Inherited Members

- Static Public Member Functions inherited from OSWrapper::Thread
static void setDefaultUncaughtExceptionHandler (UncaughtExceptionHandler *handler)
 Set the default UncaughtExceptionHandler for all the Thread.
 
static UncaughtExceptionHandlergetDefaultUncaughtExceptionHandler ()
 Get the default UncaughtExceptionHandler.
 
static Threadcreate (Runnable *r, int priority=INHERIT_PRIORITY, std::size_t stackSize=0U, void *stackAddress=0, const char *name="")
 Create a Thread object.
 
static void destroy (Thread *t)
 Destroy a Thread object.
 
static void sleep (unsigned long millis)
 Sleep the current thread while the time that is set by argument.
 
static void yield ()
 Transit the current thread from the RUNNING state to the READY state to give other thread the RUNNING state.
 
static ThreadgetCurrentThread ()
 Get the current running Thread object.
 
static int getMaxPriority ()
 Get the maximum value of RTOS's thread priority.
 
static int getMinPriority ()
 Get the minimum value of RTOS's thread priority.
 
static int getNormalPriority ()
 Get the middle priority between the minimum and maximum value.
 
static int getHighestPriority ()
 Get the highest thread priority of RTOS.
 
static int getLowestPriority ()
 Get the lowest thread priority of RTOS.
 
static int getPriorityHigherThan (int basePriority, int d)
 Get the thread priority of RTOS higher than basePriority by d.
 
- Static Public Attributes inherited from OSWrapper::Thread
static const int INHERIT_PRIORITY = -1
 Use when set the same priority as the caller thread.
 
- Protected Member Functions inherited from OSWrapper::Thread
 Thread (Runnable *r)
 
virtual ~Thread ()
 
void threadMain ()
 Common thread main method.
 

Constructor & Destructor Documentation

◆ StdCppThread()

StdCppOSWrapper::StdCppThreadFactory::StdCppThread::StdCppThread ( OSWrapper::Runnable r,
int  priority,
std::size_t  stackSize,
const char *  name 
)

◆ ~StdCppThread()

virtual StdCppOSWrapper::StdCppThreadFactory::StdCppThread::~StdCppThread ( )
inlinevirtual

Member Function Documentation

◆ beginThread()

void StdCppOSWrapper::StdCppThreadFactory::StdCppThread::beginThread ( )

◆ endThread()

void StdCppOSWrapper::StdCppThreadFactory::StdCppThread::endThread ( )

◆ getId()

std::thread::id StdCppOSWrapper::StdCppThreadFactory::StdCppThread::getId ( ) const
inline

◆ getInitialPriority()

int StdCppOSWrapper::StdCppThreadFactory::StdCppThread::getInitialPriority ( ) const
virtual

Get this thread priority when this thread was created.

Returns
Initial thread priority

Implements OSWrapper::Thread.

◆ getName()

const char * StdCppOSWrapper::StdCppThreadFactory::StdCppThread::getName ( ) const
virtual

Get the object's name.

Returns
The object's name

Implements OSWrapper::Thread.

◆ getNativeHandle()

void * StdCppOSWrapper::StdCppThreadFactory::StdCppThread::getNativeHandle ( )
virtual

Get the native handle of RTOS's thread.

Returns
native handle

Implements OSWrapper::Thread.

◆ getPriority()

int StdCppOSWrapper::StdCppThreadFactory::StdCppThread::getPriority ( ) const
virtual

Get this thread priority.

Returns
Thread priority

Implements OSWrapper::Thread.

◆ getStackSize()

std::size_t StdCppOSWrapper::StdCppThreadFactory::StdCppThread::getStackSize ( ) const
virtual

Get the stack size of this thread.

Returns
stack size

Implements OSWrapper::Thread.

◆ isFinished()

bool StdCppOSWrapper::StdCppThreadFactory::StdCppThread::isFinished ( ) const
virtual

Return true if this thread is in the FINISHED state.

Return values
trueThis thread is in the FINISHED state
falseThis thread is not in the FINISHED state

Implements OSWrapper::Thread.

◆ setName()

void StdCppOSWrapper::StdCppThreadFactory::StdCppThread::setName ( const char *  name)
virtual

Set the object's name.

Parameters
nameThe object's name

Implements OSWrapper::Thread.

◆ setPriority()

void StdCppOSWrapper::StdCppThreadFactory::StdCppThread::setPriority ( int  priority)
virtual

Change this thread priority.

Parameters
priorityThread priority

Implements OSWrapper::Thread.

◆ start()

void StdCppOSWrapper::StdCppThreadFactory::StdCppThread::start ( )
virtual

Transit this thread to the READY state.

After this method, when this thread transits to the RUNNING state, this thread calls Runnable::run() specified at create().

Note
If this thread is already in the READY state, do nothing.
If this thread is finished, you can start() again.

Implements OSWrapper::Thread.

◆ timedWait()

OSWrapper::Error StdCppOSWrapper::StdCppThreadFactory::StdCppThread::timedWait ( OSWrapper::Timeout  tmout)
virtual

Block the current thread until this thread transits to the FINISHED state but only within the limited time.

Parameters
tmoutThe limited time
Return values
OKSuccess. This thread is in the FINISHED state
TimedOutThe limited time was elapsed
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
Note
If tmout is Timeout::POLLING then this method queries the state without blocking.
If tmout is Timeout::FOREVER then this method waits forever until the condition is satisfied.

Implements OSWrapper::Thread.

◆ tryWait()

OSWrapper::Error StdCppOSWrapper::StdCppThreadFactory::StdCppThread::tryWait ( )
virtual

Query without blocking whether this thread is in the FINISHED state.

Return values
OKThis thread is already in the FINISHED state
TimedOutThis thread is not in the FINISHED state
Note
Same as timedWait(Timeout::POLLING)

Implements OSWrapper::Thread.

◆ wait()

OSWrapper::Error StdCppOSWrapper::StdCppThreadFactory::StdCppThread::wait ( )
virtual

Block the current thread until this thread transits to the FINISHED state.

Return values
OKSuccess. This thread is in the FINISHED state
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
Note
Same as timedWait(Timeout::FOREVER)

Implements OSWrapper::Thread.

Member Data Documentation

◆ m_initialPriority

int StdCppOSWrapper::StdCppThreadFactory::StdCppThread::m_initialPriority
protected

◆ m_mutex

std::mutex StdCppOSWrapper::StdCppThreadFactory::StdCppThread::m_mutex
mutableprotected

◆ m_name

const char* StdCppOSWrapper::StdCppThreadFactory::StdCppThread::m_name
protected

◆ m_priority

int StdCppOSWrapper::StdCppThreadFactory::StdCppThread::m_priority
protected

◆ m_stackSize

std::size_t StdCppOSWrapper::StdCppThreadFactory::StdCppThread::m_stackSize
protected

◆ m_thread

std::thread StdCppOSWrapper::StdCppThreadFactory::StdCppThread::m_thread
protected

The documentation for this class was generated from the following files: