summaryrefslogtreecommitdiffstats
path: root/src/common/scope_exit.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/common/scope_exit.h')
-rw-r--r--src/common/scope_exit.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/common/scope_exit.h b/src/common/scope_exit.h
index 1176a72b1..68ef5f197 100644
--- a/src/common/scope_exit.h
+++ b/src/common/scope_exit.h
@@ -12,10 +12,17 @@ template <typename Func>
struct ScopeExitHelper {
explicit ScopeExitHelper(Func&& func) : func(std::move(func)) {}
~ScopeExitHelper() {
- func();
+ if (active) {
+ func();
+ }
+ }
+
+ void Cancel() {
+ active = false;
}
Func func;
+ bool active{true};
};
template <typename Func>