3es  0.7
tes::SpinLock Class Reference

A spin lock implementation. More...

#include <3esspinlock.h>

Public Member Functions

 SpinLock ()
 Construct a spin lock (unlocked).
 
 ~SpinLock ()
 Destructor.
 
void lock ()
 Block until the spin lock can be attained.
 
bool try_lock ()
 Try attain the lock without blocking. More...
 
void unlock ()
 Unlock the lock. More...
 

Detailed Description

A spin lock implementation.

Prefered over std::mutex as that class can be very slow (i.e, Clang OSX).

This is a naive implementation and does not support re-locking.

Best used with std::unique_lock as an exception and scope safe guard.

Member Function Documentation

◆ try_lock()

bool tes::SpinLock::try_lock ( )

Try attain the lock without blocking.

Returns
True if the lock is attained, false if it could not be attained.

◆ unlock()

void tes::SpinLock::unlock ( )

Unlock the lock.

Should only ever be called by the scope which called lock() or succeeded at try_lock.


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