mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 18:20:04 +00:00
[Suspend/Resume] Fix a perf issue during entering SuspendAllScope in two threads.
Now the thread under the SuspendAllScope doesn't have any suspend request. Issue: #I9DCIT Signed-off-by: Aleksandr Emelenko <emelenko.aleksandr@huawei.com> Change-Id: I35571b4626ee0a97502b59d62841b4dc3df0ddf6
This commit is contained in:
parent
73565e8975
commit
a501d4dd52
@ -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