diff options
Diffstat (limited to 'src/lib/scope_guard.h')
| -rw-r--r-- | src/lib/scope_guard.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/lib/scope_guard.h b/src/lib/scope_guard.h index ac60f9fea..e0d1e81fc 100644 --- a/src/lib/scope_guard.h +++ b/src/lib/scope_guard.h @@ -45,11 +45,19 @@ public: ~ScopeGuard () { - _function(); + if (!_cancelled) { + _function(); + } + } + + void cancel() + { + _cancelled = true; } private: std::function<void()> _function; + bool _cancelled = false; }; |
