mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-12 09:36:33 +01:00
Replace DECLARE_DEFAULT_COMPARISONS in pthread_utils, revert some changes from about 3 weeks ago
1. Replaced DECLARE_DEFAULT_COMPARISONS (pthread_t) with 5 ddifferent LIBPBD_API inline bool operators.
2. Revert some
if (pthread_equal (t.first, pthread_self ()) != 0) {
to
if (pthread_equal (t.first, pthread_self ())) {
(along with one other example).
This commit is contained in:
parent
6efe8ceeff
commit
ffbe87961e
1 changed files with 21 additions and 11 deletions
|
|
@ -38,11 +38,21 @@
|
||||||
#include "pbd/pthread_utils.h"
|
#include "pbd/pthread_utils.h"
|
||||||
|
|
||||||
#ifdef COMPILER_MSVC
|
#ifdef COMPILER_MSVC
|
||||||
DECLARE_DEFAULT_COMPARISONS (pthread_t) // Needed for 'DECLARE_DEFAULT_COMPARISONS'. Objects in an STL container can be
|
LIBPBD_API inline bool operator<(const pthread_t& lhs, const pthread_t& rhs) {
|
||||||
// searched and sorted. Thus, when instantiating the container, MSVC complains
|
return lhs.p != rhs.p ? lhs.p < rhs.p : lhs.x < rhs.x;
|
||||||
// if the type of object being contained has no appropriate comparison operators
|
}
|
||||||
// defined (specifically, if operators '<' and '==' are undefined). This seems
|
LIBPBD_API inline bool operator==(const pthread_t& lhs, const pthread_t& rhs) {
|
||||||
// to be the case with ptw32 'pthread_t' which is a simple struct.
|
return lhs.p == rhs.p && lhs.x == rhs.x;
|
||||||
|
}
|
||||||
|
LIBPBD_API inline bool operator!=(const pthread_t& lhs, const pthread_t& rhs) {
|
||||||
|
return !(lhs == rhs);
|
||||||
|
}
|
||||||
|
LIBPBD_API inline bool operator==(const pthread_t& lhs, int rhs) {
|
||||||
|
return !rhs && !lhs.p;
|
||||||
|
}
|
||||||
|
LIBPBD_API inline bool operator!=(const pthread_t& lhs, int rhs) {
|
||||||
|
return rhs || lhs.p;
|
||||||
|
}
|
||||||
|
|
||||||
#define pthread_gethandle pthread_getw32threadhandle_np
|
#define pthread_gethandle pthread_getw32threadhandle_np
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -194,7 +204,7 @@ fake_thread_start (void* arg)
|
||||||
pthread_mutex_lock (&thread_map_lock);
|
pthread_mutex_lock (&thread_map_lock);
|
||||||
|
|
||||||
for (auto const& t : all_threads) {
|
for (auto const& t : all_threads) {
|
||||||
if (pthread_equal (t.first, pthread_self ()) != 0) {
|
if (pthread_equal (t.first, pthread_self ())) {
|
||||||
DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second));
|
DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second));
|
||||||
all_threads.erase (t.first);
|
all_threads.erase (t.first);
|
||||||
break;
|
break;
|
||||||
|
|
@ -262,7 +272,7 @@ pthread_kill_all (int signum)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock (&thread_map_lock);
|
pthread_mutex_lock (&thread_map_lock);
|
||||||
for (auto const& t : all_threads) {
|
for (auto const& t : all_threads) {
|
||||||
if (pthread_equal (t.first, pthread_self ()) != 0) {
|
if (pthread_equal (t.first, pthread_self ())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Kill: '%1'\n", t.second));
|
DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Kill: '%1'\n", t.second));
|
||||||
|
|
@ -277,7 +287,7 @@ pthread_cancel_all ()
|
||||||
{
|
{
|
||||||
pthread_mutex_lock (&thread_map_lock);
|
pthread_mutex_lock (&thread_map_lock);
|
||||||
for (auto const& t : all_threads) {
|
for (auto const& t : all_threads) {
|
||||||
if (pthread_equal (t.first, pthread_self ()) != 0) {
|
if (pthread_equal (t.first, pthread_self ())) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Cancel: '%1'\n", t.second));
|
DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Cancel: '%1'\n", t.second));
|
||||||
|
|
@ -292,7 +302,7 @@ pthread_cancel_one (pthread_t thread)
|
||||||
{
|
{
|
||||||
pthread_mutex_lock (&thread_map_lock);
|
pthread_mutex_lock (&thread_map_lock);
|
||||||
for (auto const& t : all_threads) {
|
for (auto const& t : all_threads) {
|
||||||
if (pthread_equal (t.first, thread) != 0) {
|
if (pthread_equal (t.first, thread)) {
|
||||||
all_threads.erase (t.first);
|
all_threads.erase (t.first);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -588,7 +598,7 @@ PBD::Thread::_run (void* arg)
|
||||||
/* cleanup */
|
/* cleanup */
|
||||||
pthread_mutex_lock (&thread_map_lock);
|
pthread_mutex_lock (&thread_map_lock);
|
||||||
for (auto const& t : all_threads) {
|
for (auto const& t : all_threads) {
|
||||||
if (pthread_equal (t.first, pthread_self ()) != 0) {
|
if (pthread_equal (t.first, pthread_self ())) {
|
||||||
DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second));
|
DEBUG_TRACE (PBD::DEBUG::Threads, string_compose ("Terminated: '%1'\n", t.second));
|
||||||
all_threads.erase (t.first);
|
all_threads.erase (t.first);
|
||||||
break;
|
break;
|
||||||
|
|
@ -611,5 +621,5 @@ PBD::Thread::join ()
|
||||||
bool
|
bool
|
||||||
PBD::Thread::caller_is_self () const
|
PBD::Thread::caller_is_self () const
|
||||||
{
|
{
|
||||||
return pthread_equal (_t, pthread_self ()) != 0;
|
return pthread_equal (_t, pthread_self ());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue