]> sigrok.org Git - pulseview.git/commitdiff
Session: Removed signals_mutex(), and made signals() return a copy not a reference
authorJoel Holdsworth <redacted>
Sat, 22 Aug 2015 16:01:49 +0000 (10:01 -0600)
committerJoel Holdsworth <redacted>
Sun, 18 Oct 2015 21:32:29 +0000 (15:32 -0600)
pv/popups/channels.cpp
pv/session.cpp
pv/session.hpp
pv/storesession.cpp
pv/view/decodetrace.cpp
pv/view/rowitemiterator.hpp
pv/view/view.cpp

index 3cf2ff40ae2591333519367bb03b9cc6e70a3a95..ea5f5fbed8d10c91c61dc1d39cca1826030ab81b 100644 (file)
@@ -75,8 +75,7 @@ Channels::Channels(Session &session, QWidget *parent) :
        // Collect a set of signals
        map<shared_ptr<Channel>, shared_ptr<Signal> > signal_map;
 
-       shared_lock<shared_mutex> lock(session_.signals_mutex());
-       const unordered_set< shared_ptr<Signal> > &sigs(session_.signals());
+       const unordered_set< shared_ptr<Signal> > sigs(session_.signals());
 
        for (const shared_ptr<Signal> &sig : sigs)
                signal_map[sig->channel()] = sig;
index 0b503e056a83f6bc471aaf3c14612e3682cbbb97..45c4e98790843dc67bef475a6be0594b265017b4 100644 (file)
@@ -217,13 +217,9 @@ set< shared_ptr<data::SignalData> > Session::get_data() const
        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_;
 }
 
index 689b3f832dcf40752f789fb9f3bc59db2e64bc98..0828edbbf912cb3d8e09e18db94102df872ca1e1 100644 (file)
@@ -114,9 +114,7 @@ public:
 
        std::set< std::shared_ptr<data::SignalData> > get_data() const;
 
-       boost::shared_mutex& signals_mutex() const;
-
-       const std::unordered_set< std::shared_ptr<view::Signal> >&
+       const std::unordered_set< std::shared_ptr<view::Signal> >
                signals() const;
 
 #ifdef ENABLE_DECODE
index 35582b43a411d92ced14ba45e3b7a124b320d3a0..da2f963be9eb99609786800e9c45ad3ece294040 100644 (file)
@@ -95,8 +95,7 @@ const QString& StoreSession::error() const
 
 bool StoreSession::start()
 {
-       shared_lock<shared_mutex> lock(session_.signals_mutex());
-       const unordered_set< shared_ptr<view::Signal> > &sigs(session_.signals());
+       const unordered_set< shared_ptr<view::Signal> > sigs(session_.signals());
 
        // Add enabled channels to the data set
        set< shared_ptr<data::SignalData> > data_set;
index f44d8f94b75ea0991fb6791dd5dc51a975f49a7a..38cbecb85337500cf3c20ca5963aa769918bb728 100644 (file)
@@ -710,8 +710,7 @@ QComboBox* DecodeTrace::create_channel_selector(
 {
        assert(dec);
 
-       shared_lock<shared_mutex> lock(session_.signals_mutex());
-       const auto &sigs(session_.signals());
+       const auto sigs(session_.signals());
 
        vector< shared_ptr<Signal> > sig_list(sigs.begin(), sigs.end());
        std::sort(sig_list.begin(), sig_list.end(),
@@ -749,8 +748,7 @@ void DecodeTrace::commit_decoder_channels(shared_ptr<data::decode::Decoder> &dec
 
        map<const srd_channel*, shared_ptr<LogicSignal> > channel_map;
 
-       shared_lock<shared_mutex> lock(session_.signals_mutex());
-       const unordered_set< shared_ptr<Signal> > &sigs(session_.signals());
+       const unordered_set< shared_ptr<Signal> > sigs(session_.signals());
 
        for (const ChannelSelector &s : channel_selectors_)
        {
index 10de80a03060bde9323eb4e549ff1aede26b4a49..d75b834d9f4a28179beff69a2776021934cd71a8 100644 (file)
 #include <type_traits>
 #include <vector>
 
-#ifdef _WIN32
-// Windows: Avoid namespace pollution by thread.hpp (which includes windows.h).
-#define NOGDI
-#define NORESOURCE
-#endif
-#include <boost/thread/locks.hpp>
-#include <boost/thread/shared_mutex.hpp>
-
 #include <pv/session.hpp>
 
 namespace pv {
@@ -57,12 +49,10 @@ public:
 
 public:
        RowItemIterator(Owner *owner) :
-               owner_(owner),
-               lock_(owner->session().signals_mutex()) {}
+               owner_(owner) {}
 
        RowItemIterator(Owner *owner, child_iterator iter) :
-               owner_(owner),
-               lock_(owner->session().signals_mutex()) {
+               owner_(owner) {
                assert(owner);
                if (iter != owner->child_items().end())
                        iter_stack_.push(iter);
@@ -70,7 +60,6 @@ public:
 
        RowItemIterator(const RowItemIterator<Owner, Item> &o) :
                owner_(o.owner_),
-               lock_(*o.lock_.mutex()),
                iter_stack_(o.iter_stack_) {}
 
        reference operator*() const {
@@ -133,7 +122,6 @@ public:
 
 private:
        Owner *owner_;
-       boost::shared_lock<boost::shared_mutex> lock_;
        std::stack<child_iterator> iter_stack_;
 };
 
index 6d366e7311881b8736b80daf2709becd72d7c88b..d21b75ab3f432422977b77d1d79056cdec1dc547 100644 (file)
@@ -396,8 +396,7 @@ void View::set_scale_offset(double scale, const Timestamp& offset)
 
 set< shared_ptr<SignalData> > View::get_visible_data() const
 {
-       shared_lock<shared_mutex> lock(session().signals_mutex());
-       const unordered_set< shared_ptr<Signal> > &sigs(session().signals());
+       const unordered_set< shared_ptr<Signal> > sigs(session().signals());
 
        // Make a set of all the visible data objects
        set< shared_ptr<SignalData> > visible_data;
@@ -745,8 +744,7 @@ void View::determine_time_unit()
 {
        // Check whether we know the sample rate and hence can use time as the unit
        if (time_unit_ == util::TimeUnit::Samples) {
-               shared_lock<shared_mutex> lock(session().signals_mutex());
-               const unordered_set< shared_ptr<Signal> > &sigs(session().signals());
+               const unordered_set< shared_ptr<Signal> > sigs(session().signals());
 
                // Check all signals but...
                for (const shared_ptr<Signal> signal : sigs) {
@@ -885,8 +883,7 @@ void View::signals_changed()
        const set<shared_ptr<Trace>> prev_traces(
                prev_trace_list.begin(), prev_trace_list.end());
 
-       shared_lock<shared_mutex> lock(session_.signals_mutex());
-       const unordered_set< shared_ptr<Signal> > &sigs(session_.signals());
+       const unordered_set< shared_ptr<Signal> > sigs(session_.signals());
 
        set< shared_ptr<Trace> > traces(sigs.begin(), sigs.end());