changes suggested by Michael Davidsaver

This commit is contained in:
mrkraimer
2017-06-04 14:52:53 -04:00
parent acd9ab42cc
commit b37baf8ecb
7 changed files with 15 additions and 47 deletions

View File

@@ -48,14 +48,10 @@ All these changes are in the github repositories belonging to mrkraimer.
ChannelProviderRegistry
-----------------------
The following new methods are added to ChannelProviderRegistry:
The following new method is added to ChannelProviderRegistry:
static ChannelProviderRegistry::shared_pointer getChannelProviderRegistry();
void registerChannelProviderFactory(
ChannelProviderFactory::shared_pointer const & channelProviderFactory);
void unregisterChannelProviderFactory(
ChannelProviderFactory::shared_pointer const & channelProviderFactory);
**getChannelProviderRegistry** creates the single instance of **ChannelProviderRegistry**
the first time it is called and always returns a shared pointer to the single

View File

@@ -233,8 +233,8 @@ public:
static Mutex startStopMutex;
ChannelProviderRegistry::shared_pointer CAClientFactory::channelRegistry = ChannelProviderRegistry::shared_pointer();
CAChannelProviderFactoryPtr CAClientFactory::channelProvider = CAChannelProviderFactory::shared_pointer();
ChannelProviderRegistry::shared_pointer CAClientFactory::channelRegistry;
ChannelProviderFactory::shared_pointer CAClientFactory::channelProvider;
int CAClientFactory::numStart = 0;
@@ -249,7 +249,7 @@ std::cout << "CAClientFactory::start() numStart " << numStart << std::endl;
channelProvider.reset(new CAChannelProviderFactory());
channelRegistry = ChannelProviderRegistry::getChannelProviderRegistry();
std::cout << "channelRegistry::use_count " << channelRegistry.use_count() << std::endl;
channelRegistry->registerChannelProviderFactory(channelProvider);
channelRegistry->add(channelProvider);
}
void CAClientFactory::stop()
@@ -262,7 +262,7 @@ std::cout << "channelRegistry::use_count " << channelRegistry.use_count() << std
if(numStart>=1) return;
if (channelProvider)
{
channelRegistry->unregisterChannelProviderFactory(channelProvider);
channelRegistry->remove(CAChannelProvider::PROVIDER_NAME);
if(!channelProvider.unique()) {
LOG(logLevelWarn, "ClientFactory::stop() finds shared client context with %u remaining users",
(unsigned)channelProvider.use_count());

View File

@@ -82,13 +82,11 @@ private:
bool destroyed;
};
class CAChannelProviderFactory;
typedef std::tr1::shared_ptr<CAChannelProviderFactory> CAChannelProviderFactoryPtr;
class epicsShareClass CAClientFactory {
private:
static epics::pvAccess::ChannelProviderRegistry::shared_pointer channelRegistry;
static CAChannelProviderFactoryPtr channelProvider;
static epics::pvAccess::ChannelProviderFactory::shared_pointer channelProvider;
static int numStart;
public:
static void start();

View File

@@ -1009,19 +1009,6 @@ public:
* @return The interface for ChannelProviderRegistry
*/
static ChannelProviderRegistry::shared_pointer getChannelProviderRegistry();
/**
* Register a ChannelProviderFactory.
* @param channelProviderFactory The ChannelProviderFactory.
*/
void registerChannelProviderFactory(
ChannelProviderFactory::shared_pointer const & channelProviderFactory);
/**
* Unregister a ChannelProviderFactory.
* @param channelProviderFactory The ChannelProviderFactory.
*/
void unregisterChannelProviderFactory(
ChannelProviderFactory::shared_pointer const & channelProviderFactory);
/**
* Get a shared instance of the provider with the specified name.
* @param providerName The name of the provider.

View File

@@ -43,19 +43,6 @@ ChannelProviderRegistry::shared_pointer ChannelProviderRegistry::getChannelProvi
return global_reg;
}
void ChannelProviderRegistry::registerChannelProviderFactory(
ChannelProviderFactory::shared_pointer const & channelProviderFactory)
{
assert(channelProviderFactory);
add(channelProviderFactory);
}
void ChannelProviderRegistry::unregisterChannelProviderFactory(
ChannelProviderFactory::shared_pointer const & channelProviderFactory)
{
assert(channelProviderFactory);
remove(channelProviderFactory->getFactoryName());
}
ChannelProvider::shared_pointer ChannelProviderRegistry::getProvider(std::string const & providerName) {
ChannelProviderFactory::shared_pointer fact(getFactory(providerName));
@@ -132,12 +119,12 @@ std::cerr << "getChannelProviderRegistry should not be used\n";
void registerChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) {
std::cerr << "registerChannelProviderFactory should not be used\n";
getChannelProviderRegistry()->registerChannelProviderFactory(channelProviderFactory);
getChannelProviderRegistry()->add(channelProviderFactory);
}
void unregisterChannelProviderFactory(ChannelProviderFactory::shared_pointer const & channelProviderFactory) {
std::cerr << "unregisterChannelProviderFactory should not be used\n";
getChannelProviderRegistry()->unregisterChannelProviderFactory(channelProviderFactory);
getChannelProviderRegistry()->remove(channelProviderFactory->getFactoryName());
}
epicsShareFunc void unregisterAllChannelProviderFactory()

View File

@@ -66,8 +66,8 @@ public:
static Mutex startStopMutex;
ChannelProviderRegistryPtr ClientFactory::channelRegistry = ChannelProviderRegistryPtr();
ChannelProviderFactoryImplPtr ClientFactory::channelProvider = ChannelProviderFactoryImplPtr();
ChannelProviderRegistryPtr ClientFactory::channelRegistry;
ChannelProviderFactoryPtr ClientFactory::channelProvider;
int ClientFactory::numStart = 0;
void ClientFactory::start()
@@ -81,7 +81,7 @@ std::cout << "ClientFactory::start() numStart " << numStart << std::endl;
channelProvider.reset(new ChannelProviderFactoryImpl());
channelRegistry = ChannelProviderRegistry::getChannelProviderRegistry();
std::cout << "channelRegistry::use_count " << channelRegistry.use_count() << std::endl;
channelRegistry->registerChannelProviderFactory(channelProvider);
channelRegistry->add(channelProvider);
}
void ClientFactory::stop()
@@ -95,7 +95,7 @@ std::cout << "channelRegistry::use_count " << channelRegistry.use_count() << std
if (channelProvider)
{
channelRegistry->unregisterChannelProviderFactory(channelProvider);
channelRegistry->remove(ClientContextImpl::PROVIDER_NAME);
if(!channelProvider.unique()) {
LOG(logLevelWarn, "ClientFactory::stop() finds shared client context with %u remaining users",
(unsigned)channelProvider.use_count());

View File

@@ -17,13 +17,13 @@ namespace pvAccess {
class ChannelProviderRegistry;
typedef std::tr1::shared_ptr<ChannelProviderRegistry> ChannelProviderRegistryPtr;
class ChannelProviderFactoryImpl;
typedef std::tr1::shared_ptr<ChannelProviderFactoryImpl> ChannelProviderFactoryImplPtr;
class ChannelProviderFactory;
typedef std::tr1::shared_ptr<ChannelProviderFactory> ChannelProviderFactoryPtr;
class epicsShareClass ClientFactory {
private:
static ChannelProviderRegistryPtr channelRegistry;
static ChannelProviderFactoryImplPtr channelProvider;
static ChannelProviderFactoryPtr channelProvider;
static int numStart;
public:
static void start();