QuickCppLib 0.10
Eliminate all the tedious hassle when making state-of-the-art C++ 14 - 23 libraries!
Loading...
Searching...
No Matches
quickcpplib::_xxx::configurable_spinlock Namespace Reference

Namespaces

namespace  detail
 

Classes

class  lock_guard
 
struct  lockable_ptr
 Lets you use a pointer to memory as a spinlock :) More...
 
struct  null_spin_policy
 A spin policy which does nothing. More...
 
struct  ordered_spinlockbase
 
class  shared_spinlock
 A non-FIFO policy configurable shared/exclusive spin lock meeting the SharedMutex concept. More...
 
struct  shared_spinlockbase
 
class  spinlock
 A non-FIFO policy configurable spin lock meeting the Mutex concept providing the fastest possible spin lock. More...
 
struct  spinlockbase
 
struct  spinlockbase< lockable_ptr< T > >
 
struct  spins_to_loop
 How many spins to loop, optionally calling the SMT pause instruction on Intel. More...
 
struct  spins_to_sleep
 How many spins to sleep the current thread. More...
 
struct  spins_to_yield
 How many spins to yield the current thread's timeslice. More...
 

Typedefs

template<class T >
using atomic = std::atomic< T >
 

Functions

template<class T >
bool is_lockable_locked (T &lockable) noexcept
 Determines if a lockable is locked. Type specialise this for performance if your lockable allows examination.
 
template<class T , template< class > class spinpolicy2, template< class > class spinpolicy3, template< class > class spinpolicy4>
constexpr T is_lockable_locked (spinlock< T, spinpolicy2, spinpolicy3, spinpolicy4 > &lockable) noexcept
 
template<class T , template< class > class spinpolicy2, template< class > class spinpolicy3, template< class > class spinpolicy4>
constexpr T is_lockable_locked (const spinlock< T, spinpolicy2, spinpolicy3, spinpolicy4 > &lockable) noexcept
 
template<class T , template< class > class spinpolicy2, template< class > class spinpolicy3, template< class > class spinpolicy4>
constexpr bool is_lockable_locked (spinlock< lockable_ptr< T >, spinpolicy2, spinpolicy3, spinpolicy4 > &lockable) noexcept
 
template<class T , template< class > class spinpolicy2, template< class > class spinpolicy3, template< class > class spinpolicy4>
constexpr T is_lockable_locked (shared_spinlock< T, spinpolicy2, spinpolicy3, spinpolicy4 > &lockable) noexcept
 

Typedef Documentation

◆ atomic

template<class T >
using quickcpplib::_xxx::configurable_spinlock::atomic = typedef std::atomic<T>

Function Documentation

◆ is_lockable_locked() [1/5]

template<class T >
bool quickcpplib::_xxx::configurable_spinlock::is_lockable_locked ( T &  lockable)
inlinenoexcept

Determines if a lockable is locked. Type specialise this for performance if your lockable allows examination.

823 {
824 if(lockable.try_lock())
825 {
826 lockable.unlock();
827 return false;
828 }
829 return true;
830 }

◆ is_lockable_locked() [2/5]

template<class T , template< class > class spinpolicy2, template< class > class spinpolicy3, template< class > class spinpolicy4>
constexpr T quickcpplib::_xxx::configurable_spinlock::is_lockable_locked ( spinlock< T, spinpolicy2, spinpolicy3, spinpolicy4 > &  lockable)
inlineconstexprnoexcept
835 {
836#ifdef QUICKCPPLIB_HAVE_TRANSACTIONAL_MEMORY_COMPILER
837 // Annoyingly the atomic ops are marked as unsafe for atomic transactions, so ...
838 return *((volatile T *) &lockable);
839#else
840 return lockable.load(memory_order_consume);
841#endif
842 }

◆ is_lockable_locked() [3/5]

template<class T , template< class > class spinpolicy2, template< class > class spinpolicy3, template< class > class spinpolicy4>
constexpr T quickcpplib::_xxx::configurable_spinlock::is_lockable_locked ( const spinlock< T, spinpolicy2, spinpolicy3, spinpolicy4 > &  lockable)
inlineconstexprnoexcept
847 {
848#ifdef QUICKCPPLIB_HAVE_TRANSACTIONAL_MEMORY_COMPILER
849 // Annoyingly the atomic ops are marked as unsafe for atomic transactions, so ...
850 return *((volatile T *) &lockable);
851#else
852 return lockable.load(memory_order_consume);
853#endif
854 }

◆ is_lockable_locked() [4/5]

template<class T , template< class > class spinpolicy2, template< class > class spinpolicy3, template< class > class spinpolicy4>
constexpr bool quickcpplib::_xxx::configurable_spinlock::is_lockable_locked ( spinlock< lockable_ptr< T >, spinpolicy2, spinpolicy3, spinpolicy4 > &  lockable)
inlineconstexprnoexcept
860 {
861 return ((size_t) lockable.load(memory_order_consume)) & 1;
862 }

◆ is_lockable_locked() [5/5]

template<class T , template< class > class spinpolicy2, template< class > class spinpolicy3, template< class > class spinpolicy4>
constexpr T quickcpplib::_xxx::configurable_spinlock::is_lockable_locked ( shared_spinlock< T, spinpolicy2, spinpolicy3, spinpolicy4 > &  lockable)
inlineconstexprnoexcept
888 {
889#ifdef QUICKCPPLIB_HAVE_TRANSACTIONAL_MEMORY_COMPILER
890 // Annoyingly the atomic ops are marked as unsafe for atomic transactions, so ...
891 return *((volatile T *) &lockable);
892#else
893 return lockable.load(memory_order_consume);
894#endif
895 }