summaryrefslogtreecommitdiffstats
path: root/src/server/events
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2017-02-12 15:04:20 +0100
committerDavid Robillard <d@drobilla.net>2017-02-12 15:31:47 +0100
commitb1198f0842e6e4d6b1c01f07d91b42ef4a212788 (patch)
tree93fdf4da89a6f5f634707fb8c989e0d9ee1a3c65 /src/server/events
parent81d45973412c675e3c0b4a10b64d811a219feeae (diff)
downloadingen-b1198f0842e6e4d6b1c01f07d91b42ef4a212788.tar.gz
ingen-b1198f0842e6e4d6b1c01f07d91b42ef4a212788.tar.bz2
ingen-b1198f0842e6e4d6b1c01f07d91b42ef4a212788.zip
Use smart pointers to handle real-time memory disposal
Diffstat (limited to 'src/server/events')
-rw-r--r--src/server/events/Connect.cpp21
-rw-r--r--src/server/events/Connect.hpp22
-rw-r--r--src/server/events/Copy.cpp8
-rw-r--r--src/server/events/Copy.hpp12
-rw-r--r--src/server/events/CreateBlock.cpp8
-rw-r--r--src/server/events/CreateBlock.hpp2
-rw-r--r--src/server/events/CreateGraph.cpp9
-rw-r--r--src/server/events/CreateGraph.hpp14
-rw-r--r--src/server/events/CreatePort.cpp20
-rw-r--r--src/server/events/CreatePort.hpp4
-rw-r--r--src/server/events/Delete.cpp20
-rw-r--r--src/server/events/Delete.hpp4
-rw-r--r--src/server/events/Delta.cpp12
-rw-r--r--src/server/events/Delta.hpp2
-rw-r--r--src/server/events/Disconnect.cpp18
-rw-r--r--src/server/events/Disconnect.hpp25
-rw-r--r--src/server/events/DisconnectAll.cpp11
-rw-r--r--src/server/events/DisconnectAll.hpp16
-rw-r--r--src/server/events/Mark.cpp10
-rw-r--r--src/server/events/Mark.hpp2
20 files changed, 98 insertions, 142 deletions
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index eb758940..e933a490 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -20,6 +20,7 @@
#include "ArcImpl.hpp"
#include "Broadcaster.hpp"
+#include "BufferFactory.hpp"
#include "Connect.hpp"
#include "Engine.hpp"
#include "GraphImpl.hpp"
@@ -44,8 +45,6 @@ Connect::Connect(Engine& engine,
, _head_path(head_path)
, _graph(NULL)
, _head(NULL)
- , _compiled_graph(NULL)
- , _voices(NULL)
{}
bool
@@ -125,8 +124,9 @@ Connect::pre_process(PreProcessContext& ctx)
tail_block->dependants().insert(head_block);
}
- if (ctx.must_compile(_graph)) {
- if (!(_compiled_graph = CompiledGraph::compile(_graph))) {
+ if (ctx.must_compile(*_graph)) {
+ if (!(_compiled_graph = CompiledGraph::compile(
+ *_engine.maid(), *_graph))) {
head_block->providers().erase(tail_block);
tail_block->dependants().erase(head_block);
return Event::pre_process_done(Status::COMPILATION_FAILED);
@@ -138,10 +138,9 @@ Connect::pre_process(PreProcessContext& ctx)
_head->increment_num_arcs();
if (!_head->is_driver_port()) {
- _voices = new Raul::Array<PortImpl::Voice>(_head->poly());
- _head->pre_get_buffers(*_engine.buffer_factory(),
- _voices,
- _head->poly());
+ BufferFactory& bufs = *_engine.buffer_factory();
+ _voices = bufs.maid().make_managed<PortImpl::Voices>(_head->poly());
+ _head->pre_get_buffers(bufs, _voices, _head->poly());
}
tail_output->inherit_neighbour(_head, _tail_remove, _tail_add);
@@ -156,11 +155,11 @@ Connect::execute(RunContext& context)
if (_status == Status::SUCCESS) {
_head->add_arc(context, _arc.get());
if (!_head->is_driver_port()) {
- _engine.maid()->dispose(_head->set_voices(context, _voices));
+ _head->set_voices(context, std::move(_voices));
}
_head->connect_buffers();
if (_compiled_graph) {
- _compiled_graph = _graph->swap_compiled_graph(_compiled_graph);
+ _graph->set_compiled_graph(std::move(_compiled_graph));
}
}
}
@@ -180,8 +179,6 @@ Connect::post_process()
Node::path_to_uri(_tail_path), _tail_remove, _tail_add);
}
}
-
- delete _compiled_graph;
}
void
diff --git a/src/server/events/Connect.hpp b/src/server/events/Connect.hpp
index 359c9f3b..8e7a5030 100644
--- a/src/server/events/Connect.hpp
+++ b/src/server/events/Connect.hpp
@@ -57,17 +57,17 @@ public:
void undo(Interface& target);
private:
- const Raul::Path _tail_path;
- const Raul::Path _head_path;
- GraphImpl* _graph;
- InputPort* _head;
- CompiledGraph* _compiled_graph;
- SPtr<ArcImpl> _arc;
- Raul::Array<PortImpl::Voice>* _voices;
- Resource::Properties _tail_remove;
- Resource::Properties _tail_add;
- Resource::Properties _head_remove;
- Resource::Properties _head_add;
+ const Raul::Path _tail_path;
+ const Raul::Path _head_path;
+ GraphImpl* _graph;
+ InputPort* _head;
+ MPtr<CompiledGraph> _compiled_graph;
+ SPtr<ArcImpl> _arc;
+ MPtr<PortImpl::Voices> _voices;
+ Resource::Properties _tail_remove;
+ Resource::Properties _tail_add;
+ Resource::Properties _head_remove;
+ Resource::Properties _head_add;
};
} // namespace Events
diff --git a/src/server/events/Copy.cpp b/src/server/events/Copy.cpp
index 4356e312..58c9a89c 100644
--- a/src/server/events/Copy.cpp
+++ b/src/server/events/Copy.cpp
@@ -45,7 +45,6 @@ Copy::Copy(Engine& engine,
, _old_block(NULL)
, _parent(NULL)
, _block(NULL)
- , _compiled_graph(NULL)
{}
bool
@@ -126,9 +125,7 @@ Copy::engine_to_engine(PreProcessContext& ctx)
_engine.store()->add(_block);
// Compile graph with new block added for insertion in audio thread
- if (ctx.must_compile(_parent)) {
- _compiled_graph = CompiledGraph::compile(_parent);
- }
+ _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_parent);
return Event::pre_process_done(Status::SUCCESS);
}
@@ -198,7 +195,7 @@ void
Copy::execute(RunContext& context)
{
if (_block && _compiled_graph) {
- _compiled_graph = _parent->swap_compiled_graph(_compiled_graph);
+ _parent->set_compiled_graph(std::move(_compiled_graph));
}
}
@@ -209,7 +206,6 @@ Copy::post_process()
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->copy(_old_uri, _new_uri);
}
- delete _compiled_graph;
}
void
diff --git a/src/server/events/Copy.hpp b/src/server/events/Copy.hpp
index 55310757..e95d905e 100644
--- a/src/server/events/Copy.hpp
+++ b/src/server/events/Copy.hpp
@@ -56,12 +56,12 @@ private:
bool engine_to_filesystem(PreProcessContext& ctx);
bool filesystem_to_engine(PreProcessContext& ctx);
- const Raul::URI _old_uri;
- const Raul::URI _new_uri;
- SPtr<BlockImpl> _old_block;
- GraphImpl* _parent;
- BlockImpl* _block;
- CompiledGraph* _compiled_graph;
+ const Raul::URI _old_uri;
+ const Raul::URI _new_uri;
+ SPtr<BlockImpl> _old_block;
+ GraphImpl* _parent;
+ BlockImpl* _block;
+ MPtr<CompiledGraph> _compiled_graph;
};
} // namespace Events
diff --git a/src/server/events/CreateBlock.cpp b/src/server/events/CreateBlock.cpp
index a43a8bf0..255746b1 100644
--- a/src/server/events/CreateBlock.cpp
+++ b/src/server/events/CreateBlock.cpp
@@ -46,12 +46,10 @@ CreateBlock::CreateBlock(Engine& engine,
, _properties(properties)
, _graph(NULL)
, _block(NULL)
- , _compiled_graph(NULL)
{}
CreateBlock::~CreateBlock()
{
- delete _compiled_graph;
}
bool
@@ -150,9 +148,7 @@ CreateBlock::pre_process(PreProcessContext& ctx)
/* Compile graph with new block added for insertion in audio thread
TODO: Since the block is not connected at this point, a full compilation
could be avoided and the block simply appended. */
- if (ctx.must_compile(_graph)) {
- _compiled_graph = CompiledGraph::compile(_graph);
- }
+ _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_graph);
_update.put_block(_block);
@@ -163,7 +159,7 @@ void
CreateBlock::execute(RunContext& context)
{
if (_status == Status::SUCCESS && _compiled_graph) {
- _compiled_graph = _graph->swap_compiled_graph(_compiled_graph);
+ _graph->set_compiled_graph(std::move(_compiled_graph));
}
}
diff --git a/src/server/events/CreateBlock.hpp b/src/server/events/CreateBlock.hpp
index b0aa6aa4..047c01f3 100644
--- a/src/server/events/CreateBlock.hpp
+++ b/src/server/events/CreateBlock.hpp
@@ -58,7 +58,7 @@ private:
ClientUpdate _update;
GraphImpl* _graph;
BlockImpl* _block;
- CompiledGraph* _compiled_graph;
+ MPtr<CompiledGraph> _compiled_graph;
};
} // namespace Events
diff --git a/src/server/events/CreateGraph.cpp b/src/server/events/CreateGraph.cpp
index a59aadc6..7ebaeedc 100644
--- a/src/server/events/CreateGraph.cpp
+++ b/src/server/events/CreateGraph.cpp
@@ -42,7 +42,6 @@ CreateGraph::CreateGraph(Engine& engine,
, _properties(properties)
, _graph(NULL)
, _parent(NULL)
- , _compiled_graph(NULL)
{}
CreateGraph::~CreateGraph()
@@ -50,8 +49,6 @@ CreateGraph::~CreateGraph()
for (Event* ev : _child_events) {
delete ev;
}
-
- delete _compiled_graph;
}
void
@@ -173,9 +170,7 @@ CreateGraph::pre_process(PreProcessContext& ctx)
if (_parent->enabled()) {
_graph->enable();
}
- if (ctx.must_compile(_parent)) {
- _compiled_graph = CompiledGraph::compile(_parent);
- }
+ _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_parent);
}
_graph->activate(*_engine.buffer_factory());
@@ -201,7 +196,7 @@ CreateGraph::execute(RunContext& context)
{
if (_graph) {
if (_parent && _compiled_graph) {
- _compiled_graph = _parent->swap_compiled_graph(_compiled_graph);
+ _parent->set_compiled_graph(std::move(_compiled_graph));
}
for (Event* ev : _child_events) {
diff --git a/src/server/events/CreateGraph.hpp b/src/server/events/CreateGraph.hpp
index 7eee9c08..896a18f9 100644
--- a/src/server/events/CreateGraph.hpp
+++ b/src/server/events/CreateGraph.hpp
@@ -56,13 +56,13 @@ public:
private:
void build_child_events();
- const Raul::Path _path;
- Resource::Properties _properties;
- ClientUpdate _update;
- GraphImpl* _graph;
- GraphImpl* _parent;
- CompiledGraph* _compiled_graph;
- std::list<Event*> _child_events;
+ const Raul::Path _path;
+ Resource::Properties _properties;
+ ClientUpdate _update;
+ GraphImpl* _graph;
+ GraphImpl* _parent;
+ MPtr<CompiledGraph> _compiled_graph;
+ std::list<Event*> _child_events;
};
} // namespace Events
diff --git a/src/server/events/CreatePort.cpp b/src/server/events/CreatePort.cpp
index bb8bb4d4..b6cabbeb 100644
--- a/src/server/events/CreatePort.cpp
+++ b/src/server/events/CreatePort.cpp
@@ -48,8 +48,6 @@ CreatePort::CreatePort(Engine& engine,
, _buf_type(0)
, _graph(NULL)
, _graph_port(NULL)
- , _ports_array(NULL)
- , _old_ports_array(NULL)
, _engine_port(NULL)
, _properties(properties)
{
@@ -156,8 +154,10 @@ CreatePort::pre_process(PreProcessContext& ctx)
_engine_port = _engine.driver()->create_port(_graph_port);
}
- _ports_array = new Raul::Array<PortImpl*>(old_n_ports + 1, NULL);
- _update = _graph_port->properties();
+ _ports_array = bufs.maid().make_managed<GraphImpl::Ports>(
+ old_n_ports + 1, nullptr);
+
+ _update = _graph_port->properties();
assert(_graph_port->index() == (uint32_t)index_i->second.get<int32_t>());
assert(_graph->num_ports_non_rt() == (uint32_t)old_n_ports + 1);
@@ -171,15 +171,15 @@ void
CreatePort::execute(RunContext& context)
{
if (_status == Status::SUCCESS) {
- _old_ports_array = _graph->external_ports();
- if (_old_ports_array) {
- for (uint32_t i = 0; i < _old_ports_array->size(); ++i) {
- (*_ports_array)[i] = (*_old_ports_array)[i];
+ const MPtr<GraphImpl::Ports>& old_ports = _graph->external_ports();
+ if (old_ports) {
+ for (uint32_t i = 0; i < old_ports->size(); ++i) {
+ (*_ports_array)[i] = (*old_ports)[i];
}
}
assert(!(*_ports_array)[_graph_port->index()]);
(*_ports_array)[_graph_port->index()] = _graph_port;
- _graph->external_ports(_ports_array);
+ _graph->set_external_ports(std::move(_ports_array));
if (_engine_port) {
_engine.driver()->add_port(context, _engine_port);
@@ -194,8 +194,6 @@ CreatePort::post_process()
if (respond() == Status::SUCCESS) {
_engine.broadcaster()->put(Node::path_to_uri(_path), _update);
}
-
- delete _old_ports_array;
}
void
diff --git a/src/server/events/CreatePort.hpp b/src/server/events/CreatePort.hpp
index f3e2092d..2d32f1dd 100644
--- a/src/server/events/CreatePort.hpp
+++ b/src/server/events/CreatePort.hpp
@@ -24,6 +24,7 @@
#include "raul/Array.hpp"
#include "raul/Path.hpp"
+#include "BlockImpl.hpp"
#include "Event.hpp"
#include "PortType.hpp"
@@ -67,8 +68,7 @@ private:
LV2_URID _buf_type;
GraphImpl* _graph;
DuplexPort* _graph_port;
- Raul::Array<PortImpl*>* _ports_array; ///< New external port array for Graph
- Raul::Array<PortImpl*>* _old_ports_array;
+ MPtr<BlockImpl::Ports> _ports_array; ///< New external port array for Graph
EnginePort* _engine_port; ///< Driver port if on the root
Resource::Properties _properties;
Resource::Properties _update;
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index b77f7c3e..788dfa2b 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -43,8 +43,6 @@ Delete::Delete(Engine& engine,
: Event(engine, client, id, time)
, _uri(uri)
, _engine_port(NULL)
- , _ports_array(NULL)
- , _compiled_graph(NULL)
, _disconnect_event(NULL)
{
if (Node::uri_is_path(uri)) {
@@ -55,7 +53,6 @@ Delete::Delete(Engine& engine,
Delete::~Delete()
{
delete _disconnect_event;
- delete _compiled_graph;
for (ControlBindings::Binding* b : _removed_bindings) {
delete b;
}
@@ -97,21 +94,15 @@ Delete::pre_process(PreProcessContext& ctx)
parent->remove_block(*_block);
_disconnect_event = new DisconnectAll(_engine, parent, _block.get());
_disconnect_event->pre_process(ctx);
-
- if (ctx.must_compile(parent)) {
- _compiled_graph = CompiledGraph::compile(parent);
- }
+ _compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent);
} else if (_port) {
parent->remove_port(*_port);
_disconnect_event = new DisconnectAll(_engine, parent, _port.get());
_disconnect_event->pre_process(ctx);
- if (ctx.must_compile(parent)) {
- _compiled_graph = CompiledGraph::compile(parent);
- }
-
+ _compiled_graph = ctx.maybe_compile(*_engine.maid(), *parent);
if (parent->enabled()) {
- _ports_array = parent->build_ports_array();
+ _ports_array = parent->build_ports_array(*_engine.maid());
assert(_ports_array->size() == parent->num_ports_non_rt());
}
@@ -141,8 +132,7 @@ Delete::execute(RunContext& context)
GraphImpl* parent = _block ? _block->parent_graph() : NULL;
if (_port) {
parent = _port->parent_graph();
- _engine.maid()->dispose(parent->external_ports());
- parent->external_ports(_ports_array);
+ parent->set_external_ports(std::move(_ports_array));
if (_engine_port) {
_engine.driver()->remove_port(context, _engine_port);
@@ -150,7 +140,7 @@ Delete::execute(RunContext& context)
}
if (parent && _compiled_graph) {
- _compiled_graph = parent->swap_compiled_graph(_compiled_graph);
+ parent->set_compiled_graph(std::move(_compiled_graph));
}
}
diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp
index 1b34faf6..224cad3b 100644
--- a/src/server/events/Delete.hpp
+++ b/src/server/events/Delete.hpp
@@ -65,8 +65,8 @@ private:
SPtr<BlockImpl> _block; ///< Non-NULL iff a block
SPtr<DuplexPort> _port; ///< Non-NULL iff a port
EnginePort* _engine_port;
- Raul::Array<PortImpl*>* _ports_array; ///< New (external) ports for Graph
- CompiledGraph* _compiled_graph; ///< Graph's new process order
+ MPtr<GraphImpl::Ports> _ports_array; ///< New (external) ports for Graph
+ MPtr<CompiledGraph> _compiled_graph; ///< Graph's new process order
DisconnectAll* _disconnect_event;
Store::Objects _removed_objects;
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index 2ad258fd..2c13f9d4 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -60,7 +60,6 @@ Delta::Delta(Engine& engine,
, _remove(remove)
, _object(NULL)
, _graph(NULL)
- , _compiled_graph(NULL)
, _binding(NULL)
, _state(NULL)
, _context(context)
@@ -87,7 +86,6 @@ Delta::~Delta()
delete s;
delete _create_event;
- delete _compiled_graph;
}
void
@@ -355,7 +353,8 @@ Delta::pre_process(PreProcessContext& ctx)
op = SpecialType::ENABLE;
// FIXME: defer this until all other metadata has been processed
if (value.get<int32_t>() && !_graph->enabled()) {
- if (!(_compiled_graph = CompiledGraph::compile(_graph))) {
+ if (!(_compiled_graph = CompiledGraph::compile(
+ *_engine.maid(), *_graph))) {
_status = Status::COMPILATION_FAILED;
}
}
@@ -476,7 +475,7 @@ Delta::execute(RunContext& context)
if (_graph) {
if (value.get<int32_t>()) {
if (_compiled_graph) {
- _compiled_graph = _graph->swap_compiled_graph(_compiled_graph);
+ _graph->set_compiled_graph(std::move(_compiled_graph));
}
_graph->enable();
} else {
@@ -489,10 +488,9 @@ Delta::execute(RunContext& context)
case SpecialType::POLYPHONIC: {
GraphImpl* parent = reinterpret_cast<GraphImpl*>(object->parent());
if (value.get<int32_t>()) {
- object->apply_poly(
- context, *_engine.maid(), parent->internal_poly_process());
+ object->apply_poly(context, parent->internal_poly_process());
} else {
- object->apply_poly(context, *_engine.maid(), 1);
+ object->apply_poly(context, 1);
}
} break;
case SpecialType::POLYPHONY:
diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp
index d2326cd9..d751afc7 100644
--- a/src/server/events/Delta.hpp
+++ b/src/server/events/Delta.hpp
@@ -104,7 +104,7 @@ private:
ClientUpdate _update;
Ingen::Resource* _object;
GraphImpl* _graph;
- CompiledGraph* _compiled_graph;
+ MPtr<CompiledGraph> _compiled_graph;
ControlBindings::Binding* _binding;
LilvState* _state;
Resource::Graph _context;
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index 3233cac4..9320163a 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -48,14 +48,12 @@ Disconnect::Disconnect(Engine& engine,
, _head_path(head_path)
, _graph(NULL)
, _impl(NULL)
- , _compiled_graph(NULL)
{
}
Disconnect::~Disconnect()
{
delete _impl;
- delete _compiled_graph;
}
Disconnect::Impl::Impl(Engine& e,
@@ -66,7 +64,6 @@ Disconnect::Impl::Impl(Engine& e,
, _tail(t)
, _head(h)
, _arc(graph->remove_arc(_tail, _head))
- , _voices(NULL)
{
ThreadManager::assert_thread(THREAD_PRE_PROCESS);
@@ -89,10 +86,9 @@ Disconnect::Impl::Impl(Engine& e,
if (_head->num_arcs() == 0) {
if (!_head->is_driver_port()) {
- _voices = new Raul::Array<PortImpl::Voice>(_head->poly());
- _head->pre_get_buffers(*_engine.buffer_factory(),
- _voices,
- _head->poly());
+ BufferFactory& bufs = *_engine.buffer_factory();
+ _voices = bufs.maid().make_managed<PortImpl::Voices>(_head->poly());
+ _head->pre_get_buffers(bufs, _voices, _head->poly());
if (_head->is_a(PortType::CONTROL) ||
_head->is_a(PortType::CV)) {
@@ -166,9 +162,7 @@ Disconnect::pre_process(PreProcessContext& ctx)
dynamic_cast<PortImpl*>(tail),
dynamic_cast<InputPort*>(head));
- if (ctx.must_compile(_graph)) {
- _compiled_graph = CompiledGraph::compile(_graph);
- }
+ _compiled_graph = ctx.maybe_compile(*_engine.maid(), *_graph);
return Event::pre_process_done(Status::SUCCESS);
}
@@ -186,7 +180,7 @@ Disconnect::Impl::execute(RunContext& context, bool set_head_buffers)
if (set_head_buffers) {
if (_voices) {
- _engine.maid()->dispose(_head->set_voices(context, _voices));
+ _head->set_voices(context, std::move(_voices));
} else {
_head->setup_buffers(context, *_engine.buffer_factory(), _head->poly());
}
@@ -204,7 +198,7 @@ Disconnect::execute(RunContext& context)
if (_status == Status::SUCCESS) {
if (_impl->execute(context, true)) {
if (_compiled_graph) {
- _compiled_graph = _graph->swap_compiled_graph(_compiled_graph);
+ _graph->set_compiled_graph(std::move(_compiled_graph));
}
} else {
_status = Status::NOT_FOUND;
diff --git a/src/server/events/Disconnect.hpp b/src/server/events/Disconnect.hpp
index fa16f01f..3a7e0cff 100644
--- a/src/server/events/Disconnect.hpp
+++ b/src/server/events/Disconnect.hpp
@@ -60,10 +60,7 @@ public:
class Impl {
public:
- Impl(Engine& e,
- GraphImpl* graph,
- PortImpl* t,
- InputPort* h);
+ Impl(Engine& e, GraphImpl* graph, PortImpl* t, InputPort* h);
bool execute(RunContext& context, bool set_head_buffers);
@@ -71,19 +68,19 @@ public:
inline InputPort* head() { return _head; }
private:
- Engine& _engine;
- PortImpl* _tail;
- InputPort* _head;
- SPtr<ArcImpl> _arc;
- Raul::Array<PortImpl::Voice>* _voices;
+ Engine& _engine;
+ PortImpl* _tail;
+ InputPort* _head;
+ SPtr<ArcImpl> _arc;
+ MPtr<PortImpl::Voices> _voices;
};
private:
- const Raul::Path _tail_path;
- const Raul::Path _head_path;
- GraphImpl* _graph;
- Impl* _impl;
- CompiledGraph* _compiled_graph;
+ const Raul::Path _tail_path;
+ const Raul::Path _head_path;
+ GraphImpl* _graph;
+ Impl* _impl;
+ MPtr<CompiledGraph> _compiled_graph;
};
} // namespace Events
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index 597f8e9b..16b62302 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -51,7 +51,6 @@ DisconnectAll::DisconnectAll(Engine& engine,
, _parent(NULL)
, _block(NULL)
, _port(NULL)
- , _compiled_graph(NULL)
, _deleting(false)
{
}
@@ -67,7 +66,6 @@ DisconnectAll::DisconnectAll(Engine& engine,
, _parent(parent)
, _block(dynamic_cast<BlockImpl*>(object))
, _port(dynamic_cast<PortImpl*>(object))
- , _compiled_graph(NULL)
, _deleting(true)
{
}
@@ -76,8 +74,6 @@ DisconnectAll::~DisconnectAll()
{
for (auto& i : _impls)
delete i;
-
- delete _compiled_graph;
}
bool
@@ -138,8 +134,9 @@ DisconnectAll::pre_process(PreProcessContext& ctx)
dynamic_cast<InputPort*>(a->head())));
}
- if (!_deleting && ctx.must_compile(_parent)) {
- if (!(_compiled_graph = CompiledGraph::compile(_parent))) {
+ if (!_deleting && ctx.must_compile(*_parent)) {
+ if (!(_compiled_graph = CompiledGraph::compile(
+ *_engine.maid(), *_parent))) {
return Event::pre_process_done(Status::COMPILATION_FAILED);
}
}
@@ -158,7 +155,7 @@ DisconnectAll::execute(RunContext& context)
}
if (_compiled_graph) {
- _compiled_graph = _parent->swap_compiled_graph(_compiled_graph);
+ _parent->set_compiled_graph(std::move(_compiled_graph));
}
}
diff --git a/src/server/events/DisconnectAll.hpp b/src/server/events/DisconnectAll.hpp
index 1fc1f757..abfa0572 100644
--- a/src/server/events/DisconnectAll.hpp
+++ b/src/server/events/DisconnectAll.hpp
@@ -64,14 +64,14 @@ public:
private:
typedef std::list<Disconnect::Impl*> Impls;
- Raul::Path _parent_path;
- Raul::Path _path;
- GraphImpl* _parent;
- BlockImpl* _block;
- PortImpl* _port;
- Impls _impls;
- CompiledGraph* _compiled_graph;
- bool _deleting;
+ Raul::Path _parent_path;
+ Raul::Path _path;
+ GraphImpl* _parent;
+ BlockImpl* _block;
+ PortImpl* _port;
+ Impls _impls;
+ MPtr<CompiledGraph> _compiled_graph;
+ bool _deleting;
};
} // namespace Events
diff --git a/src/server/events/Mark.cpp b/src/server/events/Mark.cpp
index c72cc14f..eee2d552 100644
--- a/src/server/events/Mark.cpp
+++ b/src/server/events/Mark.cpp
@@ -35,9 +35,6 @@ Mark::Mark(Engine& engine,
Mark::~Mark()
{
- for (const auto& g : _compiled_graphs) {
- delete g.second;
- }
}
bool
@@ -57,9 +54,10 @@ Mark::pre_process(PreProcessContext& ctx)
ctx.set_in_bundle(false);
if (!ctx.dirty_graphs().empty()) {
for (GraphImpl* g : ctx.dirty_graphs()) {
- CompiledGraph* cg = CompiledGraph::compile(g);
+ MPtr<CompiledGraph> cg = CompiledGraph::compile(
+ *_engine.maid(), *g);
if (cg) {
- _compiled_graphs.insert(std::make_pair(g, cg));
+ _compiled_graphs.insert(std::make_pair(g, std::move(cg)));
}
}
ctx.dirty_graphs().clear();
@@ -74,7 +72,7 @@ void
Mark::execute(RunContext& context)
{
for (auto& g : _compiled_graphs) {
- g.second = g.first->swap_compiled_graph(g.second);
+ g.first->set_compiled_graph(std::move(g.second));
}
}
diff --git a/src/server/events/Mark.hpp b/src/server/events/Mark.hpp
index 68ba5149..4a5e83bf 100644
--- a/src/server/events/Mark.hpp
+++ b/src/server/events/Mark.hpp
@@ -53,7 +53,7 @@ public:
Execution get_execution() const;
private:
- typedef std::map<GraphImpl*, CompiledGraph*> CompiledGraphs;
+ typedef std::map<GraphImpl*, MPtr<CompiledGraph>> CompiledGraphs;
CompiledGraphs _compiled_graphs;
Type _type;