You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geode.apache.org by pivotal-jbarrett <gi...@git.apache.org> on 2017/06/23 23:00:54 UTC
[GitHub] geode-native pull request #103: GEODE-2525: Removes MersenneTwister sources.
GitHub user pivotal-jbarrett opened a pull request:
https://github.com/apache/geode-native/pull/103
GEODE-2525: Removes MersenneTwister sources.
Can I get a quick review before I merge.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/pivotal-jbarrett/geode-native feature/GEODE-2525-cp
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/geode-native/pull/103.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #103
----
commit 46a141ca58bdaba3e162dc3e0848a725183169d4
Author: Jacob Barrett <jb...@pivotal.io>
Date: 2017-03-07T16:35:33Z
GEODE-2525: Removes MersenneTwister sources.
----
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] geode-native pull request #103: GEODE-2525: Removes MersenneTwister sources.
Posted by pivotal-jbarrett <gi...@git.apache.org>.
Github user pivotal-jbarrett commented on a diff in the pull request:
https://github.com/apache/geode-native/pull/103#discussion_r123866557
--- 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 --
Yeah probably not. I can kill it.
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] geode-native pull request #103: GEODE-2525: Removes MersenneTwister sources.
Posted by dgkimura <gi...@git.apache.org>.
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---
[GitHub] geode-native pull request #103: GEODE-2525: Removes MersenneTwister sources.
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/geode-native/pull/103
---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---