diff options
author | David Robillard <d@drobilla.net> | 2018-11-24 13:44:03 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-11-24 13:44:03 +0100 |
commit | a7d83f19b08eb4c6f79a82fe60c2b86db13f4420 (patch) | |
tree | d9b620bfba1e7462df4ddb3f6225cc5216c0ca81 /src/gui/ThreadedLoader.cpp | |
parent | d63edc742cebd685f8a05936682210aa5c1e69a9 (diff) | |
download | ingen-a7d83f19b08eb4c6f79a82fe60c2b86db13f4420.tar.gz ingen-a7d83f19b08eb4c6f79a82fe60c2b86db13f4420.tar.bz2 ingen-a7d83f19b08eb4c6f79a82fe60c2b86db13f4420.zip |
Squashed 'waflib/' changes from 6e726eb1..5ea8f99f
5ea8f99f Improve test output spacing
0e23b29f Raise exception when test suite fails to ensure non-zero exit status
d6de073b Show run time of unit tests
5b655541 Add short configure option for ultra-strict flags
4687ba6d Use gtest-like test output
258903d9 Fix failure count in test group summaries
da07e738 Fix verbose tests with Python 3
git-subtree-dir: waflib
git-subtree-split: 5ea8f99f6e1246079c1fe6bb590c38a53aadd40d
Diffstat (limited to 'src/gui/ThreadedLoader.cpp')
-rw-r--r-- | src/gui/ThreadedLoader.cpp | 148 |
1 files changed, 0 insertions, 148 deletions
diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp deleted file mode 100644 index 7a80fa6e..00000000 --- a/src/gui/ThreadedLoader.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - This file is part of Ingen. - Copyright 2007-2015 David Robillard <http://drobilla.net/> - - 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 <http://www.gnu.org/licenses/>. -*/ - -#include <cassert> -#include <string> - -#include "ingen/Log.hpp" -#include "ingen/Module.hpp" -#include "ingen/World.hpp" -#include "ingen/client/GraphModel.hpp" - -#include "App.hpp" -#include "ThreadedLoader.hpp" - -using boost::optional; - -namespace Ingen { -namespace GUI { - -ThreadedLoader::ThreadedLoader(App& app, SPtr<Interface> engine) - : _app(app) - , _sem(0) - , _engine(std::move(engine)) - , _exit_flag(false) - , _thread(&ThreadedLoader::run, this) -{ - if (!parser()) { - app.log().warn("Parser unavailable, graph loading disabled\n"); - } -} - -ThreadedLoader::~ThreadedLoader() -{ - _exit_flag = true; - _sem.post(); - if (_thread.joinable()) { - _thread.join(); - } -} - -SPtr<Parser> -ThreadedLoader::parser() -{ - return _app.world()->parser(); -} - -void -ThreadedLoader::run() -{ - while (_sem.wait() && !_exit_flag) { - std::lock_guard<std::mutex> lock(_mutex); - while (!_events.empty()) { - _events.front()(); - _events.pop_front(); - } - } -} - -void -ThreadedLoader::load_graph(bool merge, - const FilePath& file_path, - optional<Raul::Path> engine_parent, - optional<Raul::Symbol> engine_symbol, - optional<Properties> engine_data) -{ - std::lock_guard<std::mutex> lock(_mutex); - - Glib::ustring engine_base = ""; - if (engine_parent) { - if (merge) { - engine_base = engine_parent.get(); - } else { - engine_base = engine_parent.get().base(); - } - } - - _events.push_back(sigc::hide_return( - sigc::bind(sigc::mem_fun(this, &ThreadedLoader::load_graph_event), - file_path, - engine_parent, - engine_symbol, - engine_data))); - - _sem.post(); -} - -void -ThreadedLoader::load_graph_event(const FilePath& file_path, - optional<Raul::Path> engine_parent, - optional<Raul::Symbol> engine_symbol, - optional<Properties> engine_data) -{ - std::lock_guard<std::mutex> lock(_app.world()->rdf_mutex()); - - _app.world()->parser()->parse_file(_app.world(), - _app.world()->interface().get(), - file_path, - engine_parent, - engine_symbol, - engine_data); -} - -void -ThreadedLoader::save_graph(SPtr<const Client::GraphModel> model, const URI& uri) -{ - std::lock_guard<std::mutex> lock(_mutex); - - _events.push_back(sigc::hide_return( - sigc::bind(sigc::mem_fun(this, &ThreadedLoader::save_graph_event), - model, - uri))); - - _sem.post(); -} - -void -ThreadedLoader::save_graph_event(SPtr<const Client::GraphModel> model, - const URI& uri) -{ - assert(uri.scheme() == "file"); - if (_app.serialiser()) { - std::lock_guard<std::mutex> lock(_app.world()->rdf_mutex()); - - if (uri.string().find(".ingen") != std::string::npos) { - _app.serialiser()->write_bundle(model, uri); - } else { - _app.serialiser()->start_to_file(model->path(), std::string(uri.path())); - _app.serialiser()->serialise(model); - _app.serialiser()->finish(); - } - } -} - -} // namespace GUI -} // namespace Ingen |