make pvRequest weak_pointer for get, put, and monitor

This commit is contained in:
mrkraimer
2017-11-14 09:11:27 -05:00
parent 6cd7de069a
commit 784c6665a6
2 changed files with 18 additions and 6 deletions

View File

@@ -672,7 +672,7 @@ CAChannelGet::CAChannelGet(CAChannel::shared_pointer const & channel,
:
channel(channel),
channelGetRequester(channelGetRequester),
pvRequest(pvRequest)
pvRequestWeak(pvRequest)
{
if(DEBUG_LEVEL>0) {
cout << "CAChannelGet::CAChannelGet() " << channel->getChannelName() << endl;
@@ -693,6 +693,8 @@ void CAChannelGet::activate()
}
ChannelGetRequester::shared_pointer getRequester(channelGetRequester.lock());
if(!getRequester) return;
PVStructurePtr pvRequest(pvRequestWeak.lock());
if(!pvRequest) return;
if(pvStructure) throw std::runtime_error("CAChannelGet::activate() was called twice");
getType = getDBRType(pvRequest, channel->getNativeType());
pvStructure = createPVStructure(channel, getType, pvRequest);
@@ -712,6 +714,8 @@ void CAChannelGet::channelCreated(const Status& status,Channel::shared_pointer c
}
ChannelGetRequester::shared_pointer getRequester(channelGetRequester.lock());
if(!getRequester) return;
PVStructurePtr pvRequest(pvRequestWeak.lock());
if(!pvRequest) return;
chtype newType = getDBRType(pvRequest, channel->getNativeType());
if(newType!=getType) {
getType = getDBRType(pvRequest, channel->getNativeType());
@@ -1211,7 +1215,7 @@ CAChannelPut::CAChannelPut(CAChannel::shared_pointer const & channel,
:
channel(channel),
channelPutRequester(channelPutRequester),
pvRequest(pvRequest),
pvRequestWeak(pvRequest),
block(false)
{
if(DEBUG_LEVEL>0) {
@@ -1226,6 +1230,8 @@ void CAChannelPut::activate()
}
ChannelPutRequester::shared_pointer putRequester(channelPutRequester.lock());
if(!putRequester) return;
PVStructurePtr pvRequest(pvRequestWeak.lock());
if(!pvRequest) return;
if(pvStructure) throw std::runtime_error("CAChannelPut::activate() was called twice");
getType = getDBRType(pvRequest,channel->getNativeType());
pvStructure = createPVStructure(channel, getType, pvRequest);
@@ -1251,6 +1257,8 @@ void CAChannelPut::channelCreated(const Status& status,Channel::shared_pointer c
}
ChannelPutRequester::shared_pointer putRequester(channelPutRequester.lock());
if(!putRequester) return;
PVStructurePtr pvRequest(pvRequestWeak.lock());
if(!pvRequest) return;
chtype newType = getDBRType(pvRequest, channel->getNativeType());
if(newType!=getType) {
getType = getDBRType(pvRequest, channel->getNativeType());
@@ -1736,7 +1744,7 @@ CAChannelMonitor::CAChannelMonitor(
:
channel(channel),
monitorRequester(monitorRequester),
pvRequest(pvRequest),
pvRequestWeak(pvRequest),
isStarted(false)
{
if(DEBUG_LEVEL>0) {
@@ -1751,6 +1759,8 @@ void CAChannelMonitor::activate()
}
MonitorRequester::shared_pointer requester(monitorRequester.lock());
if(!requester) return;
PVStructurePtr pvRequest(pvRequestWeak.lock());
if(!pvRequest) return;
if(pvStructure) throw std::runtime_error("CAChannelMonitor::activate() was called twice");
getType = getDBRType(pvRequest, channel->getNativeType());
pvStructure = createPVStructure(channel, getType, pvRequest);
@@ -1781,6 +1791,8 @@ void CAChannelMonitor::channelCreated(const Status& status,Channel::shared_point
}
MonitorRequester::shared_pointer requester(monitorRequester.lock());
if(!requester) return;
PVStructurePtr pvRequest(pvRequestWeak.lock());
if(!pvRequest) return;
chtype newType = getDBRType(pvRequest, channel->getNativeType());
if(newType!=getType) {
getType = getDBRType(pvRequest, channel->getNativeType());

View File

@@ -180,7 +180,7 @@ private:
CAChannelPtr channel;
ChannelGetRequester::weak_pointer channelGetRequester;
epics::pvData::PVStructure::shared_pointer pvRequest;
epics::pvData::PVStructure::weak_pointer pvRequestWeak;
chtype getType;
epics::pvData::PVStructure::shared_pointer pvStructure;
@@ -248,7 +248,7 @@ private:
CAChannelPtr channel;
ChannelPutRequester::weak_pointer channelPutRequester;
epics::pvData::PVStructure::shared_pointer pvRequest;
epics::pvData::PVStructure::weak_pointer pvRequestWeak;
bool block;
chtype getType;
@@ -310,7 +310,7 @@ private:
CAChannelPtr channel;
MonitorRequester::weak_pointer monitorRequester;
epics::pvData::PVStructure::shared_pointer pvRequest;
epics::pvData::PVStructure::weak_pointer pvRequestWeak;
bool isStarted;
chtype getType;