]> sigrok.org Git - pulseview.git/blobdiff - pv/sigsession.h
SigSession: Converted _signals_mutex into a boost::shared_mutex
[pulseview.git] / pv / sigsession.h
index a624d1d216aaf6e0e280cfde4bf514a61ee118c4..62994256c80b2008c97158f213a13690ee5af41e 100644 (file)
@@ -29,6 +29,8 @@
 #include <thread>
 #include <vector>
 
+#include <boost/thread.hpp>
+
 #include <QObject>
 #include <QString>
 
@@ -79,7 +81,13 @@ public:
 
        ~SigSession();
 
-       std::shared_ptr<sigrok::Device> get_device() const;
+       DeviceManager& device_manager();
+
+       const DeviceManager& device_manager() const;
+
+       const std::shared_ptr<sigrok::Session>& session() const;
+
+       std::shared_ptr<sigrok::Device> device() const;
 
        /**
         * Sets device instance that will be used in the next capture session.
@@ -98,8 +106,9 @@ public:
 
        std::set< std::shared_ptr<data::SignalData> > get_data() const;
 
-       std::vector< std::shared_ptr<view::Signal> >
-               get_signals() const;
+       boost::shared_mutex& signals_mutex() const;
+
+       const std::vector< std::shared_ptr<view::Signal> >& signals() const;
 
 #ifdef ENABLE_DECODE
        bool add_decoder(srd_decoder *const dec);
@@ -140,6 +149,7 @@ private:
 
 private:
        DeviceManager &_device_manager;
+       std::shared_ptr<sigrok::Session> _session;
 
        /**
         * The device instance that will be used in the next capture session.
@@ -151,7 +161,7 @@ private:
        mutable std::mutex _sampling_mutex;
        capture_state _capture_state;
 
-       mutable std::mutex _signals_mutex;
+       mutable boost::shared_mutex _signals_mutex;
        std::vector< std::shared_ptr<view::Signal> > _signals;
 
        mutable std::mutex _data_mutex;
@@ -172,14 +182,6 @@ Q_SIGNALS:
        void data_received();
 
        void frame_ended();
-
-public:
-       // Hack. The libsigrok API now allows for multiple sessions. However,
-       // sigrok::Session calls are scattered around the PV architecture and a
-       // single SigSession object is being used across multiple sequential
-       // sessions. This is a mess. For now just keep a single sigrok::Session
-       // pointer here which we can use for all those scattered calls.
-       static std::shared_ptr<sigrok::Session> _sr_session;
 };
 
 } // namespace pv