#include <mn_basic_semaphore.hpp>

+ Inheritance diagram for mn::basic_semaphore:
+ Collaboration diagram for mn::basic_semaphore:

Public Member Functions

 basic_semaphore ()
 
 basic_semaphore (const basic_semaphore &other)
 
 basic_semaphore (basic_semaphore &&other)
 
virtual int lock (unsigned int timeout=MN_THREAD_CONFIG_TIMEOUT_SEMAPHORE_DEFAULT)
 
virtual int time_lock (const struct timespec *timeout)
 
virtual int unlock ()
 
void * get_handle ()
 
int get_error ()
 
virtual bool is_initialized () const
 
virtual bool is_locked () const
 Is locked? More...
 
bool operator== (const basic_semaphore &r) const
 
bool operator!= (const basic_semaphore &r) const
 
bool operator< (const basic_semaphore &r) const
 
bool operator> (const basic_semaphore &r) const
 
- Public Member Functions inherited from mn::ILockObject
 ILockObject ()
 
virtual bool try_lock ()
 

Protected Member Functions

void set_error (int error)
 

Protected Attributes

void * m_pSpinlock
 
int m_iCreateErrorCode
 
bool m_isLocked
 

Additional Inherited Members

- Public Types inherited from mn::ILockObject
using this_type = ILockObject
 

Detailed Description

Base wrapper class around FreeRTOS's implementation of semaphores.

Constructor & Destructor Documentation

◆ basic_semaphore() [1/3]

mn::basic_semaphore::basic_semaphore ( )

◆ basic_semaphore() [2/3]

mn::basic_semaphore::basic_semaphore ( const basic_semaphore other)

◆ basic_semaphore() [3/3]

mn::basic_semaphore::basic_semaphore ( basic_semaphore &&  other)

Member Function Documentation

◆ get_error()

int mn::basic_semaphore::get_error ( )
inline

Get the error code on creating

Returns
The error code on creating
Examples
/home/ambersophia/Dokumente/git/mnthread/include/mn_basic_semaphore.hpp.

◆ get_handle()

void* mn::basic_semaphore::get_handle ( )
inline

Get the FreeRTOS handle

Returns
the FreeRTOS handle
Examples
/home/ambersophia/Dokumente/git/mnthread/include/mn_basic_semaphore.hpp.

◆ is_initialized()

virtual bool mn::basic_semaphore::is_initialized ( ) const
inlinevirtual

Is the ILockObject created (initialized) ?

Returns
true if the ILockObject created (initialized) and false when not

Implements mn::ILockObject.

Examples
/home/ambersophia/Dokumente/git/mnthread/include/mn_basic_semaphore.hpp.

◆ is_locked()

virtual bool mn::basic_semaphore::is_locked ( ) const
inlinevirtual

Is locked?

Returns
True if locked and false when not.

Implements mn::ILockObject.

Examples
/home/ambersophia/Dokumente/git/mnthread/include/mn_basic_semaphore.hpp.

◆ lock()

int mn::basic_semaphore::lock ( unsigned int  timeout = MN_THREAD_CONFIG_TIMEOUT_SEMAPHORE_DEFAULT)
virtual

lock (take) a LokObject

Parameters
timeoutHow long to wait to get the Lock until giving up.

Implements mn::ILockObject.

Reimplemented in mn::basic_mutex, and mn::basic_clock< TLockType >.

Examples
/home/ambersophia/Dokumente/git/mnthread/include/mn_basic_semaphore.hpp.

◆ operator!=()

bool mn::basic_semaphore::operator!= ( const basic_semaphore r) const
inline

◆ operator<()

bool mn::basic_semaphore::operator< ( const basic_semaphore r) const
inline

◆ operator==()

bool mn::basic_semaphore::operator== ( const basic_semaphore r) const
inline

◆ operator>()

bool mn::basic_semaphore::operator> ( const basic_semaphore r) const
inline

◆ set_error()

void mn::basic_semaphore::set_error ( int  error)
inlineprotected

Set the error codes

Parameters
errorThe error code
Examples
/home/ambersophia/Dokumente/git/mnthread/include/mn_basic_semaphore.hpp.

◆ time_lock()

int mn::basic_semaphore::time_lock ( const struct timespec *  timeout)
virtual

lock (take) a semaphore.

Parameters
abs_timeHow long to wait to get the lock until giving up.
Returns
ERR_SPINLOCK_OK if the Semaphore was locked, ERR_SPINLOCK_LOCK if it timed out.

Implements mn::ILockObject.

Examples
/home/ambersophia/Dokumente/git/mnthread/include/mn_basic_semaphore.hpp.

◆ unlock()

int mn::basic_semaphore::unlock ( )
virtual

unlock (give) a semaphore.

Returns
ERR_SPINLOCK_OK if the Semaphore was unlocked, ERR_SPINLOCK_UNLOCK if it failed.

Implements mn::ILockObject.

Reimplemented in mn::basic_mutex, and mn::basic_clock< TLockType >.

Examples
/home/ambersophia/Dokumente/git/mnthread/include/mn_basic_semaphore.hpp.

Member Data Documentation

◆ m_iCreateErrorCode

int mn::basic_semaphore::m_iCreateErrorCode
protected

A saved / cached copy of error code on creating

Examples
/home/ambersophia/Dokumente/git/mnthread/include/mn_basic_semaphore.hpp.

◆ m_isLocked

bool mn::basic_semaphore::m_isLocked
protected

◆ m_pSpinlock

void* mn::basic_semaphore::m_pSpinlock
protected

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