fix merge conflicts from master
[ardour.git] / libs / pbd / pthread_utils.cc
index 3d3cb96fb5cb313f31df83bda7cc3e9229e26057..b8ca8fc09346274d7dd441ae68d1e0671e7c8534 100644 (file)
 #include <fst.h>
 #endif
 
+#ifdef COMPILER_MSVC
+DECLARE_DEFAULT_COMPARISONS(pthread_t)  // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be
+                                        // searched and sorted. Thus, when instantiating the container, MSVC complains
+                                        // if the type of object being contained has no appropriate comparison operators
+                                        // defined (specifically, if operators '<' and '==' are undefined). This seems
+                                        // to be the case with ptw32 'pthread_t' which is a simple struct.
+#endif
+
 using namespace std;
 
-typedef std::set<pthread_t> ThreadMap;
+typedef std::list<pthread_t> ThreadMap;
 static ThreadMap all_threads;
 static pthread_mutex_t thread_map_lock = PTHREAD_MUTEX_INITIALIZER;
 static Glib::Threads::Private<char> thread_name (free);
@@ -116,7 +124,7 @@ pthread_create_and_store (string name, pthread_t  *thread, void * (*start_routin
 
        if ((ret = thread_creator (thread, &default_attr, fake_thread_start, ts)) == 0) {
                pthread_mutex_lock (&thread_map_lock);
-               all_threads.insert (*thread);
+               all_threads.push_back (*thread);
                pthread_mutex_unlock (&thread_map_lock);
        }
 
@@ -149,7 +157,7 @@ pthread_kill_all (int signum)
 {      
        pthread_mutex_lock (&thread_map_lock);
        for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ++i) {
-               if ((*i) != pthread_self()) {
+               if (!pthread_equal ((*i), pthread_self())) {
                        pthread_kill ((*i), signum);
                }
        }
@@ -161,6 +169,7 @@ void
 pthread_cancel_all () 
 {      
        pthread_mutex_lock (&thread_map_lock);
+
        for (ThreadMap::iterator i = all_threads.begin(); i != all_threads.end(); ) {
 
                ThreadMap::iterator nxt = i;