From 8cbc14de44a626f616d9000b359c800213f0ae85 Mon Sep 17 00:00:00 2001 From: Nicholas Ormrod Date: Mon, 3 Nov 2014 12:39:11 -0800 Subject: [PATCH] Fix global statics Summary: Statics in headers are bad. Test Plan: run unit tests Reviewed By: robbert@fb.com Subscribers: trunkagent, sdwilsh, njormrod, folly-diffs@ FB internal diff: D1646906 Tasks: 5486739 Signature: t1:1646906:1415042805:dc4d1cec54e9320f1e609808a73622c731a4cdc9 --- folly/DynamicConverter.h | 2 +- folly/test/SynchronizedTestLib-inl.h | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/folly/DynamicConverter.h b/folly/DynamicConverter.h index 198c0ae1..2f56784b 100644 --- a/folly/DynamicConverter.h +++ b/folly/DynamicConverter.h @@ -168,7 +168,7 @@ public: // conversion factory template -static inline std::move_iterator> +inline std::move_iterator> conversionIterator(const It& it) { return std::make_move_iterator(Transformer(it)); } diff --git a/folly/test/SynchronizedTestLib-inl.h b/folly/test/SynchronizedTestLib-inl.h index aa2e3dcb..1253d32f 100644 --- a/folly/test/SynchronizedTestLib-inl.h +++ b/folly/test/SynchronizedTestLib-inl.h @@ -30,14 +30,16 @@ #include -static const auto seed = folly::randomNumberSeed(); -typedef std::mt19937 RandomT; -static RandomT rng(seed); +inline std::mt19937& getRNG() { + static const auto seed = folly::randomNumberSeed(); + static std::mt19937 rng(seed); + return rng; +} template Integral2 random(Integral1 low, Integral2 up) { std::uniform_int_distribution<> range(low, up); - return range(rng); + return range(getRNG()); } template -- 2.34.1