Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id EC200200CD4 for ; Sat, 24 Jun 2017 01:46:04 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id EAFF0160BE5; Fri, 23 Jun 2017 23:46:04 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 477E7160BF2 for ; Sat, 24 Jun 2017 01:46:04 +0200 (CEST) Received: (qmail 17305 invoked by uid 500); 23 Jun 2017 23:46:03 -0000 Mailing-List: contact issues-help@geode.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@geode.apache.org Delivered-To: mailing list issues@geode.apache.org Received: (qmail 17289 invoked by uid 99); 23 Jun 2017 23:46:03 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 23 Jun 2017 23:46:03 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id E2C37CF83E for ; Fri, 23 Jun 2017 23:46:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -100.011 X-Spam-Level: X-Spam-Status: No, score=-100.011 tagged_above=-999 required=6.31 tests=[SPF_PASS=-0.001, T_RP_MATCHES_RCVD=-0.01, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id ArQEo3UzX8k8 for ; Fri, 23 Jun 2017 23:46:02 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 6E87F5FD91 for ; Fri, 23 Jun 2017 23:46:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id D7D4AE0DA1 for ; Fri, 23 Jun 2017 23:46:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 29AC9240A5 for ; Fri, 23 Jun 2017 23:46:00 +0000 (UTC) Date: Fri, 23 Jun 2017 23:46:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@geode.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GEODE-2525) Replace random number implementation with C++11 standards MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Fri, 23 Jun 2017 23:46:05 -0000 [ https://issues.apache.org/jira/browse/GEODE-2525?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16061647#comment-16061647 ] ASF GitHub Bot commented on GEODE-2525: --------------------------------------- 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 -#include -#include 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 - * int32_t 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 guard(lck); - setSeed(seed); - } - return singleton; -} - -void GsRandom::setInstance(int32_t seed) { - std::lock_guard 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. > Replace random number implementation with C++11 standards > --------------------------------------------------------- > > Key: GEODE-2525 > URL: https://issues.apache.org/jira/browse/GEODE-2525 > Project: Geode > Issue Type: Task > Components: native client > Reporter: Jacob S. Barrett > Assignee: Jacob S. Barrett > > Remove Mersenne Twister implementation from source. Use C++11 random where appropriate. Refactor random usage to be thread safe as applicable. GsRansom uses spin lock to protect. Consider thread local random. -- This message was sent by Atlassian JIRA (v6.4.14#64029)