diff options
Diffstat (limited to 'absl/base')
-rw-r--r-- | absl/base/internal/low_level_scheduling.h | 5 | ||||
-rw-r--r-- | absl/base/internal/spinlock.h | 7 | ||||
-rw-r--r-- | absl/base/spinlock_test_common.cc | 5 |
3 files changed, 12 insertions, 5 deletions
diff --git a/absl/base/internal/low_level_scheduling.h b/absl/base/internal/low_level_scheduling.h index 31261298..ed0b4bfa 100644 --- a/absl/base/internal/low_level_scheduling.h +++ b/absl/base/internal/low_level_scheduling.h @@ -29,9 +29,6 @@ extern "C" void __google_enable_rescheduling(bool disable_result); namespace absl { ABSL_NAMESPACE_BEGIN -class CondVar; -class Mutex; - namespace base_internal { class SchedulingHelper; // To allow use of SchedulingGuard. @@ -80,8 +77,6 @@ class SchedulingGuard { }; // Access to SchedulingGuard is explicitly permitted. - friend class absl::CondVar; - friend class absl::Mutex; friend class SchedulingHelper; friend class SpinLock; diff --git a/absl/base/internal/spinlock.h b/absl/base/internal/spinlock.h index 2222398b..e6ac9e64 100644 --- a/absl/base/internal/spinlock.h +++ b/absl/base/internal/spinlock.h @@ -64,7 +64,14 @@ class ABSL_LOCKABLE SpinLock { constexpr SpinLock(absl::ConstInitType, base_internal::SchedulingMode mode) : lockword_(IsCooperative(mode) ? kSpinLockCooperative : 0) {} + // For global SpinLock instances prefer trivial destructor when possible. + // Default but non-trivial destructor in some build configurations causes an + // extra static initializer. +#ifdef ABSL_INTERNAL_HAVE_TSAN_INTERFACE ~SpinLock() { ABSL_TSAN_MUTEX_DESTROY(this, __tsan_mutex_not_static); } +#else + ~SpinLock() = default; +#endif // Acquire this SpinLock. inline void Lock() ABSL_EXCLUSIVE_LOCK_FUNCTION() { diff --git a/absl/base/spinlock_test_common.cc b/absl/base/spinlock_test_common.cc index b68c51a1..b33c54ba 100644 --- a/absl/base/spinlock_test_common.cc +++ b/absl/base/spinlock_test_common.cc @@ -20,6 +20,7 @@ #include <limits> #include <random> #include <thread> // NOLINT(build/c++11) +#include <type_traits> #include <vector> #include "gtest/gtest.h" @@ -103,6 +104,10 @@ static void ThreadedTest(SpinLock* spinlock) { } } +#ifndef THREAD_SANITIZER +static_assert(std::is_trivially_destructible<SpinLock>(), ""); +#endif + TEST(SpinLock, StackNonCooperativeDisablesScheduling) { SpinLock spinlock(base_internal::SCHEDULE_KERNEL_ONLY); spinlock.Lock(); |