mn::atomic_spinlock< T > Class Template Reference

This class implements a simple spinlack, whit atomic operations. More...

#include <mn_atomic_spinlock.hpp>

+ Inheritance diagram for mn::atomic_spinlock< T >:
+ Collaboration diagram for mn::atomic_spinlock< T >:

Public Types

using self_type = atomic_spinlock< T >
 
using value_type = T
 
using pointer = value_type *
 
using reference = value_type &
 
using lock_guard = basic_autolock< self_type >
 
- Public Types inherited from mn::ILockObject
using this_type = ILockObject
 

Public Member Functions

 atomic_spinlock ()
 Construct a new atomic_spinlock. More...
 
 atomic_spinlock (const reference value)
 Construct a new atomic_spinlock and initializes it with the given value. More...
 
virtual int lock (unsigned int not_use=0)
 
virtual int time_lock (const struct timespec *timeout)
 
virtual int unlock ()
 
virtual bool try_lock ()
 
virtual bool is_initialized () const
 
 operator value_type ()
 Converts the atomic_spinlock to value_type. More...
 
self_typeoperator= (const value_type &oValue)
 
bool operator== (const value_type &oValue)
 
bool operator!= (const value_type &oValue)
 
 atomic_spinlock (const self_type &)=delete
 
self_typeoperator= (const self_type &)=delete
 
- Public Member Functions inherited from mn::ILockObject
 ILockObject ()
 
virtual bool is_locked () const =0
 Is locked? More...
 

Protected Attributes

atomic_bool m_locked
 
value_type m_value
 

Detailed Description

template<typename T>
class mn::atomic_spinlock< T >

This class implements a simple spinlack, whit atomic operations.

Template Parameters
TThe type of the object to lock

Member Typedef Documentation

◆ lock_guard

template<typename T >
using mn::atomic_spinlock< T >::lock_guard = basic_autolock<self_type>

◆ pointer

template<typename T >
using mn::atomic_spinlock< T >::pointer = value_type*

◆ reference

template<typename T >
using mn::atomic_spinlock< T >::reference = value_type&

◆ self_type

template<typename T >
using mn::atomic_spinlock< T >::self_type = atomic_spinlock<T>

◆ value_type

template<typename T >
using mn::atomic_spinlock< T >::value_type = T

Constructor & Destructor Documentation

◆ atomic_spinlock() [1/3]

template<typename T >
mn::atomic_spinlock< T >::atomic_spinlock ( )
inline

Construct a new atomic_spinlock.

◆ atomic_spinlock() [2/3]

template<typename T >
mn::atomic_spinlock< T >::atomic_spinlock ( const reference  value)
inlineexplicit

Construct a new atomic_spinlock and initializes it with the given value.

Parameters
valueThe locked value

◆ atomic_spinlock() [3/3]

template<typename T >
mn::atomic_spinlock< T >::atomic_spinlock ( const self_type )
delete

Member Function Documentation

◆ is_initialized()

template<typename T >
virtual bool mn::atomic_spinlock< T >::is_initialized ( ) const
inlinevirtual

Is the atomic_spinlock created (initialized) ?

Returns
true if the atomic_spinlock created (initialized)

Implements mn::ILockObject.

◆ lock()

template<typename T >
virtual int mn::atomic_spinlock< T >::lock ( unsigned int  not_use = 0)
inlinevirtual

lock (take) a atomic_spinlock

Parameters
timeoutNot use

Implements mn::ILockObject.

◆ operator value_type()

template<typename T >
mn::atomic_spinlock< T >::operator value_type ( )
inline

Converts the atomic_spinlock to value_type.

Returns
The convertet value

◆ operator!=()

template<typename T >
bool mn::atomic_spinlock< T >::operator!= ( const value_type oValue)
inline

◆ operator=() [1/2]

template<typename T >
self_type& mn::atomic_spinlock< T >::operator= ( const self_type )
delete

◆ operator=() [2/2]

template<typename T >
self_type& mn::atomic_spinlock< T >::operator= ( const value_type oValue)
inline

◆ operator==()

template<typename T >
bool mn::atomic_spinlock< T >::operator== ( const value_type oValue)
inline

◆ time_lock()

template<typename T >
virtual int mn::atomic_spinlock< T >::time_lock ( const struct timespec *  timeout)
inlinevirtual

Implements mn::ILockObject.

◆ try_lock()

template<typename T >
virtual bool mn::atomic_spinlock< T >::try_lock ( )
inlinevirtual

Try to lock the atomic_spinlock

Note
call lock with timeout from 0
Returns
true if the Lock was acquired, false when not

Reimplemented from mn::ILockObject.

◆ unlock()

template<typename T >
virtual int mn::atomic_spinlock< T >::unlock ( )
inlinevirtual

unlock (give) a atomic_spinlock.

Implements mn::ILockObject.

Member Data Documentation

◆ m_locked

template<typename T >
atomic_bool mn::atomic_spinlock< T >::m_locked
protected

◆ m_value

template<typename T >
value_type mn::atomic_spinlock< T >::m_value
protected

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