From e8649ecdd2e893c9d99eccac94fba0c7a90d9ca5 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 23 Jul 2020 13:23:38 -0700 Subject: [PATCH] add StaticSource::close() --- src/pvxs/sharedpv.h | 3 +++ src/sharedpv.cpp | 14 ++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/pvxs/sharedpv.h b/src/pvxs/sharedpv.h index d1d24f1..95e69a7 100644 --- a/src/pvxs/sharedpv.h +++ b/src/pvxs/sharedpv.h @@ -99,6 +99,9 @@ struct PVXS_API StaticSource //! Fetch the Source interface, which may be used with Server::addSource() std::shared_ptr 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 diff --git a/src/sharedpv.cpp b/src/sharedpv.cpp index 8ee79aa..52fbd76 100644 --- a/src/sharedpv.cpp +++ b/src/sharedpv.cpp @@ -506,6 +506,20 @@ std::shared_ptr 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)