summaryrefslogtreecommitdiffstats
path: root/src/server/GraphImpl.cpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-11-23 14:24:07 -0500
committerDavid Robillard <d@drobilla.net>2016-10-01 07:03:17 -0400
commit11b55676a510171a56975743fd752ccbcc170622 (patch)
treeb36fce044d67e2c8f358170f207f2ec0926cb8a2 /src/server/GraphImpl.cpp
parent92d75b64d9f4cf9ca9caf3e1a0d3ad9819eb5481 (diff)
downloadingen-11b55676a510171a56975743fd752ccbcc170622.tar.gz
ingen-11b55676a510171a56975743fd752ccbcc170622.tar.bz2
ingen-11b55676a510171a56975743fd752ccbcc170622.zip
Add parallelism-aware graph traversal
Diffstat (limited to 'src/server/GraphImpl.cpp')
-rw-r--r--src/server/GraphImpl.cpp66
1 files changed, 7 insertions, 59 deletions
diff --git a/src/server/GraphImpl.cpp b/src/server/GraphImpl.cpp
index 86966b7c..22276a34 100644
--- a/src/server/GraphImpl.cpp
+++ b/src/server/GraphImpl.cpp
@@ -233,11 +233,8 @@ GraphImpl::process(RunContext& context)
void
GraphImpl::run(RunContext& context)
{
- if (_compiled_graph && _compiled_graph->size() > 0) {
- // Run all blocks
- for (size_t i = 0; i < _compiled_graph->size(); ++i) {
- (*_compiled_graph)[i].block()->process(context);
- }
+ if (_compiled_graph) {
+ _compiled_graph->run(context);
}
}
@@ -250,10 +247,11 @@ GraphImpl::set_buffer_size(RunContext& context,
BlockImpl::set_buffer_size(context, bufs, type, size);
if (_compiled_graph) {
- for (size_t i = 0; i < _compiled_graph->size(); ++i) {
- const CompiledBlock& block = (*_compiled_graph)[i];
- block.block()->set_buffer_size(context, bufs, type, size);
- }
+ // FIXME
+ // for (size_t i = 0; i < _compiled_graph->size(); ++i) {
+ // const CompiledBlock& block = (*_compiled_graph)[i];
+ // block.block()->set_buffer_size(context, bufs, type, size);
+ // }
}
}
@@ -353,55 +351,5 @@ GraphImpl::build_ports_array()
return result;
}
-static inline void
-compile_recursive(BlockImpl* n, CompiledGraph* output)
-{
- if (n == NULL || n->traversed())
- return;
-
- n->traversed(true);
- assert(output != NULL);
-
- for (auto& p : n->providers())
- if (!p->traversed())
- compile_recursive(p, output);
-
- output->push_back(CompiledBlock(n));
-}
-
-CompiledGraph*
-GraphImpl::compile()
-{
- ThreadManager::assert_thread(THREAD_PRE_PROCESS);
-
- CompiledGraph* const compiled_graph = new CompiledGraph();
-
- for (auto& b : _blocks) {
- b.traversed(false);
- }
-
- for (auto& b : _blocks) {
- // Either a sink or connected to our output ports:
- if (!b.traversed() && b.dependants().empty()) {
- compile_recursive(&b, compiled_graph);
- }
- }
-
- // Traverse any blocks we didn't hit yet
- for (auto& b : _blocks) {
- if (!b.traversed()) {
- compile_recursive(&b, compiled_graph);
- }
- }
-
- if (compiled_graph->size() != _blocks.size()) {
- _engine.log().error(fmt("Failed to compile graph %1%\n") % _path);
- delete compiled_graph;
- return NULL;
- }
-
- return compiled_graph;
-}
-
} // namespace Server
} // namespace Ingen