summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-08-16 00:59:35 +0000
committerDavid Robillard <d@drobilla.net>2012-08-16 00:59:35 +0000
commitda4c1fcad194f4f3f399f6a4a731df34567c95ef (patch)
tree22c875232a4639f0f80d818e3a399e16c4ffe6ad /src/gui
parentd64815e24c043ac87b1504c5f02e93b11c4d8285 (diff)
downloadingen-da4c1fcad194f4f3f399f6a4a731df34567c95ef.tar.gz
ingen-da4c1fcad194f4f3f399f6a4a731df34567c95ef.tar.bz2
ingen-da4c1fcad194f4f3f399f6a4a731df34567c95ef.zip
Remove Raul::Slave class.
Merge Thread::stop() and Thread::join(). Clean thread shut down without the use of pthread_cancel(). git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@4708 a436a847-0d15-0410-975c-d299462d15a1
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;