cleanup phase I

This commit is contained in:
Matej Sekoranja
2012-07-24 10:13:57 +02:00
parent 0f069c8875
commit 1b6587336e
18 changed files with 116 additions and 129 deletions
+10 -10
View File
@@ -4,7 +4,10 @@
* in file LICENSE that is included with this distribution.
*/
#include <pv/clientFactory.h>
#include <pv/clientContextImpl.h>
#include <pv/lock.h>
#include <pv/logger.h>
#include <epicsSignal.h>
@@ -12,23 +15,22 @@
using namespace epics::pvData;
using namespace epics::pvAccess;
Mutex ClientFactory::m_mutex;
ClientContextImpl::shared_pointer ClientFactory::m_context;
// TODO global static variable (de/initialization order not guaranteed)
static Mutex m_mutex;
static ClientContextImpl::shared_pointer m_context;
void ClientFactory::start()
{
epicsSignalInstallSigAlarmIgnore ();
epicsSignalInstallSigPipeIgnore ();
epicsSignalInstallSigAlarmIgnore();
epicsSignalInstallSigPipeIgnore();
Lock guard(m_mutex);
if (m_context.get()) return;
try {
m_context = createClientContextImpl();
m_context->initialize();
ChannelProvider::shared_pointer provider = m_context->getProvider();
registerChannelProvider(provider);
registerChannelProvider(m_context->getProvider());
} catch (std::exception &e) {
LOG(logLevelError, "Unhandled exception caught at %s:%d: %s", __FILE__, __LINE__, e.what());
} catch (...) {
@@ -39,11 +41,9 @@ void ClientFactory::start()
void ClientFactory::stop()
{
Lock guard(m_mutex);
if (!m_context.get()) return;
ChannelProvider::shared_pointer provider = m_context->getProvider();
unregisterChannelProvider(provider);
unregisterChannelProvider(m_context->getProvider());
m_context->dispose();
m_context.reset();