From 46c3a486eee4b2ef69d9cc4f9e2701082c64d7c8 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 4 Feb 2013 00:54:25 +0000 Subject: Replace Raul::thread with std::thread. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5047 a436a847-0d15-0410-975c-d299462d15a1 --- src/gui/ThreadedLoader.cpp | 12 ++++++------ src/gui/ThreadedLoader.hpp | 9 ++++++--- 2 files changed, 12 insertions(+), 9 deletions(-) (limited to 'src/gui') diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp index 597a728d..5c33c1de 100644 --- a/src/gui/ThreadedLoader.cpp +++ b/src/gui/ThreadedLoader.cpp @@ -31,14 +31,13 @@ namespace Ingen { namespace GUI { ThreadedLoader::ThreadedLoader(App& app, SPtr engine) - : Raul::Thread() - , _app(app) + : _app(app) , _sem(0) , _engine(engine) + , _exit_flag(false) + , _thread(&ThreadedLoader::run, this) { - if (parser()) { - start(); - } else { + if (!parser()) { app.log().warn("Parser unavailable, graph loading disabled\n"); } } @@ -47,6 +46,7 @@ ThreadedLoader::~ThreadedLoader() { _exit_flag = true; _sem.post(); + _thread.join(); } SPtr @@ -61,7 +61,7 @@ ThreadedLoader::parser() } void -ThreadedLoader::_run() +ThreadedLoader::run() { while (_sem.wait() && !_exit_flag) { _mutex.lock(); diff --git a/src/gui/ThreadedLoader.hpp b/src/gui/ThreadedLoader.hpp index 815cfeec..7f4de063 100644 --- a/src/gui/ThreadedLoader.hpp +++ b/src/gui/ThreadedLoader.hpp @@ -17,6 +17,8 @@ #ifndef INGEN_GUI_THREADEDLOADER_HPP #define INGEN_GUI_THREADEDLOADER_HPP +#include + #include #include #include @@ -28,7 +30,6 @@ #include "ingen/serialisation/Parser.hpp" #include "ingen/serialisation/Serialiser.hpp" #include "raul/Semaphore.hpp" -#include "raul/Thread.hpp" namespace Ingen { namespace GUI { @@ -44,7 +45,7 @@ namespace GUI { * * \ingroup GUI */ -class ThreadedLoader : public Raul::Thread +class ThreadedLoader { public: ThreadedLoader(App& app, @@ -70,13 +71,15 @@ private: /** Returns nothing and takes no parameters (because they have all been bound) */ typedef sigc::slot Closure; - void _run(); + void run(); App& _app; Raul::Semaphore _sem; SPtr _engine; Glib::Mutex _mutex; std::list _events; + bool _exit_flag; + std::thread _thread; }; } // namespace GUI -- cgit v1.2.1