mirror of
https://github.com/yuzu-emu/yuzu-mainline
synced 2024-11-23 16:03:51 +00:00
common: scope_exit: Implement mechanism for canceling a scope exit.
This commit is contained in:
parent
4caff51710
commit
4df6ef04ac
1 changed files with 8 additions and 1 deletions
|
@ -12,10 +12,17 @@ template <typename Func>
|
||||||
struct ScopeExitHelper {
|
struct ScopeExitHelper {
|
||||||
explicit ScopeExitHelper(Func&& func) : func(std::move(func)) {}
|
explicit ScopeExitHelper(Func&& func) : func(std::move(func)) {}
|
||||||
~ScopeExitHelper() {
|
~ScopeExitHelper() {
|
||||||
|
if (active) {
|
||||||
func();
|
func();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cancel() {
|
||||||
|
active = false;
|
||||||
|
}
|
||||||
|
|
||||||
Func func;
|
Func func;
|
||||||
|
bool active{true};
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename Func>
|
template <typename Func>
|
||||||
|
|
Loading…
Reference in a new issue