Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
Loading...
Searching...
No Matches
nix::Sync< T, M > Class Template Reference

#include <sync.hh>

Classes

class  Lock

Public Member Functions

 Sync (const T &data)
 Sync (T &&data) noexcept
template<typename ... Args>
 Sync (std::in_place_t, Args &&... args)
Lock lock ()
std::optional< LocktryLock ()

Detailed Description

template<class T, class M = std::mutex>
class nix::Sync< T, M >

This template class ensures synchronized access to a value of type T. It is used as follows:

struct Data { int x; ... };

Sync<Data> data;

{ auto data_(data.lock()); data_->x = 123; }

Here, "data" is automatically unlocked when "data_" goes out of scope.

Member Function Documentation

◆ lock()

template<class T, class M = std::mutex>
Lock nix::Sync< T, M >::lock ( )
inline

Lock this Sync and return a RAII guard object.


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