#include "spinlock.hpp"
◆ value_type
◆ shared_spinlockbase() [1/3]
  458    {
  460#if QUICKCPPLIB_IN_THREAD_SANITIZER
  461      _v.store(0, memory_order_release);
 
  462#endif
  463    }
#define QUICKCPPLIB_ANNOTATE_RWLOCK_CREATE(p)
Definition config.hpp:102
 
atomic< value_type > _v
Definition spinlock.hpp:450
 
 
 
 
◆ shared_spinlockbase() [2/3]
◆ shared_spinlockbase() [3/3]
Atomically move constructs. 
  468    {
  470
  471#if QUICKCPPLIB_IN_THREAD_SANITIZER
  472      _v.store(0, memory_order_release);
 
  473#endif
  474    }
 
 
 
◆ ~shared_spinlockbase()
  476    {
  477#ifdef QUICKCPPLIB_ENABLE_VALGRIND
  479      if(i == 1)
  480      {
  482      }
  483      else if(i != 0)
  484      {
  486      }
  487#endif
  489    }
#define QUICKCPPLIB_ANNOTATE_RWLOCK_DESTROY(p)
Definition config.hpp:103
 
#define QUICKCPPLIB_ANNOTATE_RWLOCK_RELEASED(p, s)
Definition config.hpp:105
 
T value_type
Definition spinlock.hpp:447
 
 
 
 
◆ operator=() [1/2]
◆ operator=() [2/2]
◆ load()
Returns the raw atomic. 
  493{ 
return _v.load(o); }
 
 
 
 
◆ store()
◆ try_lock()
Tries to lock the spinlock for exclusive access, returning true if successful. 
  499    {
  501      
  502      if(i)
  503        return false;
  504      o = 1;
  505      if(
_v.compare_exchange_weak(i, o, memory_order_acquire, memory_order_relaxed))
 
  506      {
  508        return true;
  509      }
  510      return false;
  511    }
#define QUICKCPPLIB_ANNOTATE_RWLOCK_ACQUIRED(p, s)
Definition config.hpp:104
 
 
 
 
◆ unlock()
Releases the lock from exclusive access. 
  514    {
  515      
  517      _v.store(0, memory_order_release);
 
  518    }
 
 
 
◆ try_lock_shared()
Tries to lock the spinlock for shared access, returning true if successful. 
  522    {
  523      
  525      if(i & 1)
  526        return false;
  527      
  528      i += 2;
  529      i &= ~1;
  530      _v.store(i, memory_order_release);
 
  532      return true;
  533    }
 
 
 
◆ unlock_shared()
Releases the lock from shared access. 
  536    {
  538      for(size_t n = 0;; n++)
  539      {
  540        i = 
_v.fetch_or(1, memory_order_acquire);
 
  541        
  542        if(!(i & 1))
  543          break;
  544        
  545        if(n > 2)
  546        {
  547          for(size_t m = 0; m < 15000; m = m + 1)
  548          {
  549            volatile int x = 1;
  550            (void) x;
  551          }
  552        }
  553      }
  555      i -= 2;
  556      i &= ~1;
  557      _v.store(i, memory_order_release);
 
  558    }
 
 
 
◆ try_convert_lock_to_shared()
Tries to convert an exclusive lock to a shared lock, returning true if successful. 
  562    {
  564      return _v.compare_exchange_strong(expected, 2, memory_order_acquire, memory_order_relaxed);
 
  565    }
 
 
 
◆ try_convert_lock_to_exclusive()
Tries to convert a shared lock to an exclusive lock, returning true if successful. 
  568    {
  570      return _v.compare_exchange_strong(expected, 1, memory_order_acquire, memory_order_relaxed);
 
  571    }
 
 
 
◆ int_yield()
◆ _v
The documentation for this struct was generated from the following file: