BitMagic-C++
Public Member Functions
bm::spin_lock< Pad > Class Template Reference

Spin-lock with two-phase acquire (read + cas) padding parameter optionally adds a buffer to avoid CPU cache line contention. More...

#include <bmthreadpool.h>

Public Member Functions

 spin_lock () noexcept
 
void lock () noexcept
 Lock the lock. More...
 
bool try_lock () noexcept
 Try to acquire the lock, return true if successfull. More...
 
void unlock () noexcept
 Unlock the lock. More...
 

Detailed Description

template<class Pad = bm::pad0_struct>
class bm::spin_lock< Pad >

Spin-lock with two-phase acquire (read + cas) padding parameter optionally adds a buffer to avoid CPU cache line contention.

TODO: test if padding realy helps in our case

Generally spin_lock does not have advantage over std::mutex but in some specific cases like WebAssembly it may be better due no "noexcept" property

Definition at line 55 of file bmthreadpool.h.

Member Function Documentation

◆ lock()

template<class Pad = bm::pad0_struct>
void bm::spin_lock< Pad >::lock ( )
inlinenoexcept

Lock the lock.

Definition at line 61 of file bmthreadpool.h.

◆ try_lock()

template<class Pad = bm::pad0_struct>
bool bm::spin_lock< Pad >::try_lock ( )
inlinenoexcept

Try to acquire the lock, return true if successfull.

Definition at line 78 of file bmthreadpool.h.

◆ unlock()

template<class Pad = bm::pad0_struct>
void bm::spin_lock< Pad >::unlock ( )
inlinenoexcept

Unlock the lock.

Definition at line 89 of file bmthreadpool.h.


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