From 8644f4230d3cba12449eb99e87eefc8a178b60d4 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Sun, 15 Jul 2018 19:22:43 -0700 Subject: [PATCH] client: simplify monitor type handling I think the original logic is correct, but I'm not sure. Cleverness to avoiding storing a Structure pointer is a premature optimization anyway. --- src/client/monitor.cpp | 4 +++- src/client/pv/monitor.h | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/client/monitor.cpp b/src/client/monitor.cpp index 9849ac2..1514955 100644 --- a/src/client/monitor.cpp +++ b/src/client/monitor.cpp @@ -155,6 +155,7 @@ void MonitorFIFO::open(const pvd::StructureConstPtr& type) opened = true; needConnected = true; + this->type = type; if(conf.ignoreRequestMask) { selectMask.clear(); @@ -187,6 +188,7 @@ void MonitorFIFO::close() opened = false; needClosed = true; selectMask.clear(); + type.reset(); } void MonitorFIFO::finish() @@ -227,7 +229,7 @@ bool MonitorFIFO::tryPost(const pvData::PVStructure& value, empty.pop_front(); } else if(force) { // allocate an extra element - elem.reset(new MonitorElement(pvd::getPVDataCreate()->createPVStructure(inuse.back()->pvStructurePtr->getStructure()))); + elem.reset(new MonitorElement(pvd::getPVDataCreate()->createPVStructure(type))); } if(elem) { diff --git a/src/client/pv/monitor.h b/src/client/pv/monitor.h index 5252d82..14df362 100644 --- a/src/client/pv/monitor.h +++ b/src/client/pv/monitor.h @@ -388,6 +388,8 @@ private: size_t freeHighLevel; epicsInt32 flowCount; + epics::pvData::StructureConstPtr type; // NULL if not opened + typedef std::list buffer_t; // we allocate one extra buffer element to hold data when post() // while all elements poll()'d. So there will always be one