diff options
author | bunnei <bunneidev@gmail.com> | 2021-01-31 16:54:10 -0800 |
---|---|---|
committer | bunnei <bunneidev@gmail.com> | 2021-02-05 14:03:36 -0800 |
commit | 18175c71edf90eeb73c6f47745b2bad32e4a1478 (patch) | |
tree | bbbdf4a73a37aa3d77a7e29ed0d5af9a47190324 /src/common/scope_exit.h | |
parent | ff3c7c068b926399513bf7328c22e224ab0b53d6 (diff) |
common: scope_exit: Add a cancellable ScopeExit macro.
Diffstat (limited to 'src/common/scope_exit.h')
-rw-r--r-- | src/common/scope_exit.h | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/common/scope_exit.h b/src/common/scope_exit.h index fa46cb3945..35dac3a8f9 100644 --- a/src/common/scope_exit.h +++ b/src/common/scope_exit.h @@ -49,3 +49,9 @@ ScopeExitHelper<Func> ScopeExit(Func&& func) { * \endcode */ #define SCOPE_EXIT(body) auto CONCAT2(scope_exit_helper_, __LINE__) = detail::ScopeExit([&]() body) + +/** + * This macro is similar to SCOPE_EXIT, except the object is caller managed. This is intended to be + * used when the caller might want to cancel the ScopeExit. + */ +#define SCOPE_GUARD(body) detail::ScopeExit([&]() body) |