ClientFactory::start() avoid custom ChannelProviderFactory
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user