diff options
Diffstat (limited to 'absl/synchronization')
-rw-r--r-- | absl/synchronization/mutex.cc | 5 | ||||
-rw-r--r-- | absl/synchronization/mutex.h | 4 | ||||
-rw-r--r-- | absl/synchronization/mutex_test.cc | 10 |
3 files changed, 10 insertions, 9 deletions
diff --git a/absl/synchronization/mutex.cc b/absl/synchronization/mutex.cc index 06a058cf710b..33f92d8fabba 100644 --- a/absl/synchronization/mutex.cc +++ b/absl/synchronization/mutex.cc @@ -48,7 +48,6 @@ #include "absl/base/internal/spinlock.h" #include "absl/base/internal/sysinfo.h" #include "absl/base/internal/thread_identity.h" -#include "absl/base/internal/tsan_mutex_interface.h" #include "absl/base/port.h" #include "absl/debugging/stacktrace.h" #include "absl/synchronization/internal/graphcycles.h" @@ -687,10 +686,6 @@ static unsigned TsanFlags(Mutex::MuHow how) { } #endif -Mutex::Mutex() : mu_(0) { - ABSL_TSAN_MUTEX_CREATE(this, __tsan_mutex_not_static); -} - static bool DebugOnlyIsExiting() { return false; } diff --git a/absl/synchronization/mutex.h b/absl/synchronization/mutex.h index b09802b523bc..374cf57d2e94 100644 --- a/absl/synchronization/mutex.h +++ b/absl/synchronization/mutex.h @@ -64,6 +64,7 @@ #include "absl/base/internal/identity.h" #include "absl/base/internal/low_level_alloc.h" #include "absl/base/internal/thread_identity.h" +#include "absl/base/internal/tsan_mutex_interface.h" #include "absl/base/port.h" #include "absl/base/thread_annotations.h" #include "absl/synchronization/internal/kernel_timeout.h" @@ -860,6 +861,9 @@ class SCOPED_LOCKABLE ReleasableMutexLock { #ifdef ABSL_INTERNAL_USE_NONPROD_MUTEX #else +inline Mutex::Mutex() : mu_(0) { + ABSL_TSAN_MUTEX_CREATE(this, __tsan_mutex_not_static); +} inline CondVar::CondVar() : cv_(0) {} #endif diff --git a/absl/synchronization/mutex_test.cc b/absl/synchronization/mutex_test.cc index 5a5874def72d..53b937843a34 100644 --- a/absl/synchronization/mutex_test.cc +++ b/absl/synchronization/mutex_test.cc @@ -1234,10 +1234,12 @@ static void CheckResults(bool exp_result, bool act_result, absl::Duration act_duration) { ABSL_RAW_CHECK(exp_result == act_result, "CheckResults failed"); // Allow for some worse-case scheduling delay and clock skew. - ABSL_RAW_CHECK(exp_duration - absl::Milliseconds(40) <= act_duration, - "CheckResults failed"); - ABSL_RAW_CHECK(exp_duration + absl::Milliseconds(150) >= act_duration, - "CheckResults failed"); + if ((exp_duration - absl::Milliseconds(40) > act_duration) || + (exp_duration + absl::Milliseconds(150) < act_duration)) { + ABSL_RAW_LOG(FATAL, "CheckResults failed: operation took %s, expected %s", + absl::FormatDuration(act_duration).c_str(), + absl::FormatDuration(exp_duration).c_str()); + } } static void TestAwaitTimeout(Cond *cp, absl::Duration timeout, bool exp_result, |