diff options
author | David Robillard <d@drobilla.net> | 2018-03-15 00:01:38 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-03-15 00:02:11 -0400 |
commit | 85f207e2bfe1ba8c6124643ccf3b9efa0feffa0e (patch) | |
tree | f4bb2266d64c39e41c1cb53763f574bf74352098 /src/server | |
parent | 046688edc2e892aa44060e1ef8132d00b548cdbc (diff) | |
download | ingen-85f207e2bfe1ba8c6124643ccf3b9efa0feffa0e.tar.gz ingen-85f207e2bfe1ba8c6124643ccf3b9efa0feffa0e.tar.bz2 ingen-85f207e2bfe1ba8c6124643ccf3b9efa0feffa0e.zip |
Add more convenient Task creation API
Diffstat (limited to 'src/server')
-rw-r--r-- | src/server/Task.hpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/server/Task.hpp b/src/server/Task.hpp index 2cdad71b..22f72997 100644 --- a/src/server/Task.hpp +++ b/src/server/Task.hpp @@ -38,6 +38,17 @@ public: PARALLEL ///< Elements may be run in any order in parallel }; + explicit Task(BlockImpl* block) + : _block(block) + , _mode(Mode::SINGLE) + , _done_end(0) + , _next(0) + , _done(false) + { + assert(block); + } + + Task(Mode mode, BlockImpl* block = nullptr) : _block(block) , _mode(mode) @@ -83,11 +94,22 @@ public: /** Steal a child task from this task (succeeds for PARALLEL only). */ Task* steal(RunContext& context); + /** Return the child task at the front of this task. */ + Task& front() const { + return *_children.front(); + } + /** Prepend a child to this task. */ void push_front(Task&& task) { _children.emplace_front(std::unique_ptr<Task>(new Task(std::move(task)))); } + /** Prepend a child to this task. */ + template<typename... Args> + void emplace_front(Args... args) { + _children.emplace_front(std::unique_ptr<Task>(new Task(std::forward<Args>(args)...))); + } + Mode mode() const { return _mode; } BlockImpl* block() const { return _block; } bool done() const { return _done; } |