summaryrefslogtreecommitdiff
path: root/libs/pbd
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2012-07-25 17:48:55 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2012-07-25 17:48:55 +0000
commit3cd8138a419cb165f56070ace0b21a1e63ec5a43 (patch)
tree51efe9abff24a1367be227aebf8e2901433b0b88 /libs/pbd
parenteb6e352dd0a307badf68ae4a216d15c03b4685de (diff)
convert from Glib:: to Glib::Threads for all thread-related API
git-svn-id: svn://localhost/ardour2/branches/3.0@13084 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/pbd')
-rw-r--r--libs/pbd/base_ui.cc6
-rw-r--r--libs/pbd/boost_debug.cc22
-rw-r--r--libs/pbd/controllable.cc10
-rw-r--r--libs/pbd/event_loop.cc8
-rw-r--r--libs/pbd/file_manager.cc8
-rw-r--r--libs/pbd/id.cc6
-rw-r--r--libs/pbd/pbd/abstract_ui.cc16
-rw-r--r--libs/pbd/pbd/abstract_ui.h10
-rw-r--r--libs/pbd/pbd/base_ui.h12
-rw-r--r--libs/pbd/pbd/controllable.h4
-rw-r--r--libs/pbd/pbd/event_loop.h6
-rw-r--r--libs/pbd/pbd/file_manager.h4
-rw-r--r--libs/pbd/pbd/id.h4
-rw-r--r--libs/pbd/pbd/pool.h12
-rw-r--r--libs/pbd/pbd/rcu.h6
-rw-r--r--libs/pbd/pbd/sndfile_manager.h2
-rw-r--r--libs/pbd/pbd/stacktrace.h12
-rw-r--r--libs/pbd/pbd/stateful.h2
-rw-r--r--libs/pbd/pool.cc37
-rw-r--r--libs/pbd/pthread_utils.cc4
-rw-r--r--libs/pbd/stateful.cc4
21 files changed, 87 insertions, 108 deletions
diff --git a/libs/pbd/base_ui.cc b/libs/pbd/base_ui.cc
index 14a3ef644d..a7e148c839 100644
--- a/libs/pbd/base_ui.cc
+++ b/libs/pbd/base_ui.cc
@@ -83,7 +83,7 @@ BaseUI::main_thread ()
bool
BaseUI::signal_running ()
{
- Glib::Mutex::Lock lm (_run_lock);
+ Glib::Threads::Mutex::Lock lm (_run_lock);
_running.signal ();
return false; // don't call it again
@@ -101,8 +101,8 @@ BaseUI::run ()
/* glibmm hack - drop the refptr to the IOSource now before it can hurt */
request_channel.drop_ios ();
- Glib::Mutex::Lock lm (_run_lock);
- run_loop_thread = Thread::create (mem_fun (*this, &BaseUI::main_thread), true);
+ Glib::Threads::Mutex::Lock lm (_run_lock);
+ run_loop_thread = Glib::Threads::Thread::create (mem_fun (*this, &BaseUI::main_thread));
_running.wait (_run_lock);
}
diff --git a/libs/pbd/boost_debug.cc b/libs/pbd/boost_debug.cc
index 3ddbc88e6d..26c8188bde 100644
--- a/libs/pbd/boost_debug.cc
+++ b/libs/pbd/boost_debug.cc
@@ -29,7 +29,7 @@
#include <map>
#include <set>
#include <vector>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
#include <boost/shared_ptr.hpp>
#include "pbd/stacktrace.h"
@@ -135,10 +135,10 @@ IPointerMap& interesting_pointers() {
return *_interesting_pointers;
}
-static Glib::Mutex* _the_lock;
-static Glib::Mutex& the_lock() {
+static Glib::Threads::Mutex* _the_lock;
+static Glib::Threads::Mutex& the_lock() {
if (_the_lock == 0) {
- _the_lock = new Glib::Mutex;
+ _the_lock = new Glib::Threads::Mutex;
}
return *_the_lock;
}
@@ -167,7 +167,7 @@ boost_debug_shared_ptr_show_live_debugging (bool yn)
void
boost_debug_shared_ptr_mark_interesting (void* ptr, const char* type)
{
- Glib::Mutex::Lock guard (the_lock());
+ Glib::Threads::Mutex::Lock guard (the_lock());
pair<void*,const char*> newpair (ptr, type);
interesting_pointers().insert (newpair);
if (debug_out) {
@@ -182,7 +182,7 @@ boost_debug_shared_ptr_operator_equals (void const *sp, void const *old_obj, int
return;
}
- Glib::Mutex::Lock guard (the_lock());
+ Glib::Threads::Mutex::Lock guard (the_lock());
if (is_interesting_object (old_obj) || is_interesting_object (obj)) {
if (debug_out) {
@@ -230,7 +230,7 @@ boost_debug_shared_ptr_reset (void const *sp, void const *old_obj, int old_use_c
return;
}
- Glib::Mutex::Lock guard (the_lock());
+ Glib::Threads::Mutex::Lock guard (the_lock());
if (is_interesting_object (old_obj) || is_interesting_object (obj)) {
if (debug_out) {
@@ -274,7 +274,7 @@ boost_debug_shared_ptr_reset (void const *sp, void const *old_obj, int old_use_c
void
boost_debug_shared_ptr_destructor (void const *sp, void const *obj, int use_count)
{
- Glib::Mutex::Lock guard (the_lock());
+ Glib::Threads::Mutex::Lock guard (the_lock());
PointerMap::iterator x = sptrs().find (sp);
if (x != sptrs().end()) {
@@ -289,7 +289,7 @@ void
boost_debug_shared_ptr_constructor (void const *sp, void const *obj, int use_count)
{
if (is_interesting_object (obj)) {
- Glib::Mutex::Lock guard (the_lock());
+ Glib::Threads::Mutex::Lock guard (the_lock());
pair<void const*, SPDebug*> newpair;
newpair.first = sp;
@@ -306,14 +306,14 @@ boost_debug_shared_ptr_constructor (void const *sp, void const *obj, int use_cou
void
boost_debug_count_ptrs ()
{
- Glib::Mutex::Lock guard (the_lock());
+ Glib::Threads::Mutex::Lock guard (the_lock());
// cerr << "Tracking " << interesting_pointers().size() << " interesting objects with " << sptrs().size () << " shared ptrs\n";
}
void
boost_debug_list_ptrs ()
{
- Glib::Mutex::Lock guard (the_lock());
+ Glib::Threads::Mutex::Lock guard (the_lock());
if (sptrs().empty()) {
cerr << "There are no dangling shared ptrs\n";
diff --git a/libs/pbd/controllable.cc b/libs/pbd/controllable.cc
index 82a8464c8b..42e015ac6f 100644
--- a/libs/pbd/controllable.cc
+++ b/libs/pbd/controllable.cc
@@ -34,7 +34,7 @@ PBD::Signal1<void,Controllable*> Controllable::StopLearning;
PBD::Signal3<void,Controllable*,int,int> Controllable::CreateBinding;
PBD::Signal1<void,Controllable*> Controllable::DeleteBinding;
-Glib::StaticRWLock Controllable::registry_lock = GLIBMM_STATIC_RW_LOCK_INIT;
+Glib::Threads::RWLock Controllable::registry_lock;
Controllable::Controllables Controllable::registry;
PBD::ScopedConnectionList* registry_connections = 0;
const std::string Controllable::xml_node_name = X_("Controllable");
@@ -52,7 +52,7 @@ Controllable::add (Controllable& ctl)
{
using namespace boost;
- Glib::RWLock::WriterLock lm (registry_lock);
+ Glib::Threads::RWLock::WriterLock lm (registry_lock);
registry.insert (&ctl);
if (!registry_connections) {
@@ -67,7 +67,7 @@ Controllable::add (Controllable& ctl)
void
Controllable::remove (Controllable* ctl)
{
- Glib::RWLock::WriterLock lm (registry_lock);
+ Glib::Threads::RWLock::WriterLock lm (registry_lock);
for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) {
if ((*i) == ctl) {
@@ -80,7 +80,7 @@ Controllable::remove (Controllable* ctl)
Controllable*
Controllable::by_id (const ID& id)
{
- Glib::RWLock::ReaderLock lm (registry_lock);
+ Glib::Threads::RWLock::ReaderLock lm (registry_lock);
for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) {
if ((*i)->id() == id) {
@@ -93,7 +93,7 @@ Controllable::by_id (const ID& id)
Controllable*
Controllable::by_name (const string& str)
{
- Glib::RWLock::ReaderLock lm (registry_lock);
+ Glib::Threads::RWLock::ReaderLock lm (registry_lock);
for (Controllables::iterator i = registry.begin(); i != registry.end(); ++i) {
if ((*i)->_name == str) {
diff --git a/libs/pbd/event_loop.cc b/libs/pbd/event_loop.cc
index 6950c045ff..77b08b9f73 100644
--- a/libs/pbd/event_loop.cc
+++ b/libs/pbd/event_loop.cc
@@ -4,10 +4,10 @@
using namespace PBD;
using namespace std;
-Glib::StaticPrivate<EventLoop> EventLoop::thread_event_loop;
-
static void do_not_delete_the_loop_pointer (void*) { }
+Glib::Threads::Private<EventLoop> EventLoop::thread_event_loop (do_not_delete_the_loop_pointer);
+
EventLoop*
EventLoop::get_event_loop_for_thread() {
return thread_event_loop.get ();
@@ -16,7 +16,7 @@ EventLoop::get_event_loop_for_thread() {
void
EventLoop::set_event_loop_for_thread (EventLoop* loop)
{
- thread_event_loop.set (loop, do_not_delete_the_loop_pointer);
+ thread_event_loop.set (loop);
}
void*
@@ -49,7 +49,7 @@ EventLoop::invalidate_request (void* data)
*/
if (ir->event_loop) {
- Glib::Mutex::Lock lm (ir->event_loop->slot_invalidation_mutex());
+ Glib::Threads::Mutex::Lock lm (ir->event_loop->slot_invalidation_mutex());
for (list<BaseRequestObject*>::iterator i = ir->requests.begin(); i != ir->requests.end(); ++i) {
(*i)->valid = false;
(*i)->invalidation = 0;
diff --git a/libs/pbd/file_manager.cc b/libs/pbd/file_manager.cc
index 29ef7d6e6e..a71ffca190 100644
--- a/libs/pbd/file_manager.cc
+++ b/libs/pbd/file_manager.cc
@@ -57,7 +57,7 @@ FileManager::FileManager ()
void
FileManager::add (FileDescriptor* d)
{
- Glib::Mutex::Lock lm (_mutex);
+ Glib::Threads::Mutex::Lock lm (_mutex);
_files.push_back (d);
}
@@ -65,7 +65,7 @@ FileManager::add (FileDescriptor* d)
bool
FileManager::allocate (FileDescriptor* d)
{
- Glib::Mutex::Lock lm (_mutex);
+ Glib::Threads::Mutex::Lock lm (_mutex);
if (!d->is_open()) {
@@ -131,7 +131,7 @@ FileManager::allocate (FileDescriptor* d)
void
FileManager::release (FileDescriptor* d)
{
- Glib::Mutex::Lock lm (_mutex);
+ Glib::Threads::Mutex::Lock lm (_mutex);
d->_refcount--;
assert (d->_refcount >= 0);
@@ -141,7 +141,7 @@ FileManager::release (FileDescriptor* d)
void
FileManager::remove (FileDescriptor* d)
{
- Glib::Mutex::Lock lm (_mutex);
+ Glib::Threads::Mutex::Lock lm (_mutex);
if (d->is_open ()) {
close (d);
diff --git a/libs/pbd/id.cc b/libs/pbd/id.cc
index 9b04c88e65..24cf02ab2e 100644
--- a/libs/pbd/id.cc
+++ b/libs/pbd/id.cc
@@ -31,14 +31,14 @@
using namespace std;
using namespace PBD;
-Glib::Mutex* ID::counter_lock = 0;
+Glib::Threads::Mutex* ID::counter_lock = 0;
uint64_t ID::_counter = 0;
void
ID::init ()
{
if (!counter_lock)
- counter_lock = new Glib::Mutex;
+ counter_lock = new Glib::Threads::Mutex;
}
ID::ID ()
@@ -59,7 +59,7 @@ ID::ID (string str)
void
ID::reset ()
{
- Glib::Mutex::Lock lm (*counter_lock);
+ Glib::Threads::Mutex::Lock lm (*counter_lock);
_id = _counter++;
}
diff --git a/libs/pbd/pbd/abstract_ui.cc b/libs/pbd/pbd/abstract_ui.cc
index b300a62dd8..8ebc12a433 100644
--- a/libs/pbd/pbd/abstract_ui.cc
+++ b/libs/pbd/pbd/abstract_ui.cc
@@ -11,9 +11,6 @@
using namespace std;
-template<typename R>
-Glib::StaticPrivate<typename AbstractUI<R>::RequestBuffer> AbstractUI<R>::per_thread_request_buffer;
-
template<typename RequestBuffer> void
cleanup_request_buffer (void* ptr)
{
@@ -28,11 +25,14 @@ cleanup_request_buffer (void* ptr)
{
- Glib::Mutex::Lock lm (rb->ui.request_buffer_map_lock);
+ Glib::Threads::Mutex::Lock lm (rb->ui.request_buffer_map_lock);
rb->dead = true;
}
}
+template<typename R>
+Glib::Threads::Private<typename AbstractUI<R>::RequestBuffer> AbstractUI<R>::per_thread_request_buffer (cleanup_request_buffer<AbstractUI<R>::RequestBuffer>);
+
template <typename RequestObject>
AbstractUI<RequestObject>::AbstractUI (const string& name)
: BaseUI (name)
@@ -87,7 +87,7 @@ AbstractUI<RequestObject>::register_thread (string target_gui, pthread_t thread_
only at thread initialization time, not repeatedly,
and so this is of little consequence.
*/
- Glib::Mutex::Lock lm (request_buffer_map_lock);
+ Glib::Threads::Mutex::Lock lm (request_buffer_map_lock);
request_buffers[thread_id] = b;
}
@@ -100,7 +100,7 @@ AbstractUI<RequestObject>::register_thread (string target_gui, pthread_t thread_
dead. it will then be deleted during a call to handle_ui_requests()
*/
- per_thread_request_buffer.set (b, cleanup_request_buffer<RequestBuffer>);
+ per_thread_request_buffer.set (b);
}
template <typename RequestObject> RequestObject*
@@ -209,7 +209,7 @@ AbstractUI<RequestObject>::handle_ui_requests ()
/* and now, the generic request buffer. same rules as above apply */
- Glib::Mutex::Lock lm (request_list_lock);
+ Glib::Threads::Mutex::Lock lm (request_list_lock);
while (!request_list.empty()) {
RequestObject* req = request_list.front ();
@@ -322,7 +322,7 @@ AbstractUI<RequestObject>::send_request (RequestObject *req)
single-reader/single-writer semantics
*/
DEBUG_TRACE (PBD::DEBUG::AbstractUI, string_compose ("%1/%2 send heap request type %3\n", name(), pthread_self(), req->type));
- Glib::Mutex::Lock lm (request_list_lock);
+ Glib::Threads::Mutex::Lock lm (request_list_lock);
request_list.push_back (req);
}
diff --git a/libs/pbd/pbd/abstract_ui.h b/libs/pbd/pbd/abstract_ui.h
index 7eb2320230..fb09dee5c2 100644
--- a/libs/pbd/pbd/abstract_ui.h
+++ b/libs/pbd/pbd/abstract_ui.h
@@ -24,7 +24,7 @@
#include <string>
#include <pthread.h>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
#include "pbd/receiver.h"
#include "pbd/ringbufferNPT.h"
@@ -42,9 +42,9 @@ class AbstractUI : public BaseUI
void register_thread (std::string, pthread_t, std::string, uint32_t num_requests);
void call_slot (EventLoop::InvalidationRecord*, const boost::function<void()>&);
- Glib::Mutex& slot_invalidation_mutex() { return request_buffer_map_lock; }
+ Glib::Threads::Mutex& slot_invalidation_mutex() { return request_buffer_map_lock; }
- Glib::Mutex request_buffer_map_lock;
+ Glib::Threads::Mutex request_buffer_map_lock;
protected:
struct RequestBuffer : public PBD::RingBufferNPT<RequestObject> {
@@ -60,9 +60,9 @@ class AbstractUI : public BaseUI
typedef std::map<pthread_t,RequestBuffer*> RequestBufferMap;
RequestBufferMap request_buffers;
- static Glib::StaticPrivate<RequestBuffer> per_thread_request_buffer;
+ static Glib::Threads::Private<RequestBuffer> per_thread_request_buffer;
- Glib::Mutex request_list_lock;
+ Glib::Threads::Mutex request_list_lock;
std::list<RequestObject*> request_list;
RequestObject* get_request (RequestType);
diff --git a/libs/pbd/pbd/base_ui.h b/libs/pbd/pbd/base_ui.h
index 65a9f27b49..186a3c55a6 100644
--- a/libs/pbd/pbd/base_ui.h
+++ b/libs/pbd/pbd/base_ui.h
@@ -26,7 +26,7 @@
#include <sigc++/slot.h>
#include <sigc++/trackable.h>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
#include <glibmm/main.h>
#include "pbd/crossthread.h"
@@ -50,8 +50,8 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop
BaseUI* base_instance() { return base_ui_instance; }
Glib::RefPtr<Glib::MainLoop> main_loop() const { return _main_loop; }
- Glib::Thread* event_loop_thread() const { return run_loop_thread; }
- bool caller_is_self () const { return Glib::Thread::self() == run_loop_thread; }
+ Glib::Threads::Thread* event_loop_thread() const { return run_loop_thread; }
+ bool caller_is_self () const { return Glib::Threads::Thread::self() == run_loop_thread; }
std::string name() const { return _name; }
@@ -75,9 +75,9 @@ class BaseUI : public sigc::trackable, public PBD::EventLoop
bool _ok;
Glib::RefPtr<Glib::MainLoop> _main_loop;
- Glib::Thread* run_loop_thread;
- Glib::Mutex _run_lock;
- Glib::Cond _running;
+ Glib::Threads::Thread* run_loop_thread;
+ Glib::Threads::Mutex _run_lock;
+ Glib::Threads::Cond _running;
/* this signals _running from within the event loop,
from an idle callback
diff --git a/libs/pbd/pbd/controllable.h b/libs/pbd/pbd/controllable.h
index b23cdc7e97..d9cd21d28d 100644
--- a/libs/pbd/pbd/controllable.h
+++ b/libs/pbd/pbd/controllable.h
@@ -25,7 +25,7 @@
#include <map>
#include "pbd/signals.h"
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
#include "pbd/statefuldestructible.h"
@@ -105,7 +105,7 @@ class Controllable : public PBD::StatefulDestructible {
static void remove (Controllable*);
typedef std::set<PBD::Controllable*> Controllables;
- static Glib::StaticRWLock registry_lock;
+ static Glib::Threads::RWLock registry_lock;
static Controllables registry;
};
diff --git a/libs/pbd/pbd/event_loop.h b/libs/pbd/pbd/event_loop.h
index 450bf5752f..b5ee9b8000 100644
--- a/libs/pbd/pbd/event_loop.h
+++ b/libs/pbd/pbd/event_loop.h
@@ -22,7 +22,7 @@
#include <boost/function.hpp>
#include <boost/bind.hpp> /* we don't need this here, but anything calling call_slot() probably will, so this is convenient */
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
namespace PBD
{
@@ -69,13 +69,13 @@ class EventLoop
};
virtual void call_slot (InvalidationRecord*, const boost::function<void()>&) = 0;
- virtual Glib::Mutex& slot_invalidation_mutex() = 0;
+ virtual Glib::Threads::Mutex& slot_invalidation_mutex() = 0;
static EventLoop* get_event_loop_for_thread();
static void set_event_loop_for_thread (EventLoop* ui);
private:
- static Glib::StaticPrivate<EventLoop> thread_event_loop;
+ static Glib::Threads::Private<EventLoop> thread_event_loop;
};
diff --git a/libs/pbd/pbd/file_manager.h b/libs/pbd/pbd/file_manager.h
index 01c9a8ee31..14552f9fef 100644
--- a/libs/pbd/pbd/file_manager.h
+++ b/libs/pbd/pbd/file_manager.h
@@ -24,7 +24,7 @@
#include <string>
#include <map>
#include <list>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
#include "pbd/signals.h"
namespace PBD {
@@ -145,7 +145,7 @@ private:
void close (FileDescriptor *);
std::list<FileDescriptor*> _files; ///< files we know about
- Glib::Mutex _mutex; ///< mutex for _files, _open and FileDescriptor contents
+ Glib::Threads::Mutex _mutex; ///< mutex for _files, _open and FileDescriptor contents
int _open; ///< number of open files
int _max_open; ///< maximum number of open files
};
diff --git a/libs/pbd/pbd/id.h b/libs/pbd/pbd/id.h
index 6296fc2981..6a9332be53 100644
--- a/libs/pbd/pbd/id.h
+++ b/libs/pbd/pbd/id.h
@@ -23,7 +23,7 @@
#include <stdint.h>
#include <string>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
namespace PBD {
@@ -63,7 +63,7 @@ class ID {
uint64_t _id;
int string_assign (std::string);
- static Glib::Mutex* counter_lock;
+ static Glib::Threads::Mutex* counter_lock;
static uint64_t _counter;
};
diff --git a/libs/pbd/pbd/pool.h b/libs/pbd/pbd/pool.h
index ab06343b4a..fc8454cee7 100644
--- a/libs/pbd/pbd/pool.h
+++ b/libs/pbd/pbd/pool.h
@@ -23,7 +23,7 @@
#include <vector>
#include <string>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
#include "pbd/ringbuffer.h"
@@ -59,7 +59,7 @@ class SingleAllocMultiReleasePool : public Pool
virtual void release (void *);
private:
- Glib::Mutex* m_lock;
+ Glib::Threads::Mutex m_lock;
};
@@ -73,7 +73,7 @@ class MultiAllocSingleReleasePool : public Pool
virtual void release (void *);
private:
- Glib::Mutex* m_lock;
+ Glib::Threads::Mutex m_lock;
};
class PerThreadPool;
@@ -106,7 +106,7 @@ class PerThreadPool
public:
PerThreadPool ();
- GPrivate* key() const { return _key; }
+ const Glib::Threads::Private<CrossThreadPool>& key() const { return _key; }
void create_per_thread_pool (std::string name, unsigned long item_size, unsigned long nitems);
CrossThreadPool* per_thread_pool ();
@@ -115,13 +115,13 @@ class PerThreadPool
void add_to_trash (CrossThreadPool *);
private:
- GPrivate* _key;
+ Glib::Threads::Private<CrossThreadPool> _key;
std::string _name;
unsigned long _item_size;
unsigned long _nitems;
/** mutex to protect either changes to the _trash variable, or writes to the RingBuffer */
- Glib::Mutex _trash_mutex;
+ Glib::Threads::Mutex _trash_mutex;
RingBuffer<CrossThreadPool*>* _trash;
};
diff --git a/libs/pbd/pbd/rcu.h b/libs/pbd/pbd/rcu.h
index 7b05346294..909954fc0e 100644
--- a/libs/pbd/pbd/rcu.h
+++ b/libs/pbd/pbd/rcu.h
@@ -21,7 +21,7 @@
#define __pbd_rcu_h__
#include "boost/shared_ptr.hpp"
-#include "glibmm/thread.h"
+#include "glibmm/threads.h"
#include <list>
@@ -187,12 +187,12 @@ public:
}
void flush () {
- Glib::Mutex::Lock lm (m_lock);
+ Glib::Threads::Mutex::Lock lm (m_lock);
m_dead_wood.clear ();
}
private:
- Glib::Mutex m_lock;
+ Glib::Threads::Mutex m_lock;
boost::shared_ptr<T>* current_write_old;
std::list<boost::shared_ptr<T> > m_dead_wood;
};
diff --git a/libs/pbd/pbd/sndfile_manager.h b/libs/pbd/pbd/sndfile_manager.h
index 8fd155111b..2167cadf5f 100644
--- a/libs/pbd/pbd/sndfile_manager.h
+++ b/libs/pbd/pbd/sndfile_manager.h
@@ -24,7 +24,7 @@
#include <string>
#include <map>
#include <sndfile.h>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
#include "pbd/signals.h"
#include "pbd/file_manager.h"
diff --git a/libs/pbd/pbd/stacktrace.h b/libs/pbd/pbd/stacktrace.h
index 40275fd536..94d07cab96 100644
--- a/libs/pbd/pbd/stacktrace.h
+++ b/libs/pbd/pbd/stacktrace.h
@@ -26,7 +26,7 @@
#include <iostream>
#include <ostream>
-#include <glibmm/thread.h>
+#include <glibmm/threads.h>
#include <list>
#ifdef HAVE_EXECINFO
@@ -50,7 +50,7 @@ class thing_with_backtrace
#else
allocation_backtrace_size = 0;
#endif
- Glib::Mutex::Lock lm (all_mutex);
+ Glib::Threads::Mutex::Lock lm (all_mutex);
all.push_back (this);
}
@@ -62,7 +62,7 @@ class thing_with_backtrace
#else
allocation_backtrace_size = 0;
#endif
- Glib::Mutex::Lock lm (all_mutex);
+ Glib::Threads::Mutex::Lock lm (all_mutex);
all.push_back (this);
}
@@ -70,7 +70,7 @@ class thing_with_backtrace
if (allocation_backtrace_size) {
delete [] allocation_backtrace;
}
- Glib::Mutex::Lock lm (all_mutex);
+ Glib::Threads::Mutex::Lock lm (all_mutex);
all.remove (this);
}
@@ -105,11 +105,11 @@ private:
void** allocation_backtrace;
int allocation_backtrace_size;
static std::list<thing_with_backtrace<T>* > all;
- static Glib::StaticMutex all_mutex;
+ static Glib::Threads::Mutex all_mutex;
};
template<typename T> std::list<PBD::thing_with_backtrace<T> *> PBD::thing_with_backtrace<T>::all;
-template<typename T> Glib::StaticMutex PBD::thing_with_backtrace<T>::all_mutex = GLIBMM_STATIC_MUTEX_INIT;
+template<typename T> Glib::Threads::Mutex PBD::thing_with_backtrace<T>::all_mutex;
} // namespace PBD
diff --git a/libs/pbd/pbd/stateful.h b/libs/pbd/pbd/stateful.h
index 36c6fe28c7..154e806644 100644
--- a/libs/pbd/pbd/stateful.h
+++ b/libs/pbd/pbd/stateful.h
@@ -110,7 +110,7 @@ class Stateful {
XMLNode *_extra_xml;
XMLNode *_instant_xml;
PBD::PropertyChange _pending_changed;
- Glib::Mutex _lock;
+ Glib::Threads::Mutex _lock;
std::string _xml_node_name; ///< name of node to use for this object in XML
OwnedPropertyList* _properties;
diff --git a/libs/pbd/pool.cc b/libs/pbd/pool.cc
index 0fc542f1dd..7b24625727 100644
--- a/libs/pbd/pool.cc
+++ b/libs/pbd/pool.cc
@@ -87,37 +87,27 @@ Pool::release (void *ptr)
MultiAllocSingleReleasePool::MultiAllocSingleReleasePool (string n, unsigned long isize, unsigned long nitems)
: Pool (n, isize, nitems)
- , m_lock(0)
{
}
MultiAllocSingleReleasePool::~MultiAllocSingleReleasePool ()
{
- delete m_lock;
}
SingleAllocMultiReleasePool::SingleAllocMultiReleasePool (string n, unsigned long isize, unsigned long nitems)
: Pool (n, isize, nitems)
- , m_lock(0)
{
}
SingleAllocMultiReleasePool::~SingleAllocMultiReleasePool ()
{
- delete m_lock;
}
void*
MultiAllocSingleReleasePool::alloc ()
{
void *ptr;
- if(!m_lock) {
- m_lock = new Glib::Mutex();
- // umm, I'm not sure that this doesn't also allocate memory.
- if(!m_lock) error << "cannot create Glib::Mutex in pool.cc" << endmsg;
- }
-
- Glib::Mutex::Lock guard(*m_lock);
+ Glib::Threads::Mutex::Lock guard (m_lock);
ptr = Pool::alloc ();
return ptr;
}
@@ -137,12 +127,7 @@ SingleAllocMultiReleasePool::alloc ()
void
SingleAllocMultiReleasePool::release (void* ptr)
{
- if(!m_lock) {
- m_lock = new Glib::Mutex();
- // umm, I'm not sure that this doesn't also allocate memory.
- if(!m_lock) error << "cannot create Glib::Mutex in pool.cc" << endmsg;
- }
- Glib::Mutex::Lock guard(*m_lock);
+ Glib::Threads::Mutex::Lock guard (m_lock);
Pool::release (ptr);
}
@@ -173,14 +158,9 @@ free_per_thread_pool (void* ptr)
}
PerThreadPool::PerThreadPool ()
- : _trash (0)
+ : _key (free_per_thread_pool)
+ , _trash (0)
{
- {
- /* for some reason this appears necessary to get glib's thread private stuff to work */
- g_private_new (NULL);
- }
-
- _key = g_private_new (free_per_thread_pool);
}
/** Create a new CrossThreadPool and set the current thread's private _key to point to it.
@@ -191,8 +171,7 @@ PerThreadPool::PerThreadPool ()
void
PerThreadPool::create_per_thread_pool (string n, unsigned long isize, unsigned long nitems)
{
- CrossThreadPool* p = new CrossThreadPool (n, isize, nitems, this);
- g_private_set (_key, p);
+ _key.set (new CrossThreadPool (n, isize, nitems, this));
}
/** @return CrossThreadPool for the current thread, which must previously have been created by
@@ -201,7 +180,7 @@ PerThreadPool::create_per_thread_pool (string n, unsigned long isize, unsigned l
CrossThreadPool*
PerThreadPool::per_thread_pool ()
{
- CrossThreadPool* p = static_cast<CrossThreadPool*> (g_private_get (_key));
+ CrossThreadPool* p = _key.get();
if (!p) {
fatal << "programming error: no per-thread pool \"" << _name << "\" for thread " << pthread_self() << endmsg;
/*NOTREACHED*/
@@ -212,7 +191,7 @@ PerThreadPool::per_thread_pool ()
void
PerThreadPool::set_trash (RingBuffer<CrossThreadPool*>* t)
{
- Glib::Mutex::Lock lm (_trash_mutex);
+ Glib::Threads::Mutex::Lock lm (_trash_mutex);
_trash = t;
}
@@ -220,7 +199,7 @@ PerThreadPool::set_trash (RingBuffer<CrossThreadPool*>* t)
void
PerThreadPool::add_to_trash (CrossThreadPool* p)
{
- Glib::Mutex::Lock lm (_trash_mutex);
+ Glib::Threads::Mutex::Lock lm (_trash_mutex);
if (!_trash) {
warning << "Pool " << p->name() << " has no trash collector; a memory leak has therefore occurred" << endmsg;
diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc
index 92d92da592..e8b5e2690d 100644
--- a/libs/pbd/pthread_utils.cc
+++ b/libs/pbd/pthread_utils.cc
@@ -33,7 +33,7 @@ using namespace std;
typedef std::set<pthread_t> ThreadMap;
static ThreadMap all_threads;
static pthread_mutex_t thread_map_lock = PTHREAD_MUTEX_INITIALIZER;
-static Glib::StaticPrivate<char> thread_name;
+static Glib::Threads::Private<char> thread_name (free);
namespace PBD {
PBD::Signal4<void,std::string, pthread_t,std::string,uint32_t> ThreadCreatedWithRequestSize;
@@ -108,7 +108,7 @@ pthread_set_name (const char *str)
{
/* copy string and delete it when exiting */
- thread_name.set (strdup (str), free);
+ thread_name.set (strdup (str));
}
const char *
diff --git a/libs/pbd/stateful.cc b/libs/pbd/stateful.cc
index 3e8cd267a5..105af75861 100644
--- a/libs/pbd/stateful.cc
+++ b/libs/pbd/stateful.cc
@@ -278,7 +278,7 @@ Stateful::send_change (const PropertyChange& what_changed)
}
{
- Glib::Mutex::Lock lm (_lock);
+ Glib::Threads::Mutex::Lock lm (_lock);
if (property_changes_suspended ()) {
_pending_changed.add (what_changed);
return;
@@ -300,7 +300,7 @@ Stateful::resume_property_changes ()
PropertyChange what_changed;
{
- Glib::Mutex::Lock lm (_lock);
+ Glib::Threads::Mutex::Lock lm (_lock);
if (property_changes_suspended() && g_atomic_int_dec_and_test (&_stateful_frozen) == FALSE) {
return;