QuickCppLib 0.10
Eliminate all the tedious hassle when making state-of-the-art C++ 14 - 23 libraries!
Loading...
Searching...
No Matches
spinlock.hpp File Reference

Provides a Lockable policy driven spinlock. More...

#include "config.hpp"
#include <atomic>
#include <chrono>
#include <thread>

Classes

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

Namespaces

namespace  quickcpplib
 The QuickCppLib namespace.
 
namespace  quickcpplib::_xxx
 Per commit unique namespace to prevent different git submodule versions clashing.
 
namespace  quickcpplib::_xxx::configurable_spinlock
 
namespace  quickcpplib::_xxx::configurable_spinlock::detail
 

Macros

#define QUICKCPPLIB_BEGIN_TRANSACT_LOCK(lockable)
 
#define QUICKCPPLIB_BEGIN_TRANSACT_LOCK_ONLY_IF_NOT(lockable, only_if_not_this)
 
#define QUICKCPPLIB_END_TRANSACT_LOCK(lockable)   }
 
#define QUICKCPPLIB_BEGIN_NESTED_TRANSACT_LOCK(N)
 
#define QUICKCPPLIB_END_NESTED_TRANSACT_LOCK(N)
 

Typedefs

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

Functions

template<bool use_pause>
void quickcpplib::_xxx::configurable_spinlock::detail::smt_pause () noexcept
 
template<>
void quickcpplib::_xxx::configurable_spinlock::detail::smt_pause< true > () noexcept
 
template<class T >
bool quickcpplib::_xxx::configurable_spinlock::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 quickcpplib::_xxx::configurable_spinlock::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 quickcpplib::_xxx::configurable_spinlock::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 quickcpplib::_xxx::configurable_spinlock::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 quickcpplib::_xxx::configurable_spinlock::is_lockable_locked (shared_spinlock< T, spinpolicy2, spinpolicy3, spinpolicy4 > &lockable) noexcept
 

Detailed Description

Provides a Lockable policy driven spinlock.

Macro Definition Documentation

◆ QUICKCPPLIB_BEGIN_TRANSACT_LOCK

#define QUICKCPPLIB_BEGIN_TRANSACT_LOCK (   lockable)
Value:
{ \
QUICKCPPLIB_NAMESPACE::configurable_spinlock::lock_guard<decltype(lockable)> __tsx_transaction(lockable);
920 { \
921 QUICKCPPLIB_NAMESPACE::configurable_spinlock::lock_guard<decltype(lockable)> __tsx_transaction(lockable);

◆ QUICKCPPLIB_BEGIN_TRANSACT_LOCK_ONLY_IF_NOT

#define QUICKCPPLIB_BEGIN_TRANSACT_LOCK_ONLY_IF_NOT (   lockable,
  only_if_not_this 
)
Value:
if(lockable.lock(only_if_not_this)) \
{ \
QUICKCPPLIB_NAMESPACE::configurable_spinlock::lock_guard<decltype(lockable)> __tsx_transaction( \
lockable, QUICKCPPLIB_NAMESPACE::adopt_lock_t());
924 { \
925 QUICKCPPLIB_NAMESPACE::configurable_spinlock::lock_guard<decltype(lockable)> __tsx_transaction( \
926 lockable, QUICKCPPLIB_NAMESPACE::adopt_lock_t());

◆ QUICKCPPLIB_END_TRANSACT_LOCK

#define QUICKCPPLIB_END_TRANSACT_LOCK (   lockable)    }

◆ QUICKCPPLIB_BEGIN_NESTED_TRANSACT_LOCK

#define QUICKCPPLIB_BEGIN_NESTED_TRANSACT_LOCK (   N)

◆ QUICKCPPLIB_END_NESTED_TRANSACT_LOCK

#define QUICKCPPLIB_END_NESTED_TRANSACT_LOCK (   N)