diff options
Diffstat (limited to 'src/server/Task.cpp')
-rw-r--r-- | src/server/Task.cpp | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/src/server/Task.cpp b/src/server/Task.cpp index b61a08eb..2b8ff0cd 100644 --- a/src/server/Task.cpp +++ b/src/server/Task.cpp @@ -22,21 +22,21 @@ #include "raul/Path.hpp" #include <cstddef> +#include <memory> -namespace ingen { -namespace server { +namespace ingen::server { void -Task::run(RunContext& context) +Task::run(RunContext& ctx) { switch (_mode) { case Mode::SINGLE: // fprintf(stderr, "%u run %s\n", context.id(), _block->path().c_str()); - _block->process(context); + _block->process(ctx); break; case Mode::SEQUENTIAL: for (const auto& task : _children) { - task->run(context); + task->run(ctx); } break; case Mode::PARALLEL: @@ -48,16 +48,16 @@ Task::run(RunContext& context) // Grab the first sub-task _next = 0; _done_end = 0; - Task* t = steal(context); + Task* t = steal(ctx); // Allow other threads to steal sub-tasks - context.claim_task(this); + ctx.claim_task(this); // Run available tasks until this task is finished - for (; t; t = get_task(context)) { - t->run(context); + for (; t; t = get_task(ctx)) { + t->run(ctx); } - context.claim_task(nullptr); + ctx.claim_task(nullptr); break; } @@ -78,10 +78,10 @@ Task::steal(RunContext&) } Task* -Task::get_task(RunContext& context) +Task::get_task(RunContext& ctx) { // Attempt to "steal" a task from ourselves - Task* t = steal(context); + Task* t = steal(ctx); if (t) { return t; } @@ -93,11 +93,11 @@ Task::get_task(RunContext& context) } if (_done_end >= _children.size()) { - return nullptr; // All child tasks are finished + return nullptr; // All child tasks are finished } // All child tasks claimed, but some are unfinished, steal a task - if ((t = context.steal_task())) { + if ((t = ctx.steal_task())) { return t; } @@ -116,7 +116,7 @@ Task::simplify(std::unique_ptr<Task>&& task) return std::move(task); } - std::unique_ptr<Task> ret = std::unique_ptr<Task>(new Task(task->mode())); + std::unique_ptr<Task> ret = std::make_unique<Task>(task->mode()); for (auto&& c : task->_children) { auto child = simplify(std::move(c)); if (!child->empty()) { @@ -162,5 +162,4 @@ Task::dump(const std::function<void(const std::string&)>& sink, } } -} // namespace server -} // namespace ingen +} // namespace ingen::server |