bm::spin_lock< Pad > Class Template Reference
BitMagic Library » Task parallel programming

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.
bool | try_lock () noexcept
| Try to acquire the lock, return true if successfull.
void | unlock () noexcept
| Unlock the lock.

## 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.

## Constructor & Destructor Documentation

## spin_lock()

template<class Pad = bm::pad0_struct>

bm::spin_lock< Pad >::spin_lock | ( |  | ) |

inline noexcept

Definition at line 58 of file bmthreadpool.h.

## Member Function Documentation

## lock()

template<class Pad = bm::pad0_struct>

void bm::spin_lock< Pad >::lock | ( |  | ) |

inline noexcept

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 | ( |  | ) |

inline noexcept

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 | ( |  | ) |

inline noexcept

Unlock the lock.

Definition at line 89 of file bmthreadpool.h.

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

- bmthreadpool.h