about summary refs log tree commit diff
path: root/src/nix-env/profiles.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2010-05-12T22·13+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2010-05-12T22·13+0000
commitaa45027818af8976dc73e6a299d5d918e5c51df1 (patch)
tree6086eb0642bc90477397169d0ee3993c1789200e /src/nix-env/profiles.hh
parenta0e3b84fac56cad6377ecd1462058a6b29bb1ea8 (diff)
parent8032f26ca0bd2233de066ce5786ff976bbd641ae (diff)
* Sync with the trunk.
Diffstat (limited to 'src/nix-env/profiles.hh')
-rw-r--r--src/nix-env/profiles.hh15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/nix-env/profiles.hh b/src/nix-env/profiles.hh
index 99c20f42d18c..a64258dae224 100644
--- a/src/nix-env/profiles.hh
+++ b/src/nix-env/profiles.hh
@@ -2,6 +2,7 @@
 #define __PROFILES_H
 
 #include "types.hh"
+#include "pathlocks.hh"
 
 #include <time.h>
 
@@ -37,6 +38,20 @@ void deleteGeneration(const Path & profile, unsigned int gen);
 
 void switchLink(Path link, Path target);
 
+/* Ensure exclusive access to a profile.  Any command that modifies
+   the profile first acquires this lock. */
+void lockProfile(PathLocks & lock, const Path & profile);
+
+/* Optimistic locking is used by long-running operations like `nix-env
+   -i'.  Instead of acquiring the exclusive lock for the entire
+   duration of the operation, we just perform the operation
+   optimistically (without an exclusive lock), and check at the end
+   whether the profile changed while we were busy (i.e., the symlink
+   target changed).  If so, the operation is restarted.  Restarting is
+   generally cheap, since the build results are still in the Nix
+   store.  Most of the time, only the user environment has to be
+   rebuilt. */
+string optimisticLockProfile(const Path & profile);
 
 }