From b1198f0842e6e4d6b1c01f07d91b42ef4a212788 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sun, 12 Feb 2017 15:04:20 +0100 Subject: Use smart pointers to handle real-time memory disposal --- src/server/PreProcessContext.hpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/server/PreProcessContext.hpp') diff --git a/src/server/PreProcessContext.hpp b/src/server/PreProcessContext.hpp index bf1115e8..ee9bed86 100644 --- a/src/server/PreProcessContext.hpp +++ b/src/server/PreProcessContext.hpp @@ -21,6 +21,8 @@ #include "GraphImpl.hpp" +namespace Raul { class Maid; } + namespace Ingen { namespace Server { @@ -44,17 +46,29 @@ public: * This may return false when an atomic bundle is deferring compilation, in * which case the graph is flagged as dirty for later compilation. */ - bool must_compile(GraphImpl* graph) { - if (!graph->enabled()) { + bool must_compile(GraphImpl& graph) { + if (!graph.enabled()) { return false; } else if (_in_bundle) { - _dirty_graphs.insert(graph); + _dirty_graphs.insert(&graph); return false; } else { return true; } } + /** Compile graph and return the result if necessary. + * + * This may return null when an atomic bundle is deferring compilation, in + * which case the graph is flagged as dirty for later compilation. + */ + MPtr maybe_compile(Raul::Maid& maid, GraphImpl& graph) { + if (must_compile(graph)) { + return CompiledGraph::compile(maid, graph); + } + return MPtr(); + } + /** Return all graphs that require compilation after an atomic bundle. */ const DirtyGraphs& dirty_graphs() const { return _dirty_graphs; } DirtyGraphs& dirty_graphs() { return _dirty_graphs; } -- cgit v1.2.1