Pol  Revision:4b29d2b
Pol::Clib::SpinLock Class Reference

#include <spinlock.h>

Public Member Functions

 SpinLock ()
 
 ~SpinLock ()
 

Private Member Functions

void lock ()
 
void unlock ()
 

Private Attributes

std::atomic_flag _lck
 

Friends

class std::lock_guard< SpinLock >
 

Detailed Description

This is a much faster replacement for mutex when locking very small and fast running protected parts. It is based on a busy loop.

Warning
use it only through SpinLockGuard

Definition at line 17 of file spinlock.h.

Constructor & Destructor Documentation

Pol::Clib::SpinLock::SpinLock ( )
inline

Definition at line 35 of file spinlock.h.

References _lck.

Pol::Clib::SpinLock::~SpinLock ( )
inline

Definition at line 39 of file spinlock.h.

Member Function Documentation

void Pol::Clib::SpinLock::lock ( )
inlineprivate

Puts the caller in an endless busy loop until it acquires the lock

Definition at line 44 of file spinlock.h.

References _lck.

void Pol::Clib::SpinLock::unlock ( )
inlineprivate

Releases the lock

Definition at line 54 of file spinlock.h.

References _lck.

Friends And Related Function Documentation

friend class std::lock_guard< SpinLock >
friend

Definition at line 19 of file spinlock.h.

Member Data Documentation

std::atomic_flag Pol::Clib::SpinLock::_lck
private

Definition at line 29 of file spinlock.h.

Referenced by lock(), SpinLock(), and unlock().


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