mirror of
https://github.com/NixOS/nix
synced 2025-06-27 04:21:16 +02:00
Make LocalStore thread-safe
Necessary for multi-threaded commands like "nix verify-paths".
This commit is contained in:
parent
05fbc606fc
commit
f398949b40
5 changed files with 246 additions and 217 deletions
|
@ -22,11 +22,11 @@ namespace nix {
|
|||
scope.
|
||||
*/
|
||||
|
||||
template<class T>
|
||||
template<class T, class M = std::mutex>
|
||||
class Sync
|
||||
{
|
||||
private:
|
||||
std::mutex mutex;
|
||||
M mutex;
|
||||
T data;
|
||||
|
||||
public:
|
||||
|
@ -38,7 +38,7 @@ public:
|
|||
{
|
||||
private:
|
||||
Sync * s;
|
||||
std::unique_lock<std::mutex> lk;
|
||||
std::unique_lock<M> lk;
|
||||
friend Sync;
|
||||
Lock(Sync * s) : s(s), lk(s->mutex) { }
|
||||
public:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue