Merge branch 'master' into cairocanvas
[ardour.git] / libs / pbd / pbd / abstract_ui.cc
index b300a62dd8e780e0d260e2750c1f2a7a64f1b5d1..d43bc64f6352a8e3071a6cbc525cdf89eebde418 100644 (file)
@@ -1,3 +1,22 @@
+/*
+    Copyright (C) 2012 Paul Davis 
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
 #include <unistd.h>
 #include <iostream>
 
@@ -11,9 +30,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 +44,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 +106,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 +119,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 +228,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 +341,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);
                }