From 5994178571afa3483d2a52ce78646d4161153ea5 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Thu, 6 Oct 2011 14:48:26 +0000 Subject: Simpler providers/dependants implementation. Raul::List is no longer necessary here since these lists are only accessed in the pre-processing thread. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3531 a436a847-0d15-0410-975c-d299462d15a1 --- src/server/CompiledPatch.hpp | 7 ++++--- src/server/NodeImpl.cpp | 4 ---- src/server/NodeImpl.hpp | 19 +++++++------------ src/server/PatchImpl.cpp | 2 +- src/server/PatchImpl.hpp | 9 +++++---- src/server/events/Connect.cpp | 4 ++-- src/server/events/CreatePort.cpp | 1 - src/server/events/Disconnect.cpp | 12 ++++++------ 8 files changed, 25 insertions(+), 33 deletions(-) diff --git a/src/server/CompiledPatch.hpp b/src/server/CompiledPatch.hpp index 519b5a2a..2fe701c0 100644 --- a/src/server/CompiledPatch.hpp +++ b/src/server/CompiledPatch.hpp @@ -19,6 +19,7 @@ #define INGEN_ENGINE_COMPILEDPATCH_HPP #include +#include #include @@ -34,14 +35,14 @@ class NodeImpl; /** All information required about a node to execute it in an audio thread. */ struct CompiledNode { - CompiledNode(NodeImpl* n, size_t np, Raul::List* d) + CompiledNode(NodeImpl* n, size_t np, const std::list& d) : _node(n), _n_providers(np) { // Copy to a vector for maximum iteration speed and cache optimization // (Need to take a copy anyway) - _dependants.reserve(d->size()); - for (Raul::List::iterator i = d->begin(); i != d->end(); ++i) + _dependants.reserve(d.size()); + for (std::list::const_iterator i = d.begin(); i != d.end(); ++i) _dependants.push_back(*i); } diff --git a/src/server/NodeImpl.cpp b/src/server/NodeImpl.cpp index eab31716..4b52fd6b 100644 --- a/src/server/NodeImpl.cpp +++ b/src/server/NodeImpl.cpp @@ -46,8 +46,6 @@ NodeImpl::NodeImpl(PluginImpl* plugin, const Raul::Symbol& symbol, bool polyphon , _process_lock(0) , _n_inputs_ready(0) , _ports(NULL) - , _providers(new Raul::List()) - , _dependants(new Raul::List()) , _activated(false) , _traversed(false) { @@ -61,8 +59,6 @@ NodeImpl::~NodeImpl() if (_activated) deactivate(); - delete _providers; - delete _dependants; delete _ports; free(_valid_ports); diff --git a/src/server/NodeImpl.hpp b/src/server/NodeImpl.hpp index 3fc4a5d6..6d9ef14b 100644 --- a/src/server/NodeImpl.hpp +++ b/src/server/NodeImpl.hpp @@ -18,6 +18,7 @@ #ifndef INGEN_ENGINE_NODEIMPL_HPP #define INGEN_ENGINE_NODEIMPL_HPP +#include #include #include @@ -152,17 +153,11 @@ public: virtual Port* port(uint32_t index) const; virtual PortImpl* port_impl(uint32_t index) const { return (*_ports)[index]; } - /** Nodes that are connected to this Node's inputs. - * (This Node depends on them) - */ - Raul::List* providers() { return _providers; } - void providers(Raul::List* l) { _providers = l; } + /** Nodes that are connected to this Node's inputs. */ + std::list& providers() { return _providers; } - /** Nodes are are connected to this Node's outputs. - * (They depend on this Node) - */ - Raul::List* dependants() { return _dependants; } - void dependants(Raul::List* l) { _dependants = l; } + /** Nodes are are connected to this Node's outputs. */ + std::list& dependants() { return _dependants; } /** Flag node as polyphonic. * @@ -216,8 +211,8 @@ protected: Raul::AtomicInt _process_lock; ///< Parallelism: Waiting on inputs 'lock' Raul::AtomicInt _n_inputs_ready; ///< Parallelism: # input ready signals this cycle Raul::Array* _ports; ///< Access in audio thread only - Raul::List* _providers; ///< Nodes connected to this one's input ports - Raul::List* _dependants; ///< Nodes this one's output ports are connected to + std::list _providers; ///< Nodes connected to this one's input ports + std::list _dependants; ///< Nodes this one's output ports are connected to bool _activated; bool _traversed; ///< Flag for process order algorithm diff --git a/src/server/PatchImpl.cpp b/src/server/PatchImpl.cpp index fb24faf7..c99b0bb1 100644 --- a/src/server/PatchImpl.cpp +++ b/src/server/PatchImpl.cpp @@ -444,7 +444,7 @@ PatchImpl::compile() const for (Nodes::const_iterator i = _nodes.begin(); i != _nodes.end(); ++i) { NodeImpl* const node = (*i); // Either a sink or connected to our output ports: - if ( ( ! node->traversed()) && node->dependants()->size() == 0) + if (!node->traversed() && node->dependants().size() == 0) compile_recursive(node, compiled_patch); } diff --git a/src/server/PatchImpl.hpp b/src/server/PatchImpl.hpp index 5795a066..095a04b7 100644 --- a/src/server/PatchImpl.hpp +++ b/src/server/PatchImpl.hpp @@ -154,11 +154,12 @@ PatchImpl::compile_recursive(NodeImpl* n, CompiledPatch* output) const n->traversed(true); assert(output != NULL); - for (Raul::List::iterator i = n->providers()->begin(); i != n->providers()->end(); ++i) - if ( ! (*i)->traversed() ) - compile_recursive((*i), output); + for (std::list::iterator i = n->providers().begin(); + i != n->providers().end(); ++i) + if (!(*i)->traversed()) + compile_recursive(*i, output); - output->push_back(CompiledNode(n, n->providers()->size(), n->dependants())); + output->push_back(CompiledNode(n, n->providers().size(), n->dependants())); } } // namespace Server diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp index da7aa593..39438d43 100644 --- a/src/server/events/Connect.cpp +++ b/src/server/events/Connect.cpp @@ -141,8 +141,8 @@ Connect::pre_process() provider... */ if (src_node != dst_node && src_node->parent() == dst_node->parent()) { - dst_node->providers()->push_back(new Raul::List::Node(src_node)); - src_node->dependants()->push_back(new Raul::List::Node(dst_node)); + dst_node->providers().push_back(src_node); + src_node->dependants().push_back(dst_node); } _patch->add_connection(_connection); diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp index c6d7c296..84a8e2d3 100644 --- a/src/server/events/CreatePort.cpp +++ b/src/server/events/CreatePort.cpp @@ -17,7 +17,6 @@ #include "raul/Array.hpp" #include "raul/Atom.hpp" -#include "raul/List.hpp" #include "raul/Maid.hpp" #include "raul/Path.hpp" #include "shared/LV2URIMap.hpp" diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp index de078c3f..c55ae1ae 100644 --- a/src/server/events/Disconnect.cpp +++ b/src/server/events/Disconnect.cpp @@ -75,18 +75,18 @@ Disconnect::Impl::Impl(Engine& e, NodeImpl* const src_node = _src_output_port->parent_node(); NodeImpl* const dst_node = _dst_input_port->parent_node(); - for (Raul::List::iterator i = dst_node->providers()->begin(); - i != dst_node->providers()->end(); ++i) { + for (std::list::iterator i = dst_node->providers().begin(); + i != dst_node->providers().end(); ++i) { if ((*i) == src_node) { - delete dst_node->providers()->erase(i); + dst_node->providers().erase(i); break; } } - for (Raul::List::iterator i = src_node->dependants()->begin(); - i != src_node->dependants()->end(); ++i) { + for (std::list::iterator i = src_node->dependants().begin(); + i != src_node->dependants().end(); ++i) { if ((*i) == dst_node) { - delete src_node->dependants()->erase(i); + src_node->dependants().erase(i); break; } } -- cgit v1.2.1