Commit 0731f1ad authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Opportunity to use exchange in ScopeGuardImpl

Summary: [Folly] Opportunity to use `exchange` in `ScopeGuardImpl`.

Reviewed By: Orvid

Differential Revision: D10119838

fbshipit-source-id: 64a00f4f60d913f8af248ebf891f730d2c69fec8
parent 32b70f14
......@@ -25,6 +25,7 @@
#include <folly/Portability.h>
#include <folly/Preprocessor.h>
#include <folly/Utility.h>
#include <folly/lang/UncaughtExceptions.h>
namespace folly {
......@@ -88,8 +89,7 @@ class ScopeGuardImpl : public ScopeGuardImplBase {
// on the value of other.dismissed_. The following lines only execute
// if the move/copy succeeded, in which case *this assumes ownership of
// the cleanup action and dismisses other.
dismissed_ = other.dismissed_;
other.dismissed_ = true;
dismissed_ = exchange(other.dismissed_, true);
}
~ScopeGuardImpl() noexcept(InvokeNoexcept) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment