summaryrefslogtreecommitdiffstats
path: root/js/src/threading
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /js/src/threading
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'js/src/threading')
-rw-r--r--js/src/threading/ConditionVariable.h10
-rw-r--r--js/src/threading/ExclusiveData.h5
-rw-r--r--js/src/threading/LockGuard.h25
3 files changed, 19 insertions, 21 deletions
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<Mutex>& lock) { wait(lock.lock); }
+ void wait(UniqueLock<Mutex>& 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<Mutex>& 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>(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 <typename Mutex>
+template <typename GuardT>
class MOZ_RAII UnlockGuard;
template <typename Mutex>
class MOZ_RAII LockGuard {
- friend class UnlockGuard<Mutex>;
+ friend class UnlockGuard<LockGuard<Mutex>>;
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 <typename Mutex>
+// RAII class to temporarily unlock a LockGuard.
+template <typename GuardT>
class MOZ_RAII UnlockGuard {
- Mutex& lock;
+ GuardT& guard;
public:
- explicit UnlockGuard(LockGuard<Mutex>& 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;
};