mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 18:20:04 +00:00
!6749 Double SuspendAllScope enter may lead to perf degradation
Merge pull request !6749 from Aleksandr Emelenko/fix-double-suspendall-scopes-enter
This commit is contained in:
commit
024e742dc7
@ -166,6 +166,11 @@ void Runtime::ResumeAll(JSThread *current)
|
||||
void Runtime::SuspendAllThreadsImpl(JSThread *current)
|
||||
{
|
||||
LockHolder lock(threadsLock_);
|
||||
while (suspendNewCount_ != 0) {
|
||||
// Someone has already suspended all threads.
|
||||
// Wait until it finishes.
|
||||
threadSuspendCondVar_.Wait(&threadsLock_);
|
||||
}
|
||||
suspendNewCount_++;
|
||||
for (auto i : threads_) {
|
||||
if (i != current) {
|
||||
@ -180,6 +185,10 @@ void Runtime::ResumeAllThreadsImpl(JSThread *current)
|
||||
if (suspendNewCount_ > 0) {
|
||||
suspendNewCount_--;
|
||||
}
|
||||
if (suspendNewCount_ == 0) {
|
||||
// Signal to waiting to suspend threads
|
||||
threadSuspendCondVar_.Signal();
|
||||
}
|
||||
for (auto i : threads_) {
|
||||
if (i != current) {
|
||||
i->ResumeThread(true);
|
||||
|
@ -161,6 +161,7 @@ private:
|
||||
}
|
||||
|
||||
Mutex threadsLock_;
|
||||
ConditionVariable threadSuspendCondVar_;
|
||||
Mutex serializeLock_;
|
||||
std::list<JSThread*> threads_;
|
||||
uint32_t suspendNewCount_ {0};
|
||||
|
Loading…
Reference in New Issue
Block a user