geode-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (GEODE-3645) Update API CacheFactory::create to return cache object
Date Wed, 29 Nov 2017 23:30:00 GMT

    [ 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<Properties> dsProps)
{
   pdxReadSerialized = false;
   this->dsProp = dsProps;
 }
- std::shared_ptr<Cache> CacheFactory::create() {
-   ACE_Guard<ACE_Recursive_Thread_Mutex> connectGuard(*g_disconnectLock);
 
-   LOGFINE("CacheFactory called DistributedSystem::connect");
-   auto cache = create(DEFAULT_CACHE_NAME, nullptr);
+Cache CacheFactory::create() {
+  ACE_Guard<ACE_Recursive_Thread_Mutex> 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<Cache>(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)

Mime
View raw message