Skip to content

Commit

Permalink
[avnd] Handle passing larger messages from exec to ui
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Jun 18, 2024
1 parent 69d5a17 commit 6ca526a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 3rdparty/libossia
21 changes: 16 additions & 5 deletions src/plugins/score-plugin-avnd/Crousti/Executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -816,11 +816,22 @@ class Executor final

if constexpr(avnd::has_processor_to_gui_bus<Node>)
{
eff.send_message = [this](auto b) mutable {
this->in_edit([this, bb = std::move(b)]() mutable {
if(this->process().to_ui)
MessageBusSender{this->process().to_ui}(std::move(bb));
});
eff.send_message = [this]<typename T>(T&& b) mutable {
if constexpr(sizeof(this) + sizeof(b) < Execution::ExecutionCommand::max_storage)
{
this->in_edit([this, bb = std::move(b)]() mutable {
if(this->process().to_ui)
MessageBusSender{this->process().to_ui}(std::move(bb));
});
}
else
{
this->in_edit(
[this, bb = std::make_unique<std::decay_t<T>>(std::move(b))]() mutable {
if(this->process().to_ui)
MessageBusSender{this->process().to_ui}(*std::move(bb));
});
}
};
}
}
Expand Down
13 changes: 13 additions & 0 deletions src/plugins/score-plugin-avnd/Crousti/MessageBus.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,19 @@ struct MessageBusSender

this->bus(std::move(buf));
}

template <typename T>
void operator()(const std::shared_ptr<T>& msg)
{
SCORE_ASSERT(msg);
return (*this)(std::move(*msg));
}
template <typename T>
void operator()(std::unique_ptr<T> msg)
{
SCORE_ASSERT(msg);
return (*this)(std::move(*msg));
}
};

struct Deserializer
Expand Down

0 comments on commit 6ca526a

Please sign in to comment.