VLink 2.0.0
A high-performance communication middleware
Loading...
Searching...
No Matches
vlink::SpinLockGuard Class Referencefinal

RAII guard that acquires a SpinLock on construction and releases it on destruction. More...

#include <spin_lock.h>

Collaboration diagram for vlink::SpinLockGuard:

Public Member Functions

 SpinLockGuard (SpinLock &lock) noexcept
 Acquires lock immediately.
 ~SpinLockGuard () noexcept
 Releases the lock held by this guard.

Detailed Description

RAII guard that acquires a SpinLock on construction and releases it on destruction.

Analogous 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
lockThe SpinLock to acquire. Must outlive this guard.
Here is the call graph for this function:

◆ ~SpinLockGuard()

vlink::SpinLockGuard::~SpinLockGuard ( )
inlinenoexcept

Releases the lock held by this guard.


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