perf: avoid taking mutex on already-resolved promises (#6984)

This commit is contained in:
Sebastian Ullrich 2025-02-07 11:14:35 +01:00 committed by GitHub
parent ac9708051a
commit 1248a55d32
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -842,6 +842,10 @@ public:
}
void resolve(lean_task_object * t, object * v) {
if (t->m_value) {
dec(v);
return;
}
unique_lock<mutex> lock(m_mutex);
if (t->m_value) {
lock.unlock(); // `dec(v)` could lead to `deactivate_task` trying to take the lock