Clio develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
util::Mutex< ProtectedDataType, MutexType > Class Template Reference

A container for data that is protected by a mutex. Inspired by Mutex in Rust. More...

#include <Mutex.hpp>

Public Member Functions

 Mutex (ProtectedDataType data)
 Construct a new Mutex object with the given data.
 
template<template< typename... > typename LockType = std::lock_guard>
Lock< ProtectedDataType const, LockType, MutexType > lock () const
 Lock the mutex and get a lock object allowing access to the protected data.
 
template<template< typename... > typename LockType = std::lock_guard>
Lock< ProtectedDataType, LockType, MutexType > lock ()
 Lock the mutex and get a lock object allowing access to the protected data.
 

Static Public Member Functions

template<typename... Args>
static Mutex make (Args &&... args)
 Make a new Mutex object with the given data.
 

Detailed Description

template<typename ProtectedDataType, typename MutexType = std::mutex>
class util::Mutex< ProtectedDataType, MutexType >

A container for data that is protected by a mutex. Inspired by Mutex in Rust.

Template Parameters
ProtectedDataTypedata type to hold
MutexTypetype of mutex

Constructor & Destructor Documentation

◆ Mutex()

template<typename ProtectedDataType , typename MutexType = std::mutex>
util::Mutex< ProtectedDataType, MutexType >::Mutex ( ProtectedDataType data)
inlineexplicit

Construct a new Mutex object with the given data.

Parameters
dataThe data to protect

Member Function Documentation

◆ lock() [1/2]

template<typename ProtectedDataType , typename MutexType = std::mutex>
template<template< typename... > typename LockType = std::lock_guard>
Lock< ProtectedDataType, LockType, MutexType > util::Mutex< ProtectedDataType, MutexType >::lock ( )
inline

Lock the mutex and get a lock object allowing access to the protected data.

Template Parameters
LockTypeThe type of lock to use
Returns
A lock on the mutex and a reference to the protected data

◆ lock() [2/2]

template<typename ProtectedDataType , typename MutexType = std::mutex>
template<template< typename... > typename LockType = std::lock_guard>
Lock< ProtectedDataType const, LockType, MutexType > util::Mutex< ProtectedDataType, MutexType >::lock ( ) const
inline

Lock the mutex and get a lock object allowing access to the protected data.

Template Parameters
LockTypeThe type of lock to use
Returns
A lock on the mutex and a reference to the protected data

◆ make()

template<typename ProtectedDataType , typename MutexType = std::mutex>
template<typename... Args>
static Mutex util::Mutex< ProtectedDataType, MutexType >::make ( Args &&... args)
inlinestatic

Make a new Mutex object with the given data.

Template Parameters
ArgsThe types of the arguments to forward to the constructor of the protected data
Parameters
argsThe arguments to forward to the constructor of the protected data
Returns
The Mutex object that protects the given data

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