CppELib 1.7.0
Loading...
Searching...
No Matches
OSWrapper::Mutex Class Referenceabstract

Abstract class that has functions of common RTOS's mutex. More...

#include <Mutex.h>

Public Member Functions

virtual Error lock ()=0
 Block the current thread until locks this mutex.
 
virtual Error tryLock ()=0
 Try to lock this mutex without blocking.
 
virtual Error timedLock (Timeout tmout)=0
 Block the current thread until locks this mutex but only within the limited time.
 
virtual Error unlock ()=0
 Unlock this mutex that the current thread locks.
 

Static Public Member Functions

static Mutexcreate ()
 Create a Mutex object.
 
static Mutexcreate (int priorityCeiling)
 Create a Mutex object with priority ceiling protocol.
 
static void destroy (Mutex *m)
 Destroy a Mutex object.
 

Protected Member Functions

virtual ~Mutex ()
 

Detailed Description

Abstract class that has functions of common RTOS's mutex.

Constructor & Destructor Documentation

◆ ~Mutex()

virtual OSWrapper::Mutex::~Mutex ( )
inlineprotectedvirtual

Member Function Documentation

◆ create() [1/2]

Mutex * OSWrapper::Mutex::create ( )
static

Create a Mutex object.

Returns
If this method succeeds then returns a pointer of Mutex object, else returns null pointer
Note
Use priority inheritance if RTOS's mutex supports.

◆ create() [2/2]

Mutex * OSWrapper::Mutex::create ( int  priorityCeiling)
static

Create a Mutex object with priority ceiling protocol.

Parameters
priorityCeilingpriority ceiling
Returns
If this method succeeds then returns a pointer of Mutex object, else returns null pointer
Note
If RTOS's mutex does not support priority ceiling protocol, priorityCeiling is ignored.

◆ destroy()

void OSWrapper::Mutex::destroy ( Mutex m)
static

Destroy a Mutex object.

Parameters
mPointer of Mutex object created by Mutex::create()
Note
If m is null pointer, do nothing.

◆ lock()

virtual Error OSWrapper::Mutex::lock ( )
pure virtual

Block the current thread until locks this mutex.

Return values
OKSuccess. The current thread locked this mutex
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
Note
Same as timedLock(Timeout::FOREVER)

Implemented in StdCppOSWrapper::StdCppMutex, and TestDoubleOSWrapper::TestDoubleMutex.

◆ timedLock()

virtual Error OSWrapper::Mutex::timedLock ( Timeout  tmout)
pure virtual

Block the current thread until locks this mutex but only within the limited time.

Parameters
tmoutThe limited time
Return values
OKSuccess. The current thread locked this mutex
TimedOutThe limited time was elapsed
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
Note
If tmout is Timeout::POLLING then this method tries to lock this mutex without blocking.
If tmout is Timeout::FOREVER then this method waits forever until locks this mutex.

Implemented in StdCppOSWrapper::StdCppMutex, and TestDoubleOSWrapper::TestDoubleMutex.

◆ tryLock()

virtual Error OSWrapper::Mutex::tryLock ( )
pure virtual

Try to lock this mutex without blocking.

Return values
OKSuccess. The current thread locked this mutex
TimedOutFailed. Other thread already locked this mutex
Note
Same as timedLock(Timeout::POLLING)

Implemented in StdCppOSWrapper::StdCppMutex, and TestDoubleOSWrapper::TestDoubleMutex.

◆ unlock()

virtual Error OSWrapper::Mutex::unlock ( )
pure virtual

Unlock this mutex that the current thread locks.

Return values
OKSuccess. The current thread unlocked this mutex
NotLockedThe current thread has not locked this mutex

Implemented in StdCppOSWrapper::StdCppMutex, and TestDoubleOSWrapper::TestDoubleMutex.


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