diff options
Diffstat (limited to 'src/server/CompiledGraph.hpp')
-rw-r--r-- | src/server/CompiledGraph.hpp | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/src/server/CompiledGraph.hpp b/src/server/CompiledGraph.hpp index 9f4071a5..7dc40865 100644 --- a/src/server/CompiledGraph.hpp +++ b/src/server/CompiledGraph.hpp @@ -1,6 +1,6 @@ /* This file is part of Ingen. - Copyright 2007-2015 David Robillard <http://drobilla.net/> + Copyright 2007-2016 David Robillard <http://drobilla.net/> Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free @@ -17,41 +17,58 @@ #ifndef INGEN_ENGINE_COMPILEDGRAPH_HPP #define INGEN_ENGINE_COMPILEDGRAPH_HPP +#include <functional> +#include <set> #include <vector> -#include <list> #include "raul/Maid.hpp" #include "raul/Noncopyable.hpp" +#include "raul/Path.hpp" + +#include "Task.hpp" namespace Ingen { + +class Log; + namespace Server { class BlockImpl; +class GraphImpl; +class RunContext; -/** All information required about a block to execute it in an audio thread. +/** A graph ``compiled'' into a quickly executable form. + * + * This is a flat sequence of nodes ordered such that the process thread can + * execute the nodes in order and have nodes always executed before any of + * their dependencies. */ -class CompiledBlock { +class CompiledGraph : public Raul::Maid::Disposable + , public Raul::Noncopyable +{ public: - CompiledBlock(BlockImpl* b) : _block(b) {} + static CompiledGraph* compile(GraphImpl* graph); + + void run(RunContext& context); - BlockImpl* block() const { return _block; } + void dump(std::function<void (const std::string&)> sink) const; private: - BlockImpl* _block; -}; + CompiledGraph(GraphImpl* graph); -/** A graph ``compiled'' into a flat structure with the correct order so - * the audio thread(s) can execute it without threading problems (since - * the preprocessor thread modifies the graph). - * - * The blocks contained here are sorted in the order they must be executed. - * The parallel processing algorithm guarantees no block will be executed - * before its providers, using this order as well as semaphores. - */ -class CompiledGraph : public std::vector<CompiledBlock> - , public Raul::Maid::Disposable - , public Raul::Noncopyable -{ + typedef std::set<BlockImpl*> BlockSet; + + void compile_graph(GraphImpl* graph); + void compile_set(const BlockSet& blocks, Task& task, BlockSet& k); + void compile_block(BlockImpl* block, Task& task, BlockSet& k); + void compile_dependant(const BlockImpl* root, + BlockImpl* block, + Task& task, + BlockSet& k); + + Log& _log; + const Raul::Path _path; + Task _master; }; } // namespace Server |