Skip to content

Commit

Permalink
perf: avoid taking mutex on already-resolved promises
Browse files Browse the repository at this point in the history
  • Loading branch information
Kha committed Feb 7, 2025
1 parent b01ca8e commit ee398e2
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/runtime/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,6 +838,10 @@ class task_manager {
}

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
Expand Down

0 comments on commit ee398e2

Please sign in to comment.