Add copy variant of SharedPV::fetch()
This commit is contained in:
+4
-2
@@ -72,8 +72,10 @@ struct PVXS_API SharedPV
|
||||
|
||||
//! Update the internal data value, and dispatch subscription updates to any clients.
|
||||
void post(const Value& val);
|
||||
//! query the internal data value.
|
||||
void fetch(Value& val);
|
||||
//! query the internal data value and update the provided Value.
|
||||
void fetch(Value& val) const;
|
||||
//! Return a (shallow) copy of the internal data value
|
||||
Value fetch() const;
|
||||
|
||||
struct Impl;
|
||||
private:
|
||||
|
||||
+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