summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-10-06 23:14:38 +0000
committerDavid Robillard <d@drobilla.net>2011-10-06 23:14:38 +0000
commit9dd656d3403395cdef8191faabcab9a3478fc6ae (patch)
treed9489943855277870c23d298cca63117151a2a7e
parenta42d55487c0f70313ebccb043c571c8097b20093 (diff)
downloadingen-9dd656d3403395cdef8191faabcab9a3478fc6ae.tar.gz
ingen-9dd656d3403395cdef8191faabcab9a3478fc6ae.tar.bz2
ingen-9dd656d3403395cdef8191faabcab9a3478fc6ae.zip
Remove _pending_disconnection from ConnectionImpl (reduce space per connection).
Instead, implement DisconnectAll in a way that avoids the problem this flag was being used to avoid. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3535 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--src/server/ConnectionImpl.cpp1
-rw-r--r--src/server/ConnectionImpl.hpp5
-rw-r--r--src/server/events/Disconnect.cpp2
-rw-r--r--src/server/events/DisconnectAll.cpp52
-rw-r--r--src/server/events/DisconnectAll.hpp2
5 files changed, 26 insertions, 36 deletions
diff --git a/src/server/ConnectionImpl.cpp b/src/server/ConnectionImpl.cpp
index 006a157d..640b61b0 100644
--- a/src/server/ConnectionImpl.cpp
+++ b/src/server/ConnectionImpl.cpp
@@ -45,7 +45,6 @@ ConnectionImpl::ConnectionImpl(PortImpl* src_port, PortImpl* dst_port)
: _src_port(src_port)
, _dst_port(dst_port)
, _queue(NULL)
- , _pending_disconnection(false)
{
assert(src_port);
assert(dst_port);
diff --git a/src/server/ConnectionImpl.hpp b/src/server/ConnectionImpl.hpp
index 36eb545f..169f68e6 100644
--- a/src/server/ConnectionImpl.hpp
+++ b/src/server/ConnectionImpl.hpp
@@ -67,10 +67,6 @@ public:
const Raul::Path& src_port_path() const;
const Raul::Path& dst_port_path() const;
- /** Used by some (recursive) events to prevent double disconnections */
- bool pending_disconnection() { return _pending_disconnection; }
- void pending_disconnection(bool b) { _pending_disconnection = b; }
-
void queue(Context& context);
void get_sources(Context& context,
@@ -100,7 +96,6 @@ protected:
PortImpl* const _src_port;
PortImpl* const _dst_port;
Raul::RingBuffer* _queue;
- bool _pending_disconnection;
};
} // namespace Server
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index c089fb11..5a6d53e8 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -108,8 +108,6 @@ Disconnect::Impl::Impl(Engine& e,
}
}
}
-
- _connection->pending_disconnection(true);
}
void
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index f355575a..b6ec3c4b 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -15,6 +15,8 @@
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <set>
+
#include <boost/format.hpp>
#include <glibmm/thread.h>
@@ -76,27 +78,6 @@ DisconnectAll::~DisconnectAll()
}
void
-DisconnectAll::maybe_remove_connection(ConnectionImpl* c)
-{
- if (c->pending_disconnection())
- return;
-
- OutputPort* src = dynamic_cast<OutputPort*>(c->src_port());
- InputPort* dst = dynamic_cast<InputPort*>(c->dst_port());
-
- if (_node) {
- if (src->parent_node() == _node || dst->parent_node() == _node) {
- _impls.push_back(new Disconnect::Impl(_engine, _parent, src, dst));
- }
- } else {
- assert(_port);
- if (src == _port || dst == _port) {
- _impls.push_back(new Disconnect::Impl(_engine, _parent, src, dst));
- }
- }
-}
-
-void
DisconnectAll::pre_process()
{
Glib::RWLock::WriterLock lock(_engine.engine_store()->lock(), Glib::NOT_LOCK);
@@ -134,12 +115,31 @@ DisconnectAll::pre_process()
assert((_node || _port) && !(_node && _port));
}
+ // Find set of connections to remove
+ std::set<ConnectionImpl*> to_remove;
for (Patch::Connections::const_iterator i = _parent->connections().begin();
- i != _parent->connections().end();) {
- Patch::Connections::const_iterator next = i;
- ++next;
- maybe_remove_connection((ConnectionImpl*)i->second.get());
- i = next;
+ i != _parent->connections().end(); ++i) {
+ ConnectionImpl* const c = (ConnectionImpl*)i->second.get();
+ if (_node) {
+ if (c->src_port()->parent_node() == _node
+ || c->dst_port()->parent_node() == _node) {
+ to_remove.insert(c);
+ }
+ } else {
+ assert(_port);
+ if (c->src_port() == _port || c->dst_port() == _port) {
+ to_remove.insert(c);
+ }
+ }
+ }
+
+ // Create disconnect events (which erases from _parent->connections())
+ for (std::set<ConnectionImpl*>::const_iterator i = to_remove.begin();
+ i != to_remove.end(); ++i) {
+ _impls.push_back(new Disconnect::Impl(
+ _engine, _parent,
+ dynamic_cast<OutputPort*>((*i)->src_port()),
+ dynamic_cast<InputPort*>((*i)->dst_port())));
}
if (!_deleting && _parent->enabled())
diff --git a/src/server/events/DisconnectAll.hpp b/src/server/events/DisconnectAll.hpp
index d53d1114..e3b23df6 100644
--- a/src/server/events/DisconnectAll.hpp
+++ b/src/server/events/DisconnectAll.hpp
@@ -70,8 +70,6 @@ private:
OBJECT_NOT_FOUND,
};
- void maybe_remove_connection(ConnectionImpl* c);
-
Raul::Path _parent_path;
Raul::Path _path;
PatchImpl* _parent;