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 C71AB200D71 for ; Thu, 30 Nov 2017 00:30:05 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id C592E160C04; Wed, 29 Nov 2017 23:30:05 +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 2201E160C16 for ; Thu, 30 Nov 2017 00:30:04 +0100 (CET) Received: (qmail 90517 invoked by uid 500); 29 Nov 2017 23:30:04 -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 90506 invoked by uid 99); 29 Nov 2017 23:30:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 29 Nov 2017 23:30:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id C266C180942 for ; Wed, 29 Nov 2017 23:30:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -99.202 X-Spam-Level: X-Spam-Status: No, score=-99.202 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, RP_MATCHES_RCVD=-0.001, SPF_PASS=-0.001, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id Q2tEtvX6g37q for ; Wed, 29 Nov 2017 23:30: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 EC8C25F1A0 for ; Wed, 29 Nov 2017 23:30: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 60104E0161 for ; Wed, 29 Nov 2017 23:30:01 +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 220BC21058 for ; Wed, 29 Nov 2017 23:30:00 +0000 (UTC) Date: Wed, 29 Nov 2017 23:30:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: issues@geode.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (GEODE-3645) Update API CacheFactory::create to return cache object MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 29 Nov 2017 23:30:06 -0000 [ https://issues.apache.org/jira/browse/GEODE-3645?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16271774#comment-16271774 ] ASF GitHub Bot commented on GEODE-3645: --------------------------------------- dgkimura commented on a change in pull request #159: GEODE-3645: Update CacheFactory::create to return Cache by value URL: https://github.com/apache/geode-native/pull/159#discussion_r153946323 ########## File path: cppcache/src/CacheFactory.cpp ########## @@ -87,76 +73,83 @@ CacheFactory::CacheFactory(const std::shared_ptr dsProps) { pdxReadSerialized = false; this->dsProp = dsProps; } - std::shared_ptr CacheFactory::create() { - ACE_Guard connectGuard(*g_disconnectLock); - LOGFINE("CacheFactory called DistributedSystem::connect"); - auto cache = create(DEFAULT_CACHE_NAME, nullptr); +Cache CacheFactory::create() { + ACE_Guard connectGuard(*g_disconnectLock); - auto& cacheImpl = cache->m_cacheImpl; - const auto& serializationRegistry = cacheImpl->getSerializationRegistry(); - const auto& pdxTypeRegistry = cacheImpl->getPdxTypeRegistry(); - const auto& memberListForVersionStamp = - std::ref(*(cacheImpl->getMemberListForVersionStamp())); + LOGFINE("CacheFactory called DistributedSystem::connect"); + auto cache = create(DEFAULT_CACHE_NAME, nullptr); - serializationRegistry->addType2( - std::bind(TXCommitMessage::create, memberListForVersionStamp)); + auto& cacheImpl = cache.m_cacheImpl; + const auto& serializationRegistry = cacheImpl->getSerializationRegistry(); Review comment: That example helped. Looks like value of `const auto&` is keeping local scoped variable const. I haven't really formulated an opinion on this yet and right now I can go either way. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: users@infra.apache.org > Update API CacheFactory::create to return cache object > ------------------------------------------------------ > > Key: GEODE-3645 > URL: https://issues.apache.org/jira/browse/GEODE-3645 > Project: Geode > Issue Type: New Feature > Components: native client > Reporter: David Kimura > > As an application developer I want to control the stack vs heap allocation of my cache object. If we change CacheFactory::create to return a cache object then the application user can pick an allocation scheme. This also allows application developers to bypass smart pointer complexity until the developer deems them necessary. > Example: > {noformat} > auto cache = CacheFactory::createFactory().create(); > auto cacheptr = std::make_shared(CacheFactory::createFactory().create()); > {noformat} > Difficulty of implementation is due to Cache/CacheImpl circular dependency. Here are a few examples of various approaches to consider: > https://gist.github.com/pivotal-jbarrett/52ba9ec5de0b494368d1c5282ef188ef > https://gist.github.com/pivotal-jbarrett/c48ffff3f7f41b187f0ed8c80108aa6a > Here are the related email threads of interest: > http://markmail.org/message/in5e337npq5euslh > http://markmail.org/message/lp2rx2rtyblg72fv -- This message was sent by Atlassian JIRA (v6.4.14#64029)