Support Class Library
A set of tools providing classes and utility
Public Types | Public Member Functions | Protected Attributes | List of all members
scl::async::Mutexed< T, Lock, Guard > Class Template Reference

A wrapper class that protects a value with a lock. More...

#include "Mutexed.h"

Collaboration diagram for scl::async::Mutexed< T, Lock, Guard >:
Collaboration graph
[legend]

Public Types

using lock_type = Lock
 
using guard_type = Guard< lock_type >
 
using value_type = T
 

Public Member Functions

template<class... Args>
 Mutexed (Args &&... args)
 
 Mutexed (Mutexed &&) noexcept=default
 
Mutexedoperator= (Mutexed &&) noexcept=default
 
 Mutexed (const Mutexed &)=delete
 
Mutexedoperator= (const Mutexed &)=delete
 
template<class F >
Mutexedtransaction (F &&f)
 

Protected Attributes

value_type value
 
std::unique_lock< lock_typelock {lock_type{}, std::defer_lock}
 

Detailed Description

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
class scl::async::Mutexed< T, Lock, Guard >

A wrapper class that protects a value with a lock.

Template Parameters
Tbeing the type of value to guard
Lockbeing the lock type
Guardbeing the type of guard to use on the lock

Definition at line 14 of file Mutexed.h.

Member Typedef Documentation

◆ guard_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
using scl::async::Mutexed< T, Lock, Guard >::guard_type = Guard<lock_type>

Definition at line 17 of file Mutexed.h.

◆ lock_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
using scl::async::Mutexed< T, Lock, Guard >::lock_type = Lock

Definition at line 16 of file Mutexed.h.

◆ value_type

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
using scl::async::Mutexed< T, Lock, Guard >::value_type = T

Definition at line 18 of file Mutexed.h.

Constructor & Destructor Documentation

◆ Mutexed() [1/3]

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
template<class... Args>
scl::async::Mutexed< T, Lock, Guard >::Mutexed ( Args &&...  args)
inlineexplicit

Definition at line 26 of file Mutexed.h.

◆ Mutexed() [2/3]

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
scl::async::Mutexed< T, Lock, Guard >::Mutexed ( Mutexed< T, Lock, Guard > &&  )
defaultnoexcept

◆ Mutexed() [3/3]

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
scl::async::Mutexed< T, Lock, Guard >::Mutexed ( const Mutexed< T, Lock, Guard > &  )
delete

Member Function Documentation

◆ operator=() [1/2]

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
Mutexed& scl::async::Mutexed< T, Lock, Guard >::operator= ( Mutexed< T, Lock, Guard > &&  )
defaultnoexcept

◆ operator=() [2/2]

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
Mutexed& scl::async::Mutexed< T, Lock, Guard >::operator= ( const Mutexed< T, Lock, Guard > &  )
delete

◆ transaction()

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
template<class F >
Mutexed& scl::async::Mutexed< T, Lock, Guard >::transaction ( F &&  f)
inline

Definition at line 36 of file Mutexed.h.

Member Data Documentation

◆ lock

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
std::unique_lock<lock_type> scl::async::Mutexed< T, Lock, Guard >::lock {lock_type{}, std::defer_lock}
mutableprotected

Definition at line 22 of file Mutexed.h.

◆ value

template<class T, class Lock = std::mutex, template< class > class Guard = std::lock_guard>
value_type scl::async::Mutexed< T, Lock, Guard >::value
protected

Definition at line 21 of file Mutexed.h.


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