Mir
Classes | Public Types | Public Member Functions | List of all members
mir::Synchronised< T > Class Template Reference

An object that enforces unique access to the data it contains. More...

#include <synchronised.h>

Classes

class  LockedImpl
 Smart-pointer-esque accessor for the protected data. More...
 

Public Types

using Locked = LockedImpl< T >
 Smart-pointer-esque accessor for the protected data. More...
 
using LockedView = LockedImpl< T const >
 Smart-pointer-esque accessor for the protected data. More...
 

Public Member Functions

 Synchronised ()=default
 
 Synchronised (T &&initial_value)
 
 Synchronised (Synchronised const &)=delete
 
Synchronisedoperator= (Synchronised const &)=delete
 
auto lock () -> Locked
 Lock the data and return an accessor. More...
 
auto lock () const -> LockedView
 Lock the data and return an accessor. More...
 

Detailed Description

template<typename T>
class mir::Synchronised< T >

An object that enforces unique access to the data it contains.

This behaves like a mutex which owns the data it guards, and can give out a smart-pointer-esque handle to lock and access it.

Template Parameters
TThe type of data contained

Member Typedef Documentation

◆ Locked

template<typename T >
using mir::Synchronised< T >::Locked = LockedImpl<T>

Smart-pointer-esque accessor for the protected data.

Ensures exclusive access to the referenced data.

Note
Instances of Locked must not outlive the Synchronised they are derived from.

◆ LockedView

template<typename T >
using mir::Synchronised< T >::LockedView = LockedImpl<T const>

Smart-pointer-esque accessor for the protected data.

Provides const access to the protected data, with the guarantee that no changes to the data can be made while this handle is live.

Note
Instances of Locked must not outlive the Synchronised they are derived from.

Constructor & Destructor Documentation

◆ Synchronised() [1/3]

template<typename T >
mir::Synchronised< T >::Synchronised ( )
default

◆ Synchronised() [2/3]

template<typename T >
mir::Synchronised< T >::Synchronised ( T &&  initial_value)
inline

◆ Synchronised() [3/3]

template<typename T >
mir::Synchronised< T >::Synchronised ( Synchronised< T > const &  )
delete

Member Function Documentation

◆ lock() [1/2]

template<typename T >
auto mir::Synchronised< T >::lock ( ) -> Locked
inline

Lock the data and return an accessor.

Returns
A smart-pointer-esque accessor for the contained data. While code has access to a live Locked instance it is guaranteed to have unique access to the contained data.

◆ lock() [2/2]

template<typename T >
auto mir::Synchronised< T >::lock ( ) const -> LockedView
inline

Lock the data and return an accessor.

Returns
A smart-pointer-esque accessor for the contained data. While code has access to a live Locked instance it is guaranteed to have unique access to the contained data.

◆ operator=()

template<typename T >
Synchronised & mir::Synchronised< T >::operator= ( Synchronised< T > const &  )
delete

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

Copyright © 2012-2023 Canonical Ltd.
Generated on Tue 2 May 10:01:24 UTC 2023
This documentation is licensed under the GPL version 2 or 3.