* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <boost/thread/locks.hpp>
+#include <boost/thread/shared_mutex.hpp>
+
#ifdef ENABLE_DECODE
#include <libsigrokdecode/libsigrokdecode.h>
#endif
// Ensure we are not capturing before setting the device
stop_capture();
+ if (device_)
+ device_->close();
+
device_ = std::move(device);
- device_->create();
+ device_->open();
device_->session()->add_datafeed_callback([=]
(shared_ptr<sigrok::Device> device, shared_ptr<Packet> packet) {
data_feed_in(device, packet);
return data;
}
-boost::shared_mutex& Session::signals_mutex() const
-{
- return signals_mutex_;
-}
-
-const unordered_set< shared_ptr<view::Signal> >& Session::signals() const
+const unordered_set< shared_ptr<view::Signal> > Session::signals() const
{
+ shared_lock<shared_mutex> lock(signals_mutex_);
return signals_;
}