projects
/
pulseview.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c3a740d
)
SigSession: Converted _signals_mutex into a boost::shared_mutex
author
Joel Holdsworth
<joel@airwebreathe.org.uk>
Sun, 5 Oct 2014 17:54:29 +0000
(18:54 +0100)
committer
Joel Holdsworth
<joel@airwebreathe.org.uk>
Wed, 19 Nov 2014 10:23:02 +0000
(10:23 +0000)
CMakeLists.txt
patch
|
blob
|
history
pv/popups/channels.cpp
patch
|
blob
|
history
pv/sigsession.cpp
patch
|
blob
|
history
pv/sigsession.h
patch
|
blob
|
history
pv/storesession.cpp
patch
|
blob
|
history
pv/view/decodetrace.cpp
patch
|
blob
|
history
pv/view/view.cpp
patch
|
blob
|
history
diff --git
a/CMakeLists.txt
b/CMakeLists.txt
index d11f1430d4b9d76cf8e1ef175db8a9f8c26692b6..0ef18566cec4f6db9f63d950683abd0af9a85fc4 100644
(file)
--- a/
CMakeLists.txt
+++ b/
CMakeLists.txt
@@
-91,7
+91,7
@@
else()
find_package(Qt4 REQUIRED QtCore QtGui QtSvg)
endif()
find_package(Qt4 REQUIRED QtCore QtGui QtSvg)
endif()
-find_package(Boost 1.42 COMPONENTS filesystem system REQUIRED)
+find_package(Boost 1.42 COMPONENTS filesystem system
thread
REQUIRED)
# Find the platform's thread library (needed for C++11 threads).
# This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value.
# Find the platform's thread library (needed for C++11 threads).
# This will set ${CMAKE_THREAD_LIBS_INIT} to the correct, OS-specific value.
diff --git
a/pv/popups/channels.cpp
b/pv/popups/channels.cpp
index 9afc3b48952754047eecce46b3f7aefb2630beb8..ee0daedf4b1035f76c6d6346dc9a59616be8db49 100644
(file)
--- a/
pv/popups/channels.cpp
+++ b/
pv/popups/channels.cpp
@@
-35,6
+35,8
@@
using namespace Qt;
using namespace Qt;
+using boost::shared_lock;
+using boost::shared_mutex;
using std::lock_guard;
using std::map;
using std::mutex;
using std::lock_guard;
using std::map;
using std::mutex;
@@
-68,7
+70,7
@@
Channels::Channels(SigSession &session, QWidget *parent) :
// Collect a set of signals
map<shared_ptr<Channel>, shared_ptr<Signal> > signal_map;
// Collect a set of signals
map<shared_ptr<Channel>, shared_ptr<Signal> > signal_map;
-
lock_guard<
mutex> lock(_session.signals_mutex());
+
shared_lock<shared_
mutex> lock(_session.signals_mutex());
const vector< shared_ptr<Signal> > &sigs(_session.signals());
for (const shared_ptr<Signal> &sig : sigs)
const vector< shared_ptr<Signal> > &sigs(_session.signals());
for (const shared_ptr<Signal> &sig : sigs)
diff --git
a/pv/sigsession.cpp
b/pv/sigsession.cpp
index 9ff6efe4df6e5d00d00b21a5c41d68f0f4f79acc..11c89e092572e61119a6f96bec53a8e1a30dc775 100644
(file)
--- a/
pv/sigsession.cpp
+++ b/
pv/sigsession.cpp
@@
-47,12
+47,16
@@
#include <libsigrok/libsigrok.hpp>
#include <libsigrok/libsigrok.hpp>
+using boost::shared_lock;
+using boost::shared_mutex;
+using boost::unique_lock;
+
using std::dynamic_pointer_cast;
using std::function;
using std::lock_guard;
using std::dynamic_pointer_cast;
using std::function;
using std::lock_guard;
-using std::mutex;
using std::list;
using std::map;
using std::list;
using std::map;
+using std::mutex;
using std::set;
using std::shared_ptr;
using std::string;
using std::set;
using std::shared_ptr;
using std::string;
@@
-229,7
+233,7
@@
void SigSession::stop_capture()
set< shared_ptr<data::SignalData> > SigSession::get_data() const
{
set< shared_ptr<data::SignalData> > SigSession::get_data() const
{
-
lock_guard<
mutex> lock(_signals_mutex);
+
shared_lock<shared_
mutex> lock(_signals_mutex);
set< shared_ptr<data::SignalData> > data;
for (const shared_ptr<view::Signal> sig : _signals) {
assert(sig);
set< shared_ptr<data::SignalData> > data;
for (const shared_ptr<view::Signal> sig : _signals) {
assert(sig);
@@
-239,7
+243,7
@@
set< shared_ptr<data::SignalData> > SigSession::get_data() const
return data;
}
return data;
}
-mutex& SigSession::signals_mutex() const
+
boost::shared_
mutex& SigSession::signals_mutex() const
{
return _signals_mutex;
}
{
return _signals_mutex;
}
@@
-257,7
+261,7
@@
bool SigSession::add_decoder(srd_decoder *const dec)
try
{
try
{
- lock_guard<mutex> lock(_signals_mutex);
+ lock_guard<
boost::shared_
mutex> lock(_signals_mutex);
// Create the decoder
decoder_stack = shared_ptr<data::DecoderStack>(
// Create the decoder
decoder_stack = shared_ptr<data::DecoderStack>(
@@
-308,7
+312,7
@@
bool SigSession::add_decoder(srd_decoder *const dec)
vector< shared_ptr<view::DecodeTrace> > SigSession::get_decode_signals() const
{
vector< shared_ptr<view::DecodeTrace> > SigSession::get_decode_signals() const
{
-
lock_guard<
mutex> lock(_signals_mutex);
+
shared_lock<shared_
mutex> lock(_signals_mutex);
return _decode_traces;
}
return _decode_traces;
}
@@
-362,7
+366,7
@@
void SigSession::update_signals(shared_ptr<Device> device)
// Make the Signals list
{
// Make the Signals list
{
-
lock_guard<
mutex> lock(_signals_mutex);
+
unique_lock<shared_
mutex> lock(_signals_mutex);
_signals.clear();
_signals.clear();
@@
-403,7
+407,7
@@
void SigSession::update_signals(shared_ptr<Device> device)
shared_ptr<view::Signal> SigSession::signal_from_channel(
shared_ptr<Channel> channel) const
{
shared_ptr<view::Signal> SigSession::signal_from_channel(
shared_ptr<Channel> channel) const
{
- lock_guard<mutex> lock(_signals_mutex);
+ lock_guard<
boost::shared_
mutex> lock(_signals_mutex);
for (shared_ptr<view::Signal> sig : _signals) {
assert(sig);
if (sig->channel() == channel)
for (shared_ptr<view::Signal> sig : _signals) {
assert(sig);
if (sig->channel() == channel)
diff --git
a/pv/sigsession.h
b/pv/sigsession.h
index 37ea3abcdcd936f636714d68d2a01915cfee2bda..62994256c80b2008c97158f213a13690ee5af41e 100644
(file)
--- a/
pv/sigsession.h
+++ b/
pv/sigsession.h
@@
-29,6
+29,8
@@
#include <thread>
#include <vector>
#include <thread>
#include <vector>
+#include <boost/thread.hpp>
+
#include <QObject>
#include <QString>
#include <QObject>
#include <QString>
@@
-104,7
+106,7
@@
public:
std::set< std::shared_ptr<data::SignalData> > get_data() const;
std::set< std::shared_ptr<data::SignalData> > get_data() const;
-
std::
mutex& signals_mutex() const;
+
boost::shared_
mutex& signals_mutex() const;
const std::vector< std::shared_ptr<view::Signal> >& signals() const;
const std::vector< std::shared_ptr<view::Signal> >& signals() const;
@@
-159,7
+161,7
@@
private:
mutable std::mutex _sampling_mutex;
capture_state _capture_state;
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;
std::vector< std::shared_ptr<view::Signal> > _signals;
mutable std::mutex _data_mutex;
diff --git
a/pv/storesession.cpp
b/pv/storesession.cpp
index 95b8da8738a33f8c808633df283b7190ea6b6d70..ef1c6aad2d245317988066b65c3299033d89ebca 100644
(file)
--- a/
pv/storesession.cpp
+++ b/
pv/storesession.cpp
@@
-29,6
+29,9
@@
#include <libsigrok/libsigrok.hpp>
#include <libsigrok/libsigrok.hpp>
+using boost::shared_lock;
+using boost::shared_mutex;
+
using std::deque;
using std::dynamic_pointer_cast;
using std::lock_guard;
using std::deque;
using std::dynamic_pointer_cast;
using std::lock_guard;
@@
-80,7
+83,7
@@
bool StoreSession::start()
set< shared_ptr<data::SignalData> > data_set =
_session.get_data();
set< shared_ptr<data::SignalData> > data_set =
_session.get_data();
-
lock_guard<
mutex> lock(_session.signals_mutex());
+
shared_lock<shared_
mutex> lock(_session.signals_mutex());
const vector< shared_ptr<view::Signal> > &sigs(_session.signals());
// Check we have logic data
const vector< shared_ptr<view::Signal> > &sigs(_session.signals());
// Check we have logic data
diff --git
a/pv/view/decodetrace.cpp
b/pv/view/decodetrace.cpp
index 138ba0a14263fc92e0ce09cb74232f227d0b0c22..1cb9ce7154a9c302f15e3ecb63637f109f84286a 100644
(file)
--- a/
pv/view/decodetrace.cpp
+++ b/
pv/view/decodetrace.cpp
@@
-53,6
+53,8
@@
extern "C" {
#include <pv/widgets/decodergroupbox.h>
#include <pv/widgets/decodermenu.h>
#include <pv/widgets/decodergroupbox.h>
#include <pv/widgets/decodermenu.h>
+using boost::shared_lock;
+using boost::shared_mutex;
using std::dynamic_pointer_cast;
using std::list;
using std::lock_guard;
using std::dynamic_pointer_cast;
using std::list;
using std::lock_guard;
@@
-60,7
+62,6
@@
using std::make_pair;
using std::max;
using std::map;
using std::min;
using std::max;
using std::map;
using std::min;
-using std::mutex;
using std::pair;
using std::shared_ptr;
using std::tie;
using std::pair;
using std::shared_ptr;
using std::tie;
@@
-696,7
+697,7
@@
QComboBox* DecodeTrace::create_channel_selector(
{
assert(dec);
{
assert(dec);
-
lock_guard<
mutex> lock(_session.signals_mutex());
+
shared_lock<shared_
mutex> lock(_session.signals_mutex());
const vector< shared_ptr<Signal> > &sigs(_session.signals());
assert(_decoder_stack);
const vector< shared_ptr<Signal> > &sigs(_session.signals());
assert(_decoder_stack);
@@
-731,7
+732,7
@@
void DecodeTrace::commit_decoder_channels(shared_ptr<data::decode::Decoder> &dec
map<const srd_channel*, shared_ptr<LogicSignal> > channel_map;
map<const srd_channel*, shared_ptr<LogicSignal> > channel_map;
-
lock_guard<
mutex> lock(_session.signals_mutex());
+
shared_lock<shared_
mutex> lock(_session.signals_mutex());
const vector< shared_ptr<Signal> > &sigs(_session.signals());
for (const ChannelSelector &s : _channel_selectors)
const vector< shared_ptr<Signal> > &sigs(_session.signals());
for (const ChannelSelector &s : _channel_selectors)
diff --git
a/pv/view/view.cpp
b/pv/view/view.cpp
index 079d8d89b38ffaec8e42b1c6a7f173e56a46bb30..61f017660cab050cc5ae84f0b9d626daef69bcca 100644
(file)
--- a/
pv/view/view.cpp
+++ b/
pv/view/view.cpp
@@
-43,6
+43,8
@@
#include "pv/data/logic.h"
#include "pv/data/logicsnapshot.h"
#include "pv/data/logic.h"
#include "pv/data/logicsnapshot.h"
+using boost::shared_lock;
+using boost::shared_mutex;
using pv::data::SignalData;
using std::back_inserter;
using std::deque;
using pv::data::SignalData;
using std::back_inserter;
using std::deque;
@@
-51,7
+53,6
@@
using std::lock_guard;
using std::max;
using std::make_pair;
using std::min;
using std::max;
using std::make_pair;
using std::min;
-using std::mutex;
using std::pair;
using std::set;
using std::shared_ptr;
using std::pair;
using std::set;
using std::shared_ptr;
@@
-273,7
+274,7
@@
list<weak_ptr<SelectableItem> > View::selected_items() const
set< shared_ptr<SignalData> > View::get_visible_data() const
{
set< shared_ptr<SignalData> > View::get_visible_data() const
{
-
lock_guard<
mutex> lock(session().signals_mutex());
+
shared_lock<shared_
mutex> lock(session().signals_mutex());
const vector< shared_ptr<Signal> > &sigs(session().signals());
// Make a set of all the visible data objects
const vector< shared_ptr<Signal> > &sigs(session().signals());
// Make a set of all the visible data objects
@@
-522,7
+523,7
@@
void View::signals_changed()
// Populate the traces
clear_child_items();
// Populate the traces
clear_child_items();
-
lock_guard<
mutex> lock(session().signals_mutex());
+
shared_lock<shared_
mutex> lock(session().signals_mutex());
const vector< shared_ptr<Signal> > &sigs(session().signals());
for (auto s : sigs)
add_child_item(s);
const vector< shared_ptr<Signal> > &sigs(session().signals());
for (auto s : sigs)
add_child_item(s);