summaryrefslogtreecommitdiffstats
path: root/src/server/Task.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/Task.cpp')
-rw-r--r--src/server/Task.cpp59
1 files changed, 17 insertions, 42 deletions
diff --git a/src/server/Task.cpp b/src/server/Task.cpp
index c76c19ae..0630ec51 100644
--- a/src/server/Task.cpp
+++ b/src/server/Task.cpp
@@ -21,12 +21,12 @@ namespace Ingen {
namespace Server {
void
-Task::run(RunContext& context)
+Task::run(Runner& context)
{
switch (_mode) {
- case Mode::SINGLE:
+ case Mode::UNIT:
// fprintf(stderr, "%u run %s\n", context.id(), _block->path().c_str());
- _block->process(context);
+ context.run_unit(_unit);
break;
case Mode::SEQUENTIAL:
for (auto& task : _children) {
@@ -59,7 +59,7 @@ Task::run(RunContext& context)
}
Task*
-Task::steal(RunContext& context)
+Task::steal(Runner& context)
{
if (_mode == Mode::PARALLEL) {
const unsigned i = _next++;
@@ -72,7 +72,7 @@ Task::steal(RunContext& context)
}
Task*
-Task::get_task(RunContext& context)
+Task::get_task(Runner& context)
{
// Attempt to "steal" a task from ourselves
Task* t = steal(context);
@@ -104,54 +104,29 @@ Task::get_task(RunContext& context)
}
Task
-Task::simplify(Task task)
+Task::compile(const IR& work)
{
- if (task.mode() == Mode::SINGLE) {
- return task;
+ if (work.mode() == Mode::UNIT) {
+ return Task(Mode::UNIT, work.unit());
}
- Task ret(task.mode());
- for (auto&& c : task._children) {
- auto child = simplify(std::move(c));
+ Task task(work.mode());
+ for (auto c = work.children().rbegin(); c != work.children().rend(); ++c) {
+ auto child(compile(*c));
if (!child.empty()) {
- if (child.mode() == task.mode()) {
- // Merge child into parent
+ if (child.mode() == work.mode()) { // Merge child into parent
for (auto&& grandchild : child._children) {
- ret.append(std::move(grandchild));
+ task.append(std::move(grandchild));
}
} else {
- // Add child task
- ret.append(std::move(child));
+ task.append(std::move(child));
}
}
}
- if (ret._children.size() == 1) {
- return std::move(ret._children.front());
- }
-
- return ret;
-}
-
-void
-Task::dump(std::function<void (const std::string&)> sink, unsigned indent, bool first) const
-{
- if (!first) {
- sink("\n");
- for (unsigned i = 0; i < indent; ++i) {
- sink(" ");
- }
- }
-
- if (_mode == Mode::SINGLE) {
- sink(_block->path());
- } else {
- sink(((_mode == Mode::SEQUENTIAL) ? "(seq " : "(par "));
- for (size_t i = 0; i < _children.size(); ++i) {
- _children[i].dump(sink, indent + 5, i == 0);
- }
- sink(")");
- }
+ return ((task._children.size() == 1)
+ ? std::move(task._children.front())
+ : std::move(task));
}
} // namespace Server