VLink  2.0.0
A high-performance communication middleware
vlink::SpinLockGuard Class Referencefinal

RAII wrapper that locks a SpinLock on construction and unlocks on destruction. More...

#include <spin_lock.h>

Collaboration diagram for vlink::SpinLockGuard:

Public Member Functions

 SpinLockGuard (SpinLock &lock) noexcept
 Acquires lock immediately. More...
 
 ~SpinLockGuard () noexcept
 Releases the held spin lock. More...
 

Detailed Description

RAII wrapper that locks a SpinLock on construction and unlocks on destruction.

Equivalent to std::lock_guard<SpinLock>. Preferred over manual lock / unlock because it is exception-safe.

Example
SpinLock my_lock;
{
SpinLockGuard guard(my_lock);
critical_section();
}

Constructor & Destructor Documentation

◆ SpinLockGuard()

vlink::SpinLockGuard::SpinLockGuard ( SpinLock lock)
inlineexplicitnoexcept

Acquires lock immediately.

Parameters
lockSpin lock to acquire. Must outlive this guard.

◆ ~SpinLockGuard()

vlink::SpinLockGuard::~SpinLockGuard ( )
inlinenoexcept

Releases the held spin lock.

Here is the call graph for this function:

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