Browse Source

common: scope_exit: Add a cancellable ScopeExit macro.

nce_cpp
bunnei 5 years ago
parent
commit
559c505126
  1. 6
      src/common/scope_exit.h

6
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)
Loading…
Cancel
Save