mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-08-23 13:10:42 +02:00
common: scope_exit: Implement mechanism for canceling a scope exit.
This commit is contained in:
parent
4caff51710
commit
4df6ef04ac
@ -12,10 +12,17 @@ template <typename Func>
|
||||
struct ScopeExitHelper {
|
||||
explicit ScopeExitHelper(Func&& func) : func(std::move(func)) {}
|
||||
~ScopeExitHelper() {
|
||||
if (active) {
|
||||
func();
|
||||
}
|
||||
}
|
||||
|
||||
void Cancel() {
|
||||
active = false;
|
||||
}
|
||||
|
||||
Func func;
|
||||
bool active{true};
|
||||
};
|
||||
|
||||
template <typename Func>
|
||||
|
Loading…
Reference in New Issue
Block a user