summaryrefslogtreecommitdiff
path: root/libs/pbd/pbd/mutex.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/pbd/pbd/mutex.h')
-rw-r--r--libs/pbd/pbd/mutex.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/libs/pbd/pbd/mutex.h b/libs/pbd/pbd/mutex.h
new file mode 100644
index 0000000000..60d915fa35
--- /dev/null
+++ b/libs/pbd/pbd/mutex.h
@@ -0,0 +1,16 @@
+#include <glibmm/thread.h>
+#include <iostream>
+
+class PBDMutex : public Glib::Mutex
+{
+ public:
+ PBDMutex() : Glib::Mutex() {}
+ ~PBDMutex() {
+ if (trylock()) {
+ unlock ();
+ } else {
+ std::cerr << "Mutex @ " << this << " locked during destructor\n";
+ unlock ();
+ }
+ }
+};