/*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2011-present Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
swap(datum_, rhs);
}
+ /**
+ * Assign another datum and return the original value. Recommended
+ * because it keeps the mutex held only briefly.
+ */
+ T exchange(T&& rhs) {
+ swap(rhs);
+ return std::move(rhs);
+ }
+
/**
* Copies datum to a given target.
*/
std::is_const<SynchronizedType>::value,
typename SynchronizedType::ConstLockedPtr,
typename SynchronizedType::LockedPtr>::type;
-} // detail
+} // namespace detail
/**
* A helper base class for implementing LockedPtr.