Skip to content
Snippets Groups Projects
Commit 4df6ef04 authored by bunnei's avatar bunnei
Browse files

common: scope_exit: Implement mechanism for canceling a scope exit.

parent 4caff517
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment