Add copy variant of SharedPV::fetch()
This commit is contained in:
+15
-1
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user