From 8dd16259287f58f9273002717ec4d27e97127719 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 12 Jun 2024 07:43:14 +0200 Subject: Merging upstream version 127.0. Signed-off-by: Daniel Baumann --- js/src/threading/ConditionVariable.h | 10 +++++----- js/src/threading/ExclusiveData.h | 5 ----- js/src/threading/LockGuard.h | 25 ++++++++++++++----------- 3 files changed, 19 insertions(+), 21 deletions(-) (limited to 'js/src/threading') diff --git a/js/src/threading/ConditionVariable.h b/js/src/threading/ConditionVariable.h index e2b8865cbf..5ff0590c5c 100644 --- a/js/src/threading/ConditionVariable.h +++ b/js/src/threading/ConditionVariable.h @@ -55,7 +55,7 @@ class ConditionVariable { lock.postLockChecks(); #endif } - void wait(UniqueLock& lock) { wait(lock.lock); } + void wait(UniqueLock& lock) { wait(lock.mutex); } // As with |wait|, block the current thread of execution until woken from // another thread. This method will resume waiting once woken until the given @@ -100,15 +100,15 @@ class ConditionVariable { CVStatus wait_for(UniqueLock& lock, const mozilla::TimeDuration& rel_time) { #ifdef DEBUG - lock.lock.preUnlockChecks(); + lock.mutex.preUnlockChecks(); #endif CVStatus res = - impl_.wait_for(lock.lock.impl_, rel_time) == mozilla::CVStatus::Timeout + impl_.wait_for(lock.mutex.impl_, rel_time) == mozilla::CVStatus::Timeout ? CVStatus::Timeout : CVStatus::NoTimeout; #ifdef DEBUG - lock.lock.preLockChecks(); - lock.lock.postLockChecks(); + lock.mutex.preLockChecks(); + lock.mutex.postLockChecks(); #endif return res; } diff --git a/js/src/threading/ExclusiveData.h b/js/src/threading/ExclusiveData.h index 38e89f10a1..2d8ca831bf 100644 --- a/js/src/threading/ExclusiveData.h +++ b/js/src/threading/ExclusiveData.h @@ -109,11 +109,6 @@ class ExclusiveData { explicit ExclusiveData(const MutexId& id, Args&&... args) : lock_(id), value_(std::forward(args)...) {} - ExclusiveData(ExclusiveData&& rhs) - : lock_(std::move(rhs.lock)), value_(std::move(rhs.value_)) { - MOZ_ASSERT(&rhs != this, "self-move disallowed!"); - } - ExclusiveData& operator=(ExclusiveData&& rhs) { this->~ExclusiveData(); new (mozilla::KnownNotNull, this) ExclusiveData(std::move(rhs)); diff --git a/js/src/threading/LockGuard.h b/js/src/threading/LockGuard.h index d6d7976648..8a72570225 100644 --- a/js/src/threading/LockGuard.h +++ b/js/src/threading/LockGuard.h @@ -11,31 +11,34 @@ namespace js { -template +template class MOZ_RAII UnlockGuard; template class MOZ_RAII LockGuard { - friend class UnlockGuard; + friend class UnlockGuard>; friend class ConditionVariable; - Mutex& lock; + Mutex& mutex; public: - explicit LockGuard(Mutex& aLock) : lock(aLock) { lock.lock(); } - ~LockGuard() { lock.unlock(); } + explicit LockGuard(Mutex& mutex) : mutex(mutex) { lock(); } + ~LockGuard() { unlock(); } LockGuard(const LockGuard& other) = delete; + + protected: + void lock() { mutex.lock(); } + void unlock() { mutex.unlock(); } }; -template +// RAII class to temporarily unlock a LockGuard. +template class MOZ_RAII UnlockGuard { - Mutex& lock; + GuardT& guard; public: - explicit UnlockGuard(LockGuard& aGuard) : lock(aGuard.lock) { - lock.unlock(); - } - ~UnlockGuard() { lock.lock(); } + explicit UnlockGuard(GuardT& guard) : guard(guard) { guard.unlock(); } + ~UnlockGuard() { guard.lock(); } UnlockGuard(const UnlockGuard& other) = delete; }; -- cgit v1.2.3