Void Sentry
An AI-driven, real-time Sentry Turret platform leveraging asynchronous I/O and computer vision to deliver high-precision autonomous motion tracking on resource-constrained embedded hardware.
Loading...
Searching...
No Matches
vsync::SpinGuarded< T > Class Template Reference

A value of type T that owns its own spinlock; every access is one short critical section. More...

#include <sync.h>

Public Member Functions

 SpinGuarded (const T &initial)
 
 SpinGuarded (const SpinGuarded &)=delete
 
SpinGuarded & operator= (const SpinGuarded &)=delete
 
T load () const
 Returns a copy of the value, made under the lock.
 
void store (const T &value)
 Replaces the value under the lock.
 
template<typename F >
decltype(auto) update (F &&f)
 Runs f(T&) under the lock and returns its result (void is fine).
 
template<typename F >
decltype(auto) inspect (F &&f) const
 Runs f(const T&) under the lock and returns its result; use it to copy out one field.
 

Detailed Description

template<typename T>
class vsync::SpinGuarded< T >

A value of type T that owns its own spinlock; every access is one short critical section.

T should be a small trivially copyable struct. load() and store() copy the whole value, update() and inspect() run a callback on the live value under the lock, so a callback must only copy or assign (no blocking calls, no logging, no allocation) to keep the section as short as the hand-written enter/exit pairs it replaces.


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