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

Use cacheline_aligned in folly/experimental/settings/

Summary: [Folly] Use `cacheline_aligned` in `folly/experimental/settings/`.

Reviewed By: aary

Differential Revision: D19657676

fbshipit-source-id: cf31152b6525df2838b5c79f846e1698af17777e
parent d5d8571e
...@@ -21,12 +21,13 @@ ...@@ -21,12 +21,13 @@
#include <string> #include <string>
#include <typeindex> #include <typeindex>
#include <folly/CachelinePadded.h>
#include <folly/Conv.h> #include <folly/Conv.h>
#include <folly/Range.h> #include <folly/Range.h>
#include <folly/SharedMutex.h> #include <folly/SharedMutex.h>
#include <folly/ThreadLocal.h> #include <folly/ThreadLocal.h>
#include <folly/Utility.h>
#include <folly/experimental/settings/SettingsMetadata.h> #include <folly/experimental/settings/SettingsMetadata.h>
#include <folly/lang/Aligned.h>
namespace folly { namespace folly {
namespace settings { namespace settings {
...@@ -340,8 +341,9 @@ class SettingCore : public SettingCoreBase { ...@@ -340,8 +341,9 @@ class SettingCore : public SettingCoreBase {
defaultValue_(std::move(defaultValue)), defaultValue_(std::move(defaultValue)),
trivialStorage_(trivialStorage), trivialStorage_(trivialStorage),
localValue_([]() { localValue_([]() {
return new CachelinePadded< return new cacheline_aligned<
std::pair<Version, std::shared_ptr<Contents>>>(0, nullptr); std::pair<Version, std::shared_ptr<Contents>>>(
in_place, 0, nullptr);
}) { }) {
set(defaultValue_, "default"); set(defaultValue_, "default");
registerSetting(*this); registerSetting(*this);
...@@ -358,9 +360,9 @@ class SettingCore : public SettingCoreBase { ...@@ -358,9 +360,9 @@ class SettingCore : public SettingCoreBase {
/* Thread local versions start at 0, this will force a read on first access. /* Thread local versions start at 0, this will force a read on first access.
*/ */
CachelinePadded<std::atomic<Version>> settingVersion_{1}; cacheline_aligned<std::atomic<Version>> settingVersion_{in_place, 1};
ThreadLocal<CachelinePadded<std::pair<Version, std::shared_ptr<Contents>>>> ThreadLocal<cacheline_aligned<std::pair<Version, std::shared_ptr<Contents>>>>
localValue_; localValue_;
FOLLY_ALWAYS_INLINE const std::shared_ptr<Contents>& tlValue() const { FOLLY_ALWAYS_INLINE const std::shared_ptr<Contents>& tlValue() const {
......
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