about summary refs log tree commit diff
path: root/src/libutil
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-08T16·07+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-08T16·07+0200
commitf398949b40624488b54b35d446a9b5ac46101739 (patch)
tree34a8382e793d237a8eaabd65f4afecace06081a0 /src/libutil
parent05fbc606fc1ce4a764276b7dee6ed49859de9d57 (diff)
Make LocalStore thread-safe
Necessary for multi-threaded commands like "nix verify-paths".
Diffstat (limited to 'src/libutil')
-rw-r--r--src/libutil/sync.hh6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/libutil/sync.hh b/src/libutil/sync.hh
index c99c098ac9..ebe64ffbda 100644
--- a/src/libutil/sync.hh
+++ b/src/libutil/sync.hh
@@ -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: