change PBD::Transmitter code to use PBD::Signal<> not sigc::signal<>, since the latter is not thread safe

This commit is contained in:
Paul Davis 2016-08-14 08:33:23 -04:00
parent f77d1e0a36
commit 09ed9c44e7
3 changed files with 14 additions and 20 deletions

View File

@ -42,7 +42,7 @@ class LIBPBD_API Receiver : public sigc::trackable
virtual void receive (Transmitter::Channel, const char *) = 0;
private:
std::vector<sigc::connection *> connections;
PBD::ScopedConnectionList connections;
};
#endif // __libmisc_receiver_h__

View File

@ -23,7 +23,7 @@
#include <sstream>
#include <iostream>
#include <sigc++/sigc++.h>
#include <pbd/signals.h>
#include "pbd/libpbd_visibility.h"
@ -41,7 +41,7 @@ class LIBPBD_API Transmitter : public std::stringstream
Transmitter (Channel);
sigc::signal<void,Channel, const char *> &sender() {
PBD::Signal2<void,Channel, const char *> &sender() {
return *send;
}
@ -53,12 +53,12 @@ class LIBPBD_API Transmitter : public std::stringstream
private:
Channel channel;
sigc::signal<void, Channel, const char *> *send;
PBD::Signal2<void, Channel, const char *> *send;
sigc::signal<void, Channel, const char *> info;
sigc::signal<void, Channel, const char *> warning;
sigc::signal<void, Channel, const char *> error;
sigc::signal<void, Channel, const char *> fatal;
PBD::Signal2<void, Channel, const char *> info;
PBD::Signal2<void, Channel, const char *> warning;
PBD::Signal2<void, Channel, const char *> error;
PBD::Signal2<void, Channel, const char *> fatal;
};
/* for EGCS 2.91.66, if this function is not compiled within the same

View File

@ -37,23 +37,17 @@ Receiver::~Receiver ()
void
Receiver::hangup ()
{
vector<sigc::connection *>::iterator i;
for (i = connections.begin(); i != connections.end (); i++) {
(*i)->disconnect ();
delete *i;
}
connections.erase (connections.begin(), connections.end());
connections.drop_connections ();
}
void
Receiver::listen_to (Transmitter &transmitter)
{
sigc::connection *c = new sigc::connection;
/* odd syntax here because boost's placeholders (_1, _2) are in an
anonymous namespace which causes ambiguity with sigc++ (and will also
do so with std::placeholder in the C++11 future
*/
transmitter.sender().connect_same_thread (connections, boost::bind (&Receiver::receive, this, boost::arg<1>(), boost::arg<2>()));
(*c) = transmitter.sender().connect(mem_fun(*this, &Receiver::receive));
connections.push_back (c);
}