add reftrack to pvac

This commit is contained in:
Michael Davidsaver
2017-11-22 12:32:38 -06:00
parent 3f51c74ba1
commit 250826ffb9
6 changed files with 109 additions and 11 deletions

View File

@@ -8,10 +8,11 @@
#include <pv/pvData.h>
#include <pv/bitSet.h>
#include <pv/reftrack.h>
#define epicsExportSharedSymbols
#include "pv/logger.h"
#include "pva/client.h"
#include "clientpvt.h"
#include "pv/pvAccess.h"
#include "pv/configuration.h"
@@ -34,7 +35,10 @@ struct ClientChannel::Impl : public pva::ChannelRequester
typedef std::vector<ClientChannel::ConnectCallback*> listeners_t;
listeners_t listeners;
virtual ~Impl() {}
static size_t num_instances;
Impl() {REFTRACE_INCREMENT(num_instances);}
virtual ~Impl() {REFTRACE_DECREMENT(num_instances);}
virtual std::string getRequesterName() OVERRIDE FINAL { return "ClientChannel::Impl"; }
@@ -68,6 +72,8 @@ struct ClientChannel::Impl : public pva::ChannelRequester
}
};
size_t ClientChannel::Impl::num_instances;
ClientChannel::Options::Options()
:priority(0)
,address()
@@ -151,12 +157,29 @@ void ClientChannel::removeConnectListener(ConnectCallback* cb)
}
}
static
void register_reftrack()
{
static volatile int done;
if(done) return;
done = 1;
// done is an optimization, duplicate calls to registerRef* are no-ops
pvac::detail::registerRefTrack();
pvac::detail::registerRefTrackGet();
pvac::detail::registerRefTrackMonitor();
pvac::detail::registerRefTrackRPC();
}
std::tr1::shared_ptr<epics::pvAccess::Channel>
ClientChannel::getChannel()
{ return impl->channel; }
struct ClientProvider::Impl
{
static size_t num_instances;
Impl() {register_reftrack(); REFTRACE_INCREMENT(num_instances);}
~Impl() {REFTRACE_DECREMENT(num_instances);}
pva::ChannelProvider::shared_pointer provider;
epicsMutex mutex;
@@ -164,6 +187,8 @@ struct ClientProvider::Impl
channels_t channels;
};
size_t ClientProvider::Impl::num_instances;
ClientProvider::ClientProvider(const std::string& providerName,
const std::tr1::shared_ptr<epics::pvAccess::Configuration>& conf)
:impl(new Impl)
@@ -240,4 +265,14 @@ void ClientProvider::disconnect()
impl->channels.clear();
}
namespace detail {
void registerRefTrack()
{
epics::registerRefCounter("pvac::ClientChannel::Impl", &ClientChannel::Impl::num_instances);
epics::registerRefCounter("pvac::ClientProvider::Impl", &ClientProvider::Impl::num_instances);
}
}
} //namespace pvac

View File

@@ -10,10 +10,11 @@
#include <pv/current_function.h>
#include <pv/pvData.h>
#include <pv/bitSet.h>
#include <pv/reftrack.h>
#define epicsExportSharedSymbols
#include "pv/logger.h"
#include "pva/client.h"
#include "clientpvt.h"
#include "pv/pvAccess.h"
namespace pvd = epics::pvData;
@@ -35,9 +36,13 @@ struct GetPutter : public pva::ChannelPutRequester,
pvac::ClientChannel::PutCallback *putcb;
pvac::GetEvent event;
GetPutter(pvac::ClientChannel::GetCallback* cb) :started(false), getcb(cb), putcb(0) {}
GetPutter(pvac::ClientChannel::PutCallback* cb) :started(false), getcb(0), putcb(cb) {}
virtual ~GetPutter() {cancel();}
static size_t num_instances;
GetPutter(pvac::ClientChannel::GetCallback* cb) :started(false), getcb(cb), putcb(0)
{REFTRACE_INCREMENT(num_instances);}
GetPutter(pvac::ClientChannel::PutCallback* cb) :started(false), getcb(0), putcb(cb)
{REFTRACE_INCREMENT(num_instances);}
virtual ~GetPutter() {cancel();REFTRACE_DECREMENT(num_instances);}
void callEvent(Guard& G, pvac::GetEvent::event_t evt = pvac::GetEvent::Fail)
{
@@ -172,6 +177,8 @@ struct GetPutter : public pva::ChannelPutRequester,
}
};
size_t GetPutter::num_instances;
} //namespace
namespace pvac {
@@ -213,4 +220,13 @@ ClientChannel::put(PutCallback* cb,
}
namespace detail {
void registerRefTrackGet()
{
epics::registerRefCounter("pvac::GetPutter", &GetPutter::num_instances);
}
}
}//namespace pvac

