This commit is contained in:
Michael Davidsaver
2015-12-08 17:40:37 -05:00
parent 810377aa34
commit 5e9ed37613
3 changed files with 5 additions and 3 deletions

View File

@ -23,6 +23,7 @@ struct MonitorCacheEntry : public epics::pvData::MonitorRequester
{
POINTER_DEFINITIONS(MonitorCacheEntry);
static size_t num_instances;
weak_pointer weakref;
ChannelCacheEntry * const chan;

View File

@ -163,7 +163,8 @@ GWChannel::createMonitor(
ment = entry->mon_entries.find(ser);
if(!ment) {
ment.reset(new MonitorCacheEntry(entry.get()));
entry->mon_entries[ser] = ment;
entry->mon_entries[ser] = ment; // ref. wrapped
ment->weakref = ment;
// Create upstream monitor
// This would create a strong ref. loop between ent and ent->mon.

View File

@ -56,7 +56,7 @@ MonitorCacheEntry::monitorConnect(pvd::Status const & status,
if(!startresult.isSuccess())
std::cout<<"upstream monitor start() fails\n";
//TODO: hold a shared_ptr to 'this' incase all MonitorUsers are destroy()d in a callback
shared_pointer self(weakref); // keeps us alive all MonitorUsers are destroy()ed
for(interested_t::vector_type::const_iterator it = tonotify.begin(),
end = tonotify.end(); it!=end; ++it)
@ -92,7 +92,7 @@ MonitorCacheEntry::monitorEvent(pvd::MonitorPtr const & monitor)
pvd::MonitorElementPtr update;
//TODO: hold a shared_ptr to 'this' incase all MonitorUsers are destroy()d in a callback
shared_pointer self(weakref); // keeps us alive all MonitorUsers are destroy()ed
while((update=monitor->poll()))
{