Github user dgkimura commented on a diff in the pull request: https://github.com/apache/geode-native/pull/103#discussion_r123862142 --- Diff: src/tests/cpp/fwklib/GsRandom.cpp --- @@ -18,60 +18,16 @@ #include "GsRandom.hpp" #include <cstring> -#include <mutex> -#include <util/concurrent/spinlock_mutex.hpp> namespace apache { namespace geode { namespace client { namespace testframework { -using util::concurrent::spinlock_mutex; - -GsRandom *GsRandom::singleton = 0; -MTRand GsRandom::gen; -int32_t GsRandom::seedUsed = -101; -spinlock_mutex GsRandom::lck; - -/** - * Creates a new random number generator using a single - * <code>int32_t</code> seed. - * - * @param seed the initial seed. - * @see java.util.Random#Random(int32_t) - */ -GsRandom *GsRandom::getInstance(int32_t seed) { - if (singleton == 0) { - setInstance(seed); - } else { - std::lock_guard<spinlock_mutex> guard(lck); - setSeed(seed); - } - return singleton; -} - -void GsRandom::setInstance(int32_t seed) { - std::lock_guard<spinlock_mutex> guard(lck); - if (singleton == 0) { - singleton = new GsRandom(); - if (seed != -1) { - singleton->gen.seed(seed); - } else { - singleton->gen.seed(); - } - seedUsed = seed; - } -} - -void GsRandom::setSeed(int32_t seed) { - if (seed != seedUsed) { - if (seed != -1) { - singleton->gen.seed(seed); - } else { - singleton->gen.seed(); - } - seedUsed = seed; - } +GsRandom &GsRandom::getInstance() { + // C++11 initializes statics threads safe --- End diff -- Nit, I don't this this comment adds much value.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---