We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent be5dd1a commit 32264c8Copy full SHA for 32264c8
rocket/once_flag.hpp
@@ -37,14 +37,16 @@ class once_flag
37
|| (::abi::__cxa_guard_acquire(this->m_guard) == 0))
38
return;
39
40
- try {
41
- forward<funcT>(func) (forward<paramsT>(params)...);
42
- ::abi::__cxa_guard_release(this->m_guard);
43
- }
44
- catch(...) {
45
- ::abi::__cxa_guard_abort(this->m_guard);
46
- throw;
47
+ struct Sentry
+ {
+ decltype(::abi::__cxa_guard_abort)* dtor;
+ ::abi::__guard* guard;
+ ~Sentry() { (* this->dtor) (this->guard); }
+ };
+
+ Sentry sentry = { ::abi::__cxa_guard_abort, this->m_guard };
48
+ forward<funcT>(func) (forward<paramsT>(params)...);
49
+ sentry.dtor = ::abi::__cxa_guard_release;
50
}
51
};
52
0 commit comments