mn::basic_counting_semaphore Class Reference

#include <mn_counting_semaphore.hpp>

+ Inheritance diagram for mn::basic_counting_semaphore:
+ Collaboration diagram for mn::basic_counting_semaphore:

Public Member Functions

 basic_counting_semaphore (int count=MN_THREAD_CONFIG_CSEMAPHORE_MIN_COUNT, int maxcount=MN_THREAD_CONFIG_CSEMAPHORE_MAX_COUNT)
 
 basic_counting_semaphore (const basic_counting_semaphore &o)
 
 basic_counting_semaphore (basic_counting_semaphore &&o)
 
virtual ~basic_counting_semaphore ()
 
void set_initial_count (int count)
 
void set_max_count (int count)
 
int get_count () const
 
- Public Member Functions inherited from mn::basic_semaphore
 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 Attributes

int m_uiCount
 
int m_uiMaxCount
 
- Protected Attributes inherited from mn::basic_semaphore
void * m_pSpinlock
 
int m_iCreateErrorCode
 
bool m_isLocked
 

Additional Inherited Members

- Public Types inherited from mn::ILockObject
using this_type = ILockObject
 
- Protected Member Functions inherited from mn::basic_semaphore
void set_error (int error)
 

Constructor & Destructor Documentation

◆ basic_counting_semaphore() [1/3]

mn::basic_counting_semaphore::basic_counting_semaphore ( int  count = MN_THREAD_CONFIG_CSEMAPHORE_MIN_COUNT,
int  maxcount = MN_THREAD_CONFIG_CSEMAPHORE_MAX_COUNT 
)

Create the counting semaphore

Note
When enabled the config item MN_THREAD_CONFIG_USE_LOCK_CREATE then throw on error the lockcreate_exception exceptions and the config item MN_THREAD_CONFIG_DEBUG enabled, then with debug informations. When the config item MN_THREAD_CONFIG_USE_LOCK_CREATE disabled then get the created error code with basic_semaphore::get_error()
Parameters
countMust not be greater than maxCount.
maxcountMust be greater than 0.

◆ basic_counting_semaphore() [2/3]

mn::basic_counting_semaphore::basic_counting_semaphore ( const basic_counting_semaphore o)
inline

◆ basic_counting_semaphore() [3/3]

mn::basic_counting_semaphore::basic_counting_semaphore ( basic_counting_semaphore &&  o)
inline

◆ ~basic_counting_semaphore()

mn::basic_counting_semaphore::~basic_counting_semaphore ( )
virtual

Member Function Documentation

◆ get_count()

int mn::basic_counting_semaphore::get_count ( ) const

Get the current count value.

Returns
The current count and 0 if the semaphore is not available.

◆ set_initial_count()

void mn::basic_counting_semaphore::set_initial_count ( int  count)
inline

Set the initial count

Parameters
countthe new initial count
Note
only call befor create, after this have no effect

◆ set_max_count()

void mn::basic_counting_semaphore::set_max_count ( int  count)
inline

Set the max count

Parameters
countthe new max count
Note
only call befor create, after this have no effect

Member Data Documentation

◆ m_uiCount

int mn::basic_counting_semaphore::m_uiCount
protected

◆ m_uiMaxCount

int mn::basic_counting_semaphore::m_uiMaxCount
protected

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