|
Nix 2.93.3
Lix: A modern, delicious implementation of the Nix package manager; unstable internal interfaces
|
#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< Lock > | tryLock () |
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.