View File

@@ -9,10 +9,11 @@
#include <pv/current_function.h>
#include <pv/pvData.h>
#include <pv/bitSet.h>
#include <pv/reftrack.h>
#define epicsExportSharedSymbols
#include "pv/logger.h"
#include "pva/client.h"
#include "clientpvt.h"
#include "pv/pvAccess.h"
namespace pvd = epics::pvData;
@@ -34,13 +35,15 @@ struct Monitor::Impl : public pva::MonitorRequester
pva::MonitorElement::Ref last;
static size_t num_instances;
Impl(ClientChannel::MonitorCallback* cb)
:started(false)
,done(false)
,seenEmpty(false)
,cb(cb)
{}
virtual ~Impl() {cancel();}
{REFTRACE_INCREMENT(num_instances);}
virtual ~Impl() {cancel();REFTRACE_DECREMENT(num_instances);}
void callEvent(Guard& G, MonitorEvent::event_t evt = MonitorEvent::Fail)
{
@@ -160,6 +163,8 @@ struct Monitor::Impl : public pva::MonitorRequester
}
};
size_t Monitor::Impl::num_instances;
Monitor::Monitor(const std::tr1::shared_ptr<Impl>& impl)
:impl(impl)
{}
@@ -224,4 +229,13 @@ ClientChannel::monitor(MonitorCallback *cb,
return Monitor(ret);
}
namespace detail {
void registerRefTrackMonitor()
{
epics::registerRefCounter("pvac::Monitor::Impl", &Monitor::Impl::num_instances);
}
}
}//namespace pvac

View File

@@ -8,6 +8,7 @@
#include <pv/pvData.h>
#include <pv/bitSet.h>
#include <pv/reftrack.h>
#define epicsExportSharedSymbols
#include "pv/logger.h"
@@ -34,9 +35,12 @@ struct RPCer : public pva::ChannelRPCRequester,
pvd::PVStructure::const_shared_pointer args;
static size_t num_instances;
RPCer(pvac::ClientChannel::GetCallback* cb,
const pvd::PVStructure::const_shared_pointer& args) :started(false), cb(cb), args(args) {}
virtual ~RPCer() {cancel();}
const pvd::PVStructure::const_shared_pointer& args) :started(false), cb(cb), args(args)
{REFTRACE_INCREMENT(num_instances);}
virtual ~RPCer() {cancel();REFTRACE_DECREMENT(num_instances);}
void callEvent(Guard& G, pvac::GetEvent::event_t evt = pvac::GetEvent::Fail)
{
@@ -136,6 +140,8 @@ struct RPCer : public pva::ChannelRPCRequester,
}
};
size_t RPCer::num_instances;
}//namespace
namespace pvac {
@@ -159,4 +165,13 @@ ClientChannel::rpc(GetCallback* cb,
return Operation(ret);
}
namespace detail {
void registerRefTrackRPC()
{
epics::registerRefCounter("pvac::RPCer", &RPCer::num_instances);
}
}
}//namespace pvac

15
src/client/clientpvt.h Normal file
View File

@@ -0,0 +1,15 @@
#ifndef CLIENTPVT_H
#define CLIENTPVT_H
#include <pva/client.h>
namespace pvac{namespace detail{
void registerRefTrack();
void registerRefTrackGet();
void registerRefTrackMonitor();
void registerRefTrackRPC();
}} // namespace pvac::detail
#endif // CLIENTPVT_H

View File

@@ -179,6 +179,7 @@ struct Timeout : public std::runtime_error
namespace detail {
class PutBuilder;
void registerRefTrack();
}
/** Represents a single channel
@@ -195,6 +196,7 @@ class epicsShareClass ClientChannel
struct Impl;
std::tr1::shared_ptr<Impl> impl;
friend class ClientProvider;
friend void detail::registerRefTrack();
ClientChannel(const std::tr1::shared_ptr<Impl>& i) :impl(i) {}
public:
@@ -395,6 +397,7 @@ class epicsShareClass ClientProvider
{
struct Impl;
std::tr1::shared_ptr<Impl> impl;
friend void detail::registerRefTrack();
public:
/** Use named provider.