Add copy variant of SharedPV::fetch()

This commit is contained in:
Michael Davidsaver
2020-07-26 20:46:12 -07:00
parent 24f3478c98
commit e31e6cda36
2 changed files with 19 additions and 3 deletions
+15 -1
View File
@@ -407,7 +407,7 @@ void SharedPV::post(const Value& val)
}
}
void SharedPV::fetch(Value& val)
void SharedPV::fetch(Value& val) const
{
if(!impl)
throw std::logic_error("Empty SharedPV");
@@ -421,6 +421,20 @@ void SharedPV::fetch(Value& val)
}
}
Value SharedPV::fetch() const
{
if(!impl)
throw std::logic_error("Empty SharedPV");
Guard G(impl->lock);
if(impl->current) {
return impl->current.clone();
} else {
throw std::logic_error("open() first");
}
}
struct StaticSource::Impl : public Source
{
RWLock lock;