/* This file is part of Ingen. Copyright 2007-2017 David Robillard Ingen is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. Ingen is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for details. You should have received a copy of the GNU Affero General Public License along with Ingen. If not, see . */ #ifndef INGEN_ENGINE_WORK_HPP #define INGEN_ENGINE_WORK_HPP #include namespace Ingen { namespace Server { template class Work { public: enum class Mode { UNIT, ///< Single unit to run SEQUENTIAL, ///< Elements must be run sequentially in order PARALLEL ///< Elements may be run in any order in parallel }; static Work unit(Unit& unit) { return Work(Mode::UNIT, &unit); } static Work sequential() { return Work(Mode::SEQUENTIAL); } static Work parallel() { return Work(Mode::PARALLEL); } void prepend(Work&& work) { _children.emplace_back(std::move(work)); } Unit* unit() const { return _unit; } Mode mode() const { return _mode; } const std::vector& children() const { return _children; } private: Work(Mode mode, Unit* unit = nullptr) : _unit(unit), _mode(mode) {} std::vector _children; ///< Children in reverse execution order Unit* const _unit; ///< Used for UNIT mode only const Mode _mode; ///< Execution mode }; } // namespace Server } // namespace Ingen #endif // INGEN_ENGINE_WORK_HPP