add StaticSource::close()

This commit is contained in:
Michael Davidsaver
2020-07-23 13:23:38 -07:00
parent ce80e8897b
commit e8649ecdd2
2 changed files with 17 additions and 0 deletions
+3
View File
@@ -99,6 +99,9 @@ struct PVXS_API StaticSource
//! Fetch the Source interface, which may be used with Server::addSource()
std::shared_ptr<Source> source() const;
//! call SharedPV::close() on all PVs
void close();
//! Add a new name through which a SharedPV may be addressed.
StaticSource& add(const std::string& name, const SharedPV& pv);
//! Remove a single name
+14
View File
@@ -506,6 +506,20 @@ std::shared_ptr<Source> StaticSource::source() const
return impl;
}
void StaticSource::close()
{
if(!impl)
throw std::logic_error("Empty StaticSource");
{
auto G(impl->lock.lockReader());
for(auto& pair : impl->pvs) {
pair.second.close();
}
}
}
StaticSource& StaticSource::add(const std::string& name, const SharedPV &pv)
{
if(!impl)