summaryrefslogtreecommitdiff
path: root/libs/pbd/pthread_utils.cc
diff options
context:
space:
mode:
Diffstat (limited to 'libs/pbd/pthread_utils.cc')
-rw-r--r--libs/pbd/pthread_utils.cc15
1 files changed, 12 insertions, 3 deletions
diff --git a/libs/pbd/pthread_utils.cc b/libs/pbd/pthread_utils.cc
index 3d3cb96fb5..b8ca8fc093 100644
--- a/libs/pbd/pthread_utils.cc
+++ b/libs/pbd/pthread_utils.cc
@@ -28,9 +28,17 @@
#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;