summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2015-02-06 22:55:30 +0000
committerDavid Robillard <d@drobilla.net>2015-02-06 22:55:30 +0000
commit10669b73136183f70057917af311dadad46588b7 (patch)
tree6d81c015f9ab292f5d21b219504f28fdb027630f
parent8fb76ad09c062055170666de28661bd9da25f98e (diff)
downloadingen-10669b73136183f70057917af311dadad46588b7.tar.gz
ingen-10669b73136183f70057917af311dadad46588b7.tar.bz2
ingen-10669b73136183f70057917af311dadad46588b7.zip
Remove gthread dependency from engine.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5533 a436a847-0d15-0410-975c-d299462d15a1
-rw-r--r--ingen/Store.hpp8
-rw-r--r--src/server/events/Connect.cpp34
-rw-r--r--src/server/events/Delete.cpp8
-rw-r--r--src/server/events/Delete.hpp2
-rw-r--r--src/server/events/Delta.cpp15
-rw-r--r--src/server/events/Delta.hpp2
-rw-r--r--src/server/events/Disconnect.cpp4
-rw-r--r--src/server/events/DisconnectAll.cpp5
-rw-r--r--src/server/events/Get.cpp4
-rw-r--r--src/server/events/Move.cpp4
-rw-r--r--src/server/ingen_lv2.cpp28
-rw-r--r--src/server/wscript17
12 files changed, 61 insertions, 70 deletions
diff --git a/ingen/Store.hpp b/ingen/Store.hpp
index 33a7f2ea..4856ff4e 100644
--- a/ingen/Store.hpp
+++ b/ingen/Store.hpp
@@ -18,9 +18,7 @@
#define INGEN_STORE_HPP
#include <map>
-
-#undef nil
-#include <glibmm/thread.h>
+#include <mutex>
#include "raul/Deletable.hpp"
#include "raul/Noncopyable.hpp"
@@ -72,10 +70,10 @@ public:
const Raul::Symbol& symbol,
bool allow_zero=true);
- Glib::RWLock& lock() { return _lock; }
+ std::mutex& mutex() { return _mutex; }
private:
- Glib::RWLock _lock;
+ std::mutex _mutex;
};
} // namespace Ingen
diff --git a/src/server/events/Connect.cpp b/src/server/events/Connect.cpp
index 13faabd4..1b11702f 100644
--- a/src/server/events/Connect.cpp
+++ b/src/server/events/Connect.cpp
@@ -14,8 +14,6 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <glibmm/thread.h>
-
#include "ingen/Store.hpp"
#include "raul/Maid.hpp"
#include "raul/Path.hpp"
@@ -52,7 +50,7 @@ Connect::Connect(Engine& engine,
bool
Connect::pre_process()
{
- Glib::RWLock::ReaderLock rlock(_engine.store()->lock());
+ std::unique_lock<std::mutex> lock(_engine.store()->mutex());
Node* tail = _engine.store()->get(_tail_path);
if (!tail) {
@@ -108,26 +106,22 @@ Connect::pre_process()
_arc = SPtr<ArcImpl>(new ArcImpl(tail_output, _head));
- rlock.release();
+ /* Need to be careful about graph port arcs here and adding a
+ block's parent as a dependant/provider, or adding a graph as its own
+ provider...
+ */
+ if (tail_block != head_block && tail_block->parent() == head_block->parent()) {
+ head_block->providers().push_back(tail_block);
+ tail_block->dependants().push_back(head_block);
+ }
- {
- Glib::RWLock::ReaderLock wlock(_engine.store()->lock());
+ _graph->add_arc(_arc);
+ _head->increment_num_arcs();
- /* Need to be careful about graph port arcs here and adding a
- block's parent as a dependant/provider, or adding a graph as its own
- provider...
- */
- if (tail_block != head_block && tail_block->parent() == head_block->parent()) {
- head_block->providers().push_back(tail_block);
- tail_block->dependants().push_back(head_block);
- }
+ tail_output->inherit_neighbour(_head, _tail_remove, _tail_add);
+ _head->inherit_neighbour(tail_output, _head_remove, _head_add);
- _graph->add_arc(_arc);
- _head->increment_num_arcs();
-
- tail_output->inherit_neighbour(_head, _tail_remove, _tail_add);
- _head->inherit_neighbour(tail_output, _head_remove, _head_add);
- }
+ lock.unlock();
_voices = new Raul::Array<PortImpl::Voice>(_head->poly());
_head->get_buffers(*_engine.buffer_factory(),
diff --git a/src/server/events/Delete.cpp b/src/server/events/Delete.cpp
index 993530a8..2d324515 100644
--- a/src/server/events/Delete.cpp
+++ b/src/server/events/Delete.cpp
@@ -45,7 +45,7 @@ Delete::Delete(Engine& engine,
, _ports_array(NULL)
, _compiled_graph(NULL)
, _disconnect_event(NULL)
- , _lock(engine.store()->lock(), Glib::NOT_LOCK)
+ , _lock(engine.store()->mutex(), std::defer_lock)
{
if (Node::uri_is_path(uri)) {
_path = Node::uri_to_path(uri);
@@ -84,7 +84,7 @@ Delete::pre_process()
return Event::pre_process_done(Status::INTERNAL_ERROR, _path);
}
- _lock.acquire();
+ _lock.lock();
_engine.store()->remove(iter, _removed_objects);
@@ -145,8 +145,8 @@ Delete::execute(ProcessContext& context)
void
Delete::post_process()
{
- if (_lock.locked()) {
- _lock.release();
+ if (_lock.owns_lock()) {
+ _lock.unlock();
}
_removed_bindings.reset();
diff --git a/src/server/events/Delete.hpp b/src/server/events/Delete.hpp
index 3cf9a2dc..dc695ab8 100644
--- a/src/server/events/Delete.hpp
+++ b/src/server/events/Delete.hpp
@@ -82,7 +82,7 @@ private:
SPtr<ControlBindings::Bindings> _removed_bindings;
Store::Objects _removed_objects;
- Glib::RWLock::WriterLock _lock;
+ std::unique_lock<std::mutex> _lock;
};
} // namespace Events
diff --git a/src/server/events/Delta.cpp b/src/server/events/Delta.cpp
index f1acbdc2..23285b9b 100644
--- a/src/server/events/Delta.cpp
+++ b/src/server/events/Delta.cpp
@@ -15,8 +15,7 @@
*/
#include <vector>
-
-#include <glibmm/thread.h>
+#include <thread>
#include "ingen/Store.hpp"
#include "ingen/URIs.hpp"
@@ -63,7 +62,7 @@ Delta::Delta(Engine& engine,
, _compiled_graph(NULL)
, _context(context)
, _type(type)
- , _poly_lock(engine.store()->lock(), Glib::NOT_LOCK)
+ , _poly_lock(engine.store()->mutex(), std::defer_lock)
{
if (context != Resource::Graph::DEFAULT) {
for (auto& p : _properties) {
@@ -107,7 +106,7 @@ Delta::pre_process()
bool poly_changed = false;
// Take a writer lock while we modify the store
- Glib::RWLock::WriterLock lock(_engine.store()->lock());
+ std::unique_lock<std::mutex> lock(_engine.store()->mutex());
_object = is_graph_object
? static_cast<Ingen::Resource*>(_engine.store()->get(Node::uri_to_path(_subject)))
@@ -279,8 +278,8 @@ Delta::pre_process()
}
if (poly_changed) {
- lock.release();
- _poly_lock.acquire();
+ lock.unlock();
+ _poly_lock.lock();
}
return Event::pre_process_done(
@@ -377,8 +376,8 @@ Delta::execute(ProcessContext& context)
void
Delta::post_process()
{
- if (_poly_lock.locked()) {
- _poly_lock.release();
+ if (_poly_lock.owns_lock()) {
+ _poly_lock.unlock();
}
Broadcaster::Transfer t(*_engine.broadcaster());
diff --git a/src/server/events/Delta.hpp b/src/server/events/Delta.hpp
index a8e8ed0b..45de197e 100644
--- a/src/server/events/Delta.hpp
+++ b/src/server/events/Delta.hpp
@@ -119,7 +119,7 @@ private:
SPtr<ControlBindings::Bindings> _old_bindings;
- Glib::RWLock::WriterLock _poly_lock; ///< Long-term lock for poly changes
+ std::unique_lock<std::mutex> _poly_lock; ///< Long-term lock for poly changes
};
} // namespace Events
diff --git a/src/server/events/Disconnect.cpp b/src/server/events/Disconnect.cpp
index e0931f59..39b5da00 100644
--- a/src/server/events/Disconnect.cpp
+++ b/src/server/events/Disconnect.cpp
@@ -16,8 +16,6 @@
#include <list>
-#include <glibmm/thread.h>
-
#include "ingen/Store.hpp"
#include "raul/Maid.hpp"
#include "raul/Path.hpp"
@@ -111,7 +109,7 @@ Disconnect::Impl::Impl(Engine& e,
bool
Disconnect::pre_process()
{
- Glib::RWLock::WriterLock lock(_engine.store()->lock());
+ std::unique_lock<std::mutex> lock(_engine.store()->mutex());
if (_tail_path.parent().parent() != _head_path.parent().parent()
&& _tail_path.parent() != _head_path.parent().parent()
diff --git a/src/server/events/DisconnectAll.cpp b/src/server/events/DisconnectAll.cpp
index ef876ffe..22560c7e 100644
--- a/src/server/events/DisconnectAll.cpp
+++ b/src/server/events/DisconnectAll.cpp
@@ -17,7 +17,6 @@
#include <set>
#include <boost/format.hpp>
-#include <glibmm/thread.h>
#include "ingen/Store.hpp"
#include "raul/Array.hpp"
@@ -82,10 +81,10 @@ DisconnectAll::~DisconnectAll()
bool
DisconnectAll::pre_process()
{
- Glib::RWLock::WriterLock lock(_engine.store()->lock(), Glib::NOT_LOCK);
+ std::unique_lock<std::mutex> lock(_engine.store()->mutex(), std::defer_lock);
if (!_deleting) {
- lock.acquire();
+ lock.lock();
_parent = dynamic_cast<GraphImpl*>(_engine.store()->get(_parent_path));
if (!_parent) {
diff --git a/src/server/events/Get.cpp b/src/server/events/Get.cpp
index 6269aa2a..c984e576 100644
--- a/src/server/events/Get.cpp
+++ b/src/server/events/Get.cpp
@@ -16,8 +16,6 @@
#include <utility>
-#include <glibmm/thread.h>
-
#include "ingen/Interface.hpp"
#include "ingen/Node.hpp"
#include "ingen/Store.hpp"
@@ -116,7 +114,7 @@ Get::Get(Engine& engine,
bool
Get::pre_process()
{
- Glib::RWLock::ReaderLock lock(_engine.store()->lock());
+ std::unique_lock<std::mutex> lock(_engine.store()->mutex());
if (_uri == "ingen:/plugins") {
_plugins = _engine.block_factory()->plugins();
diff --git a/src/server/events/Move.cpp b/src/server/events/Move.cpp
index 44939525..9da77bc8 100644
--- a/src/server/events/Move.cpp
+++ b/src/server/events/Move.cpp
@@ -14,8 +14,6 @@
along with Ingen. If not, see <http://www.gnu.org/licenses/>.
*/
-#include <glibmm/thread.h>
-
#include "ingen/Store.hpp"
#include "raul/Path.hpp"
@@ -50,7 +48,7 @@ Move::~Move()
bool
Move::pre_process()
{
- Glib::RWLock::WriterLock lock(_engine.store()->lock());
+ std::unique_lock<std::mutex> lock(_engine.store()->mutex());
if (!_old_path.parent().is_parent_of(_new_path)) {
return Event::pre_process_done(Status::PARENT_DIFFERS, _new_path);
diff --git a/src/server/ingen_lv2.cpp b/src/server/ingen_lv2.cpp
index 70642298..56f106cb 100644
--- a/src/server/ingen_lv2.cpp
+++ b/src/server/ingen_lv2.cpp
@@ -20,11 +20,6 @@
#include <thread>
#include <vector>
-#include <glib.h>
-#include <glibmm/convert.h>
-#include <glibmm/miscutils.h>
-#include <glibmm/timer.h>
-
#include "lv2/lv2plug.in/ns/ext/atom/util.h"
#include "lv2/lv2plug.in/ns/ext/buf-size/buf-size.h"
#include "lv2/lv2plug.in/ns/ext/log/log.h"
@@ -447,7 +442,7 @@ struct IngenPlugin {
};
static Lib::Graphs
-find_graphs(const Glib::ustring& manifest_uri)
+find_graphs(const std::string& manifest_uri)
{
Sord::World world;
const Sord::URI base(world, manifest_uri);
@@ -512,14 +507,14 @@ ingen_instantiate(const LV2_Descriptor* descriptor,
lv2_log_error(&logger, "host did not provide URI unmap feature\n");
return NULL;
}
-
- if (!Glib::thread_supported()) {
- Glib::thread_init();
- }
set_bundle_path(bundle_path);
- Lib::Graphs graphs = find_graphs(
- Glib::filename_to_uri(Ingen::bundle_file_path("manifest.ttl")));
+ const std::string manifest_path = Ingen::bundle_file_path("manifest.ttl");
+ SerdNode manifest_node = serd_node_new_file_uri(
+ (const uint8_t*)manifest_path.c_str(), NULL, NULL, true);
+
+ Lib::Graphs graphs = find_graphs((const char*)manifest_node.buf);
+ serd_node_free(&manifest_node);
const LV2Graph* graph = NULL;
for (const auto& g : graphs) {
@@ -798,8 +793,13 @@ LV2Graph::LV2Graph(const std::string& u, const std::string& f)
Lib::Lib(const char* bundle_path)
{
Ingen::set_bundle_path(bundle_path);
- graphs = find_graphs(
- Glib::filename_to_uri(Ingen::bundle_file_path("manifest.ttl")));
+ const std::string manifest_path = Ingen::bundle_file_path("manifest.ttl");
+ SerdNode manifest_node = serd_node_new_file_uri(
+ (const uint8_t*)manifest_path.c_str(), NULL, NULL, true);
+
+ graphs = find_graphs((const char*)manifest_node.buf);
+
+ serd_node_free(&manifest_node);
}
static void
diff --git a/src/server/wscript b/src/server/wscript
index 2ab1dfe9..76362fa5 100644
--- a/src/server/wscript
+++ b/src/server/wscript
@@ -53,8 +53,10 @@ def build(bld):
name = 'libingen_server',
target = 'ingen_server',
install_path = '${LIBDIR}',
- use = 'libingen')
- core_libs = 'GLIBMM GTHREAD LV2 LILV RAUL SERD SORD'
+ use = 'libingen',
+ cxxflags = bld.env.PTHREAD_CFLAGS,
+ linkflags = bld.env.PTHREAD_LINKFLAGS)
+ core_libs = 'GLIBMM LV2 LILV RAUL SERD SORD'
autowaf.use_lib(bld, obj, core_libs)
if bld.env.BUILD_TESTS:
@@ -67,7 +69,8 @@ def build(bld):
install_path = '${LIBDIR}',
use = 'libingen_profiled',
lib = bld.env.INGEN_TEST_LIBS,
- cxxflags = bld.env.INGEN_TEST_CXXFLAGS)
+ cxxflags = bld.env.PTHREAD_CFLAGS + bld.env.INGEN_TEST_CXXFLAGS,
+ linkflags = bld.env.PTHREAD_LINKFLAGS)
autowaf.use_lib(bld, obj, core_libs)
if bld.env.HAVE_JACK:
@@ -77,7 +80,9 @@ def build(bld):
name = 'libingen_jack',
target = 'ingen_jack',
install_path = '${LIBDIR}',
- use = 'libingen_server')
+ use = 'libingen_server',
+ cxxflags = bld.env.PTHREAD_CFLAGS,
+ linkflags = bld.env.PTHREAD_LINKFLAGS)
autowaf.use_lib(bld, obj, core_libs + ' JACK')
# Ingen LV2 wrapper
@@ -87,5 +92,7 @@ def build(bld):
name = 'libingen_lv2',
target = 'ingen_lv2',
install_path = '${LV2DIR}/ingen.lv2/',
- use = 'libingen libingen_server')
+ use = 'libingen libingen_server',
+ cxxflags = bld.env.PTHREAD_CFLAGS,
+ linkflags = bld.env.PTHREAD_LINKFLAGS)
autowaf.use_lib(bld, obj, core_libs)