ClientFactory::start() avoid custom ChannelProviderFactory

This commit is contained in:
Michael Davidsaver
2017-06-06 10:41:36 +02:00
parent de84fadeb7
commit 58b4a5ef64
3 changed files with 3 additions and 67 deletions

View File

@@ -18,76 +18,15 @@
using namespace epics::pvData;
using namespace epics::pvAccess;
class ChannelProviderFactoryImpl : public ChannelProviderFactory
{
private:
Mutex m_mutex;
ChannelProvider::shared_pointer m_shared_provider;
public:
POINTER_DEFINITIONS(ChannelProviderFactoryImpl);
virtual ~ChannelProviderFactoryImpl()
{
Lock guard(m_mutex);
if (m_shared_provider)
{
ChannelProvider::shared_pointer provider;
m_shared_provider.swap(provider);
// factroy cleans up also shared provider
provider->destroy();
}
}
virtual std::string getFactoryName()
{
return ClientContextImpl::PROVIDER_NAME;
}
virtual ChannelProvider::shared_pointer sharedInstance()
{
Lock guard(m_mutex);
if (!m_shared_provider)
{
epics::pvAccess::Configuration::shared_pointer def;
m_shared_provider = createClientProvider(def);
}
return m_shared_provider;
}
virtual ChannelProvider::shared_pointer newInstance(const std::tr1::shared_ptr<epics::pvAccess::Configuration>& conf)
{
Lock guard(m_mutex);
return createClientProvider(conf);
}
};
static Mutex cprovfact_mutex;
static ChannelProviderFactoryImpl::shared_pointer pva_factory;
void ClientFactory::start()
{
epicsSignalInstallSigAlarmIgnore();
epicsSignalInstallSigPipeIgnore();
Lock guard(cprovfact_mutex);
if (!pva_factory)
pva_factory.reset(new ChannelProviderFactoryImpl());
registerChannelProviderFactory(pva_factory);
getChannelProviderRegistry()->add("pva", createClientProvider, false);
}
void ClientFactory::stop()
{
Lock guard(cprovfact_mutex);
if (pva_factory)
{
unregisterChannelProviderFactory(pva_factory);
if(!pva_factory.unique()) {
LOG(logLevelWarn, "ClientFactory::stop() finds shared client context with %u remaining users",
(unsigned)pva_factory.use_count());
}
pva_factory.reset();
}
getChannelProviderRegistry()->remove("pva");
}

View File

@@ -47,7 +47,6 @@ using namespace epics::pvData;
namespace epics {
namespace pvAccess {
string ClientContextImpl::PROVIDER_NAME = "pva";
Status ChannelImpl::channelDestroyed(
Status::STATUSTYPE_WARNING, "channel destroyed");
Status ChannelImpl::channelDisconnected(
@@ -3302,7 +3301,7 @@ public:
virtual std::string getProviderName()
{
return PROVIDER_NAME;
return "pva";
}
virtual ChannelFind::shared_pointer channelFind(

View File

@@ -67,8 +67,6 @@ class ClientContextImpl : public Context
public:
POINTER_DEFINITIONS(ClientContextImpl);
static std::string PROVIDER_NAME;
/**
* Get context implementation version.
* @return version of the context implementation.