summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2012-05-15 00:05:25 +0000
committerCarl Hetherington <carl@carlh.net>2012-05-15 00:05:25 +0000
commit0c3f6d9819d701995a5c9af000defa7153b57404 (patch)
tree163339d06867c2ec003974952e547b1b83184c4d /libs
parent42267ff78c039b63d7fff57439207418a1ac9f4e (diff)
Remove the need for a shared_ptr for Signal; signal
tells its connections that it's going away, instead. git-svn-id: svn://localhost/ardour2/branches/3.0@12277 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs')
-rw-r--r--libs/pbd/pbd/signal.h.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/libs/pbd/pbd/signal.h.py b/libs/pbd/pbd/signal.h.py
index 70a1a2d88c..9997811c52 100644
--- a/libs/pbd/pbd/signal.h.py
+++ b/libs/pbd/pbd/signal.h.py
@@ -9,10 +9,7 @@ if len(sys.argv) < 2:
f = open(sys.argv[1], 'w')
print >>f,"""
-/** THIS FILE IS AUTOGENERATED: DO NOT EDIT.
- *
- * This file is generated by signals.h.py.
- */
+/** THIS FILE IS AUTOGENERATED by signals.h.py: CHANGES WILL BE LOST */
#include <list>
#include <boost/function.hpp>
@@ -26,7 +23,7 @@ namespace PBD {
class Connection;
-class SignalBase : public boost::enable_shared_from_this<SignalBase>
+class SignalBase
{
public:
virtual ~SignalBase () {}
@@ -39,17 +36,25 @@ protected:
class Connection : public boost::enable_shared_from_this<Connection>
{
public:
- Connection (boost::shared_ptr<SignalBase> b) : _signal (b) {}
+ Connection (SignalBase* b) : _signal (b) {}
void disconnect ()
{
+ boost::mutex::scoped_lock lm (_mutex);
if (_signal) {
_signal->disconnect (shared_from_this ());
}
}
+ void signal_going_away ()
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+ _signal = 0;
+ }
+
private:
- boost::shared_ptr<SignalBase> _signal;
+ boost::mutex _mutex;
+ SignalBase* _signal;
};
template<typename R>
@@ -112,10 +117,23 @@ def simple_signal(f, n, v):
print >>f,"public:"
print >>f,""
+ print >>f,"\t~SimpleSignal%d ()" % n
+
print >>f,"""
+ {
+ boost::mutex::scoped_lock lm (_mutex);
+#if __GNUC__ > 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ >= 6))
+ for (typename Slots::iterator i = _slots.begin(); i != _slots.end(); ++i) {
+#else
+ for (Slots::iterator i = _slots.begin(); i != _slots.end(); ++i) {
+#endif
+ i->first->signal_going_away ();
+ }
+ }
+
boost::shared_ptr<Connection> connect (slot_function_type f)
{
- boost::shared_ptr<Connection> c (new Connection (shared_from_this ()));
+ boost::shared_ptr<Connection> c (new Connection (this));
boost::mutex::scoped_lock lm (_mutex);
_slots[c] = f;
return c;