summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/ThreadedLoader.cpp31
-rw-r--r--src/gui/ThreadedLoader.hpp9
2 files changed, 24 insertions, 16 deletions
diff --git a/src/gui/ThreadedLoader.cpp b/src/gui/ThreadedLoader.cpp
index f7c77c99..a6c9b1ed 100644
--- a/src/gui/ThreadedLoader.cpp
+++ b/src/gui/ThreadedLoader.cpp
@@ -32,8 +32,9 @@ namespace Ingen {
namespace GUI {
ThreadedLoader::ThreadedLoader(App& app, SharedPtr<Interface> engine)
- : Raul::Slave("Loader")
+ : Raul::Thread("Loader")
, _app(app)
+ , _sem(0)
, _engine(engine)
{
if (parser())
@@ -42,6 +43,12 @@ ThreadedLoader::ThreadedLoader(App& app, SharedPtr<Interface> engine)
warn << "Failed to load ingen_serialisation module, load disabled." << endl;
}
+ThreadedLoader::~ThreadedLoader()
+{
+ _exit_flag = true;
+ _sem.post();
+}
+
SharedPtr<Serialisation::Parser>
ThreadedLoader::parser()
{
@@ -54,16 +61,16 @@ ThreadedLoader::parser()
}
void
-ThreadedLoader::_whipped()
+ThreadedLoader::_run()
{
- _mutex.lock();
-
- while ( ! _events.empty() ) {
- _events.front()();
- _events.pop_front();
+ while (_sem.wait() && !_exit_flag) {
+ _mutex.lock();
+ while (!_events.empty()) {
+ _events.front()();
+ _events.pop_front();
+ }
+ _mutex.unlock();
}
-
- _mutex.unlock();
}
void
@@ -96,9 +103,8 @@ ThreadedLoader::load_patch(bool merge,
engine_symbol,
engine_data)));
- whip();
-
_mutex.unlock();
+ _sem.post();
}
void
@@ -112,8 +118,7 @@ ThreadedLoader::save_patch(SharedPtr<const Client::PatchModel> model,
model, filename)));
_mutex.unlock();
-
- whip();
+ _sem.post();
}
void
diff --git a/src/gui/ThreadedLoader.hpp b/src/gui/ThreadedLoader.hpp
index e7815eeb..273c72f9 100644
--- a/src/gui/ThreadedLoader.hpp
+++ b/src/gui/ThreadedLoader.hpp
@@ -27,7 +27,7 @@
#include "ingen/Interface.hpp"
#include "ingen/serialisation/Parser.hpp"
#include "ingen/serialisation/Serialiser.hpp"
-#include "raul/Slave.hpp"
+#include "raul/Semaphore.hpp"
#include "raul/Thread.hpp"
namespace Ingen {
@@ -44,12 +44,14 @@ namespace GUI {
*
* \ingroup GUI
*/
-class ThreadedLoader : public Raul::Slave
+class ThreadedLoader : public Raul::Thread
{
public:
ThreadedLoader(App& app,
SharedPtr<Interface> engine);
+ ~ThreadedLoader();
+
void load_patch(bool merge,
const Glib::ustring& document_uri,
boost::optional<Raul::Path> engine_parent,
@@ -68,9 +70,10 @@ private:
/** Returns nothing and takes no parameters (because they have all been bound) */
typedef sigc::slot<void> Closure;
- void _whipped();
+ void _run();
App& _app;
+ Raul::Semaphore _sem;
SharedPtr<Interface> _engine;
Glib::Mutex _mutex;
std::list<Closure> _events;