about summary refs log tree commit diff
path: root/src/libutil/finally.hh
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-29T11·57+0200
committerEelco Dolstra <eelco.dolstra@logicblox.com>2016-04-29T11·57+0200
commitaa3bc3d5dcff5ff6567a4e00320cb9caa28c5a93 (patch)
treeca430fbdbfad473105b78384eb200dcce797fd0e /src/libutil/finally.hh
parent21e9d183ccf4216a61e0bb89d7e2eb42ce092e85 (diff)
Eliminate the substituter mechanism
Substitution is now simply a Store -> Store copy operation, most
typically from BinaryCacheStore to LocalStore.
Diffstat (limited to 'src/libutil/finally.hh')
-rw-r--r--src/libutil/finally.hh12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libutil/finally.hh b/src/libutil/finally.hh
new file mode 100644
index 000000000000..47c64deaecea
--- /dev/null
+++ b/src/libutil/finally.hh
@@ -0,0 +1,12 @@
+#pragma once
+
+/* A trivial class to run a function at the end of a scope. */
+class Finally
+{
+private:
+    std::function<void()> fun;
+
+public:
+    Finally(std::function<void()> fun) : fun(fun) { }
+    ~Finally() { fun(); }
+};