Nix 2.26.3
Nix, the purely functional package manager; unstable internal interfaces
 
Loading...
Searching...
No Matches
nix::SyncBase< T, M, WL, RL > Class Template Reference

#include <sync.hh>

Classes

class  Lock
 
struct  ReadLock
 
struct  WriteLock
 

Public Member Functions

 SyncBase (const T &data)
 
 SyncBase (T &&data) noexcept
 
WriteLock lock ()
 
ReadLock readLock () const
 

Detailed Description

template<class T, class M, class WL, class RL>
class nix::SyncBase< T, M, WL, RL >

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, class WL, class RL>
WriteLock nix::SyncBase< T, M, WL, RL >::lock ( )
inline

Acquire write (exclusive) access to the inner value.

◆ readLock()

template<class T, class M, class WL, class RL>
ReadLock nix::SyncBase< T, M, WL, RL >::readLock ( ) const
inline

Acquire read access to the inner value. When using std::shared_mutex, this will use a shared lock.


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