An optimization of the RT Lock Holder

Do not change current thread state in case we are able to immediately
acquire the lock.

Issue: #I9EQL0

Signed-off-by: Konstantin Grebenschikov <grebenschikov.konstantin@huawei.com>
Change-Id: I5bb4c825a445013931e49bbd6e7a02e29e80b16d
This commit is contained in:
Konstantin Grebenschikov 2024-04-08 10:55:16 +08:00
parent bcf11cf5a4
commit 1ce54bb4aa

View File

@ -21,6 +21,9 @@ namespace panda::ecmascript {
RuntimeLockHolder::RuntimeLockHolder(JSThread *thread, Mutex &mtx)
: thread_(thread), mtx_(mtx)
{
if (mtx_.TryLock()) {
return;
}
ThreadStateTransitionScope ts(thread_, ThreadState::WAIT);
mtx.Lock();
}