summaryrefslogtreecommitdiffstats
path: root/src/server/Task.hpp
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2018-03-24 14:07:08 +0100
committerDavid Robillard <d@drobilla.net>2018-03-24 14:07:08 +0100
commitc9863ba79edbac7ae78ad0e374a2988c816ad31a (patch)
tree7dcebb7dd779fded2cb358b7c4981f84a8c69e3d /src/server/Task.hpp
parentcc110c047e20499d995dac9bcbb1e9d15bbae4c2 (diff)
downloadingen-c9863ba79edbac7ae78ad0e374a2988c816ad31a.tar.gz
ingen-c9863ba79edbac7ae78ad0e374a2988c816ad31a.tar.bz2
ingen-c9863ba79edbac7ae78ad0e374a2988c816ad31a.zip
WIP: Variant task
Diffstat (limited to 'src/server/Task.hpp')
-rw-r--r--src/server/Task.hpp52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/server/Task.hpp b/src/server/Task.hpp
index 99fe347d..25f76260 100644
--- a/src/server/Task.hpp
+++ b/src/server/Task.hpp
@@ -24,12 +24,55 @@
#include <memory>
#include <ostream>
+#include <boost/variant/variant.hpp>
+
namespace Ingen {
namespace Server {
class BlockImpl;
class RunContext;
+struct SingleTask;
+struct MultiTask;
+struct SeqTask;
+struct ParTask;
+
+using Task = boost::variant<SingleTask, SeqTask, ParTask>;
+
+using TaskChildren = std::deque<std::unique_ptr<Task>>;
+
+struct SingleTask {
+ BlockImpl* block; ///< Block to run
+};
+
+struct MultiTask {
+ /** Prepend a child to this task. */
+ template<typename... Args>
+ void emplace_front(Args... args) {
+ children.emplace_front(new Task(std::forward<Args>(args)...));
+ }
+
+ TaskChildren children; ///< Child tasks
+};
+
+struct SeqTask : MultiTask {
+};
+
+struct ParTask : MultiTask {
+ ParTask() = default;
+
+ ParTask(ParTask&& task)
+ : done_end(task.done_end)
+ , next(task.next.load())
+ , done(task.done.load())
+ {}
+
+ unsigned done_end{0}; ///< Index of rightmost done sub-task
+ std::atomic<unsigned> next{0}; ///< Index of next sub-task
+ std::atomic<bool> done{false}; ///< Completion phase
+};
+
+ #if 0
class Task {
public:
enum class Mode {
@@ -112,6 +155,15 @@ private:
std::atomic<bool> _done; ///< Completion phase
};
+#endif
+
+void run(Task& task, RunContext& context);
+
+std::unique_ptr<Task> simplify(std::unique_ptr<Task>&& task);
+
+/** Steal a child task from this task. */
+Task* steal(ParTask& task, RunContext& context);
+
} // namespace Server
} // namespace Ingen