summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar bunnei2020-03-31 15:16:07 -0400
committerGravatar bunnei2020-04-17 00:59:28 -0400
commit4df6ef04ac5e2169bdba67937a0b301f569949d6 (patch)
treeb3341228156641d7e3f9d0aed5b4ab3ff1e8eb07 /src
parentcore: memory: Move to Core::Memory namespace. (diff)
downloadyuzu-4df6ef04ac5e2169bdba67937a0b301f569949d6.tar.gz
yuzu-4df6ef04ac5e2169bdba67937a0b301f569949d6.tar.xz
yuzu-4df6ef04ac5e2169bdba67937a0b301f569949d6.zip
common: scope_exit: Implement mechanism for canceling a scope exit.
Diffstat (limited to 'src')
-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>
12struct ScopeExitHelper { 12struct ScopeExitHelper {
13 explicit ScopeExitHelper(Func&& func) : func(std::move(func)) {} 13 explicit ScopeExitHelper(Func&& func) : func(std::move(func)) {}
14 ~ScopeExitHelper() { 14 ~ScopeExitHelper() {
15 func(); 15 if (active) {
16 func();
17 }
18 }
19
20 void Cancel() {
21 active = false;
16 } 22 }
17 23
18 Func func; 24 Func func;
25 bool active{true};
19}; 26};
20 27
21template <typename Func> 28template <typename Func>