From: Nicholas Ormrod Date: Mon, 3 Nov 2014 20:39:11 +0000 (-0800) Subject: Fix global statics X-Git-Tag: v0.22.0~199 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8cbc14de44a626f616d9000b359c800213f0ae85;p=folly.git 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 --- 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