Chromium Code Reviews| Index: src/IceUtils.h |
| diff --git a/src/IceUtils.h b/src/IceUtils.h |
| index f9b03bc75b1f65da97b6f1dc5494750b36af500f..8c127d3ebce58fb52a8991104c3ac22f5e203fea 100644 |
| --- a/src/IceUtils.h |
| +++ b/src/IceUtils.h |
| @@ -123,6 +123,25 @@ template <typename T> static bool isPositiveZero(T Val) { |
| return Val == 0 && !std::signbit(Val); |
| } |
| +/// An RAII class to ensure that a boolean flag is restored to its previous |
| +/// value upon function exist. |
|
Jim Stichnoth
2016/02/17 04:01:56
exit
|
| +/// |
| +/// Used in places like RandomizationPoolingPause and generating target helper |
| +/// calls. |
| +class BoolFlagSaver { |
| + BoolFlagSaver() = delete; |
| + BoolFlagSaver(const BoolFlagSaver &) = delete; |
| + BoolFlagSaver &operator=(const BoolFlagSaver &) = delete; |
| + |
| +public: |
| + BoolFlagSaver(bool &F, bool NewValue) : OldValue(F), Flag(F) { F = NewValue; } |
| + ~BoolFlagSaver() { Flag = OldValue; } |
| + |
| +private: |
| + const bool OldValue; |
| + bool &Flag; |
| +}; |
| + |
| } // end of namespace Utils |
| } // end of namespace Ice